getOpenstackBasedPlatforms() public static method

Gets the list of OpenStack based clouds
public static getOpenstackBasedPlatforms ( ) : array
return array Returns the list of OpenStack based clouds
Beispiel #1
0
 /**
  * Performs upgrade literally for the stage ONE.
  *
  * Implementation of this method performs update steps needs to be taken
  * to accomplish upgrade successfully.
  *
  * If there are any error during an execution of this scenario it must
  * throw an exception.
  *
  * @param   int  $stage  optional The stage number
  * @throws  \Exception
  */
 protected function run1($stage)
 {
     $environments = $this->db->Execute("SELECT id FROM client_environments WHERE status='Active'");
     while ($env = $environments->FetchRow()) {
         $environment = \Scalr_Environment::init()->loadById($env['id']);
         foreach (PlatformFactory::getOpenstackBasedPlatforms() as $platform) {
             if ($platform == \SERVER_PLATFORMS::RACKSPACENG_UK || $platform == \SERVER_PLATFORMS::RACKSPACENG_US) {
                 continue;
             }
             try {
                 if ($environment->isPlatformEnabled($platform)) {
                     $os = $environment->openstack($platform);
                     //It throws an exception on failure
                     $zones = $os->listZones();
                     $zone = array_shift($zones);
                     $os = $environment->openstack($platform, $zone->name);
                     // Check SG Extension
                     $pars[$this->getOpenStackOption($platform, 'EXT_SECURITYGROUPS_ENABLED')] = (int) $os->servers->isExtensionSupported(ServersExtension::securityGroups());
                     // Check Floating Ips Extension
                     $pars[$this->getOpenStackOption($platform, 'EXT_FLOATING_IPS_ENABLED')] = (int) $os->servers->isExtensionSupported(ServersExtension::floatingIps());
                     // Check Cinder Extension
                     $pars[$this->getOpenStackOption($platform, 'EXT_CINDER_ENABLED')] = (int) $os->hasService('volume');
                     // Check Swift Extension
                     $pars[$this->getOpenStackOption($platform, 'EXT_SWIFT_ENABLED')] = (int) $os->hasService('object-store');
                     // Check LBaas Extension
                     $pars[$this->getOpenStackOption($platform, 'EXT_LBAAS_ENABLED')] = $os->hasService('network') ? (int) $os->network->isExtensionSupported('lbaas') : 0;
                     $environment->setPlatformConfig($pars);
                 }
             } catch (\Exception $e) {
                 $this->console->out("Update settings for env: {$env['id']} failed: " . $e->getMessage());
             }
         }
     }
 }
Beispiel #2
0
 public function viewAction()
 {
     if ($this->getParam('platform')) {
         $locations = self::loadController('Platforms')->getCloudLocations(array($this->getParam('platform')), false);
     } else {
         $locations = self::loadController('Platforms')->getCloudLocations(PlatformFactory::getOpenstackBasedPlatforms(), false);
     }
     $this->response->page('ui/tools/openstack/volumes/view.js', array('locations' => $locations));
 }
Beispiel #3
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]);
     }
 }
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::RemoveServerSnapshot()
  */
 public function RemoveServerSnapshot(DBRole $DBRole)
 {
     foreach (PlatformFactory::getOpenstackBasedPlatforms() as $platform) {
         $images = $DBRole->getImageId($platform);
         if (count($images) > 0) {
             foreach ($images as $location => $imageId) {
                 try {
                     $osClient = $DBRole->getEnvironmentObject()->openstack($platform, $location);
                     $osClient->servers->images->delete($imageId);
                 } catch (\Exception $e) {
                     if (stristr($e->getMessage(), "Unavailable service \"compute\" or region") || stristr($e->getMessage(), "Image not found") || stristr($e->getMessage(), "Cannot destroy a destroyed snapshot") || stristr($e->getMessage(), "OpenStack error. Could not find user")) {
                         //DO NOTHING
                     } else {
                         throw $e;
                     }
                 }
             }
         }
     }
     return true;
 }
Beispiel #5
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;
 }
Beispiel #6
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 #7
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']);
 }