getCloudstackBasedPlatforms() public static method

Gets the list of CloudStack based clouds
public static getCloudstackBasedPlatforms ( ) : array
return array Returns the list of CloudStack based clouds
Beispiel #1
0
 protected function run4()
 {
     $this->console->notice('Fill image_id in servers table');
     // ec2
     $this->db->Execute("\n            UPDATE servers s JOIN server_properties sp ON s.server_id = sp.server_id\n            SET s.image_id = sp.value\n            WHERE sp.name = ? AND s.platform = ?\n        ", [\EC2_SERVER_PROPERTIES::AMIID, \SERVER_PLATFORMS::EC2]);
     // rackspace
     $this->db->Execute("\n            UPDATE servers s JOIN server_properties sp ON s.server_id = sp.server_id\n            SET s.image_id = sp.value\n            WHERE sp.name = ? AND s.platform = ?\n        ", [\RACKSPACE_SERVER_PROPERTIES::IMAGE_ID, \SERVER_PLATFORMS::RACKSPACE]);
     //cloudstack
     foreach (PlatformFactory::getCloudstackBasedPlatforms() as $platform) {
         foreach ($this->db->GetCol('SELECT server_id FROM servers WHERE platform = ?', [$platform]) as $serverId) {
             try {
                 $dbServer = \DBServer::LoadByID($serverId);
                 $env = (new \Scalr_Environment())->loadById($dbServer->envId);
                 if ($dbServer->GetProperty(\CLOUDSTACK_SERVER_PROPERTIES::SERVER_ID)) {
                     $lst = $env->cloudstack($platform)->instance->describe(['id' => $dbServer->GetProperty(\CLOUDSTACK_SERVER_PROPERTIES::SERVER_ID)]);
                     if ($lst && $lst->count() == 1) {
                         $instance = $lst->offsetGet(0);
                         $dbServer->imageId = $instance->templateid;
                         $this->console->notice('Set imageId: %s for serverId: %s', $dbServer->imageId, $serverId);
                         $dbServer->save();
                     } else {
                         $this->console->warning('Instance not found: %s for serverId: %s', $dbServer->GetProperty(\CLOUDSTACK_SERVER_PROPERTIES::SERVER_ID), $serverId);
                     }
                 }
             } catch (\Exception $e) {
                 $this->console->warning($e->getMessage());
             }
         }
     }
     // openstack
     foreach (PlatformFactory::getOpenstackBasedPlatforms() as $platform) {
         $this->db->Execute("\n                UPDATE servers s LEFT JOIN server_properties sp ON s.server_id = sp.server_id\n                SET s.image_id = sp.value\n                WHERE sp.name = ? AND s.platform = ?\n            ", [\OPENSTACK_SERVER_PROPERTIES::IMAGE_ID, $platform]);
     }
 }
 public function _cloudCredentialsType($from, $to, $action)
 {
     switch ($action) {
         case static::ACT_CONVERT_TO_OBJECT:
             /* @var $from Entity\CloudCredentials */
             $to->cloudCredentialsType = static::CLOUD_CREDENTIALS_TYPE_CLOUDSTACK;
             break;
         case static::ACT_CONVERT_TO_ENTITY:
             /* @var $to Entity\CloudCredentials */
             $to->cloud = $this->getCloudstackProvider($from);
             break;
         case static::ACT_GET_FILTER_CRITERIA:
             return [['cloud' => ['$in' => PlatformFactory::getCloudstackBasedPlatforms()]]];
     }
 }
Beispiel #3
0
 /**
  * Returns the list of the disabled resources for current installation
  *
  * It looks in the config.
  *
  * @return  array Returns array of the disabled ACL resources
  */
 public static function getDisabledResources()
 {
     if (!isset(self::$disabledResources)) {
         self::$disabledResources = array();
         $allowedClouds = \Scalr::config('scalr.allowed_clouds');
         if (!\Scalr::config('scalr.dns.global.enabled')) {
             //If DNS is disabled in the config we should not use it in the ACL
             self::$disabledResources[] = self::RESOURCE_DNS_ZONES;
         }
         if (!\Scalr::config('scalr.billing.enabled')) {
             //If Billing is disabled in the config we should not use it in the ACL
             self::$disabledResources[] = self::RESOURCE_ADMINISTRATION_BILLING;
         }
         if (array_intersect(PlatformFactory::getCloudstackBasedPlatforms(), $allowedClouds) === array()) {
             //If any cloudstack based cloud is not allowed we should not use these permissions
             self::$disabledResources[] = self::RESOURCE_CLOUDSTACK_VOLUMES;
             self::$disabledResources[] = self::RESOURCE_CLOUDSTACK_SNAPSHOTS;
             self::$disabledResources[] = self::RESOURCE_CLOUDSTACK_PUBLIC_IPS;
         }
         if (array_intersect(PlatformFactory::getOpenstackBasedPlatforms(), $allowedClouds) === array()) {
             //If any openstack base cloud is not allowed we should not use these permissions
             self::$disabledResources[] = self::RESOURCE_OPENSTACK_VOLUMES;
             self::$disabledResources[] = self::RESOURCE_OPENSTACK_SNAPSHOTS;
             self::$disabledResources[] = self::RESOURCE_OPENSTACK_PUBLIC_IPS;
         }
     }
     return self::$disabledResources;
 }
 public function _cloudCredentialsType($from, $to, $action)
 {
     switch ($action) {
         case static::ACT_CONVERT_TO_OBJECT:
             /* @var $from Entity\CloudCredentials */
             $to->cloudCredentialsType = static::$cloudsMap[$from->cloud];
             break;
         case static::ACT_CONVERT_TO_ENTITY:
             /* @var $to Entity\CloudCredentials */
             $to->cloud = array_flip(static::$cloudsMap)[$from->cloudCredentialsType];
             break;
         case static::ACT_GET_FILTER_CRITERIA:
             switch ($from->cloudCredentialsType) {
                 case static::CLOUD_CREDENTIALS_TYPE_OPENSTACK:
                     $cloud = ['$in' => PlatformFactory::getCanonicalOpenstackPlatforms()];
                     break;
                 case static::CLOUD_CREDENTIALS_TYPE_CLOUDSTACK:
                     $cloud = ['$in' => PlatformFactory::getCloudstackBasedPlatforms()];
                     break;
                 case static::CLOUD_CREDENTIALS_TYPE_RACKSPACE:
                     $cloud = ['$in' => PlatformFactory::getRackspacePlatforms()];
                     break;
                 default:
                     $clouds = array_flip(static::$cloudsMap);
                     if (empty($clouds[$from->cloudCredentialsType])) {
                         throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Unknown cloudCredentialsType '{$from->cloudCredentialsType}'");
                     }
                     $cloud = $clouds[$from->cloudCredentialsType];
                     break;
             }
             return [['cloud' => $cloud]];
     }
 }
Beispiel #5
0
 /**
  * Gets array of supported clouds
  *
  * @return array
  */
 public function getSupportedClouds()
 {
     $allowedClouds = (array) \Scalr::config('scalr.allowed_clouds');
     return array_values(array_intersect($allowedClouds, array_merge([SERVER_PLATFORMS::EC2, SERVER_PLATFORMS::GCE], PlatformFactory::getOpenstackBasedPlatforms(), PlatformFactory::getCloudstackBasedPlatforms())));
 }
Beispiel #6
0
 public function defaultAction()
 {
     //Platforms should be in the same order everywhere
     $platforms = array_values(array_intersect(array_keys(SERVER_PLATFORMS::GetList()), array_merge([SERVER_PLATFORMS::EC2], PlatformFactory::getOpenstackBasedPlatforms(), PlatformFactory::getCloudstackBasedPlatforms())));
     $this->response->page('ui/analytics/pricing/view.js', ['platforms' => $platforms, 'forbidAutomaticUpdate' => [SERVER_PLATFORMS::EC2 => !!SettingEntity::getValue(SettingEntity::ID_FORBID_AUTOMATIC_UPDATE_AWS_PRICES)]], [], ['ui/analytics/pricing/view.css']);
 }