当前位置: 首页>>代码示例>>PHP>>正文


PHP Scalr_Environment::isPlatformEnabled方法代码示例

本文整理汇总了PHP中Scalr_Environment::isPlatformEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Scalr_Environment::isPlatformEnabled方法的具体用法?PHP Scalr_Environment::isPlatformEnabled怎么用?PHP Scalr_Environment::isPlatformEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scalr_Environment的用法示例。


在下文中一共展示了Scalr_Environment::isPlatformEnabled方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Set test names for objects
  */
 protected function setUp()
 {
     parent::setUp();
     if ($this->isSkipFunctionalTests()) {
         $this->markTestSkipped();
     }
     $testEnvId = \Scalr::config('scalr.phpunit.envid');
     try {
         $this->testEnv = \Scalr_Environment::init()->loadById($testEnvId);
     } catch (Exception $e) {
         $this->markTestSkipped('Test Environment does not exist.');
     }
     if (!$this->testEnv || !$this->testEnv->isPlatformEnabled(\SERVER_PLATFORMS::AZURE)) {
         $this->markTestSkipped('Azure platform is not enabled.');
     }
     $this->azure = $this->testEnv->azure();
     $this->subscriptionId = $this->azure->getEnvironment()->cloudCredentials(SERVER_PLATFORMS::AZURE)->properties[Entity\CloudCredentialsProperty::AZURE_SUBSCRIPTION_ID];
     $this->resourceGroupName = 'test3-resource-group-' . $this->getInstallationId();
     $this->availabilitySetName = 'test3-availability-set-' . $this->getInstallationId();
     $this->vmName = 'test3-virtual-machine-' . $this->getInstallationId();
     $this->vnName = 'test3-virtual-network-' . $this->getInstallationId();
     $this->nicName = 'test3-network-interface' . $this->getInstallationId();
     $this->publicIpName = 'myPublicIP3';
     $this->storageName = 'teststorage3' . $this->getInstallationId();
     $this->sgName = 'test3-security-group' . $this->getInstallationId();
 }
开发者ID:mheydt,项目名称:scalr,代码行数:29,代码来源:AzureTest.php

示例2: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     if ($environment === null || !$environment->isPlatformEnabled($this->platform)) {
         return array();
     }
     try {
         $client = $environment->openstack($this->platform, "fakeRegion");
         foreach ($client->listZones() as $zone) {
             $retval[$zone->name] = ucfirst($this->platform) . " / {$zone->name}";
         }
     } catch (\Exception $e) {
         return array();
     }
     return $retval;
 }
开发者ID:rickb838,项目名称:scalr,代码行数:19,代码来源:OpenstackPlatformModule.php

示例3: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     if (!$environment || !$environment->isPlatformEnabled($this->platform)) {
         return array();
     }
     try {
         $cs = $environment->cloudstack($this->platform);
         foreach ($cs->zone->describe() as $zone) {
             $retval[$zone->name] = ucfirst($this->platform) . " / {$zone->name}";
         }
     } catch (\Exception $e) {
         return array();
     }
     return $retval;
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:19,代码来源:CloudstackPlatformModule.php

示例4: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     $retval = [];
     if ($environment && $environment->isPlatformEnabled($this->platform)) {
         try {
             $client = $environment->openstack($this->platform, "fakeRegion");
             foreach ($client->listZones() as $zone) {
                 $retval[$zone->name] = ucfirst($this->platform) . " / {$zone->name}";
             }
         } catch (\Exception $e) {
             // No need to do anything here
             // If we cannot get list of cloud locations - will return an empty one
         }
     }
     return $retval;
 }
开发者ID:scalr,项目名称:scalr,代码行数:20,代码来源:OpenstackPlatformModule.php

示例5: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     $retval = [];
     if ($environment && $environment->isPlatformEnabled(\SERVER_PLATFORMS::GCE)) {
         try {
             $client = $this->getClient($environment);
             $zones = $client->zones->listZones($environment->keychain(SERVER_PLATFORMS::GCE)->properties[Entity\CloudCredentialsProperty::GCE_PROJECT_ID]);
             foreach ($zones->getItems() as $zone) {
                 if ($zone->status == 'UP') {
                     $retval[$zone->getName()] = $zone->getName();
                 }
             }
         } catch (Exception $e) {
         }
     }
     return $retval;
 }
开发者ID:scalr,项目名称:scalr,代码行数:21,代码来源:GoogleCEPlatformModule.php

示例6: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     if ($environment === null || !$environment->isPlatformEnabled(\SERVER_PLATFORMS::AZURE)) {
         return [];
     }
     $locationsResponse = $environment->azure()->getLocationsList();
     $retval = [];
     foreach ($locationsResponse->resourceTypes as $rt) {
         /* @var $rt \Scalr\Service\Azure\DataType\ResourceTypeData */
         if ($rt->resourceType == 'locations/vmSizes') {
             foreach ($rt->locations as $location) {
                 $retval[strtolower(str_replace(" ", "", $location))] = $location;
             }
         }
     }
     return $retval;
 }
开发者ID:mheydt,项目名称:scalr,代码行数:21,代码来源:AzurePlatformModule.php

示例7: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     if ($environment === null || !$environment->isPlatformEnabled(\SERVER_PLATFORMS::GCE)) {
         return array();
     }
     try {
         $client = $this->getClient($environment);
         $zones = $client->zones->listZones($environment->getPlatformConfigValue(self::PROJECT_ID));
         foreach ($zones->getItems() as $zone) {
             if ($zone->status == 'UP') {
                 $retval[$zone->getName()] = $zone->getName();
             }
         }
     } catch (\Exception $e) {
         return array();
     }
     return $retval;
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:22,代码来源:GoogleCEPlatformModule.php

示例8: getLocations

 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\Platforms\Cloudstack\CloudstackPlatformModule::getLocations()
  */
 public function getLocations(\Scalr_Environment $environment = null)
 {
     if ($environment === null || !$environment->isPlatformEnabled($this->platform)) {
         return array();
     }
     try {
         $cs = $environment->cloudstack($this->platform);
         $products = $cs->listAvailableProductTypes();
         if (count($products) > 0) {
             foreach ($products as $product) {
                 $retval[$product->zoneid] = "KT uCloud / {$product->zonedesc} ({$product->zoneid})";
             }
         }
     } catch (\Exception $e) {
         return array();
     }
     return $retval;
 }
开发者ID:rickb838,项目名称:scalr,代码行数:22,代码来源:UCloudPlatformModule.php

示例9: saveRackspace

 private function saveRackspace()
 {
     $pars = array();
     $enabled = false;
     $locations = array('rs-ORD1', 'rs-LONx');
     if (!$this->env->isPlatformEnabled(SERVER_PLATFORMS::RACKSPACE)) {
         throw new Scalr_Exception_Core('Rackspace cloud has been deprecated. Please use Rackspace Open Cloud instead.');
     }
     foreach ($locations as $location) {
         if ($this->getParam("rackspace_is_enabled_{$location}")) {
             $enabled = true;
             $pars[$location][RackspacePlatformModule::USERNAME] = $this->checkVar(RackspacePlatformModule::USERNAME, 'string', "Username required", $location);
             $pars[$location][RackspacePlatformModule::API_KEY] = $this->checkVar(RackspacePlatformModule::API_KEY, 'string', "API Key required", $location);
             $pars[$location][RackspacePlatformModule::IS_MANAGED] = $this->checkVar(RackspacePlatformModule::IS_MANAGED, 'bool', "", $location);
         } else {
             $pars[$location][RackspacePlatformModule::USERNAME] = false;
             $pars[$location][RackspacePlatformModule::API_KEY] = false;
             $pars[$location][RackspacePlatformModule::IS_MANAGED] = false;
         }
     }
     if (count($this->checkVarError)) {
         $this->response->failure();
         $this->response->data(array('errors' => $this->checkVarError));
     } else {
         $this->db->BeginTrans();
         try {
             $this->env->enablePlatform(SERVER_PLATFORMS::RACKSPACE, $enabled);
             foreach ($pars as $cloud => $prs) {
                 $this->env->setPlatformConfig($prs, true, $cloud);
             }
             if (!$this->user->getAccount()->getSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED)) {
                 $this->user->getAccount()->setSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED, time());
             }
             $this->response->success('Cloud credentials have been ' . ($enabled ? 'saved' : 'removed from Scalr'));
             $this->response->data(array('enabled' => $enabled));
         } catch (Exception $e) {
             $this->db->RollbackTrans();
             throw new Exception(_('Failed to save Rackspace settings'));
         }
         $this->db->CommitTrans();
     }
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:42,代码来源:Clouds.php

示例10: saveEc2

 private function saveEc2()
 {
     $pars = [];
     $enabled = false;
     $envAutoEnabled = false;
     $bNew = !$this->env->isPlatformEnabled(SERVER_PLATFORMS::EC2);
     $currentCloudCredentials = $this->env->keychain(SERVER_PLATFORMS::EC2);
     $ccProps = $currentCloudCredentials->properties;
     if ($this->getParam('ec2_is_enabled')) {
         $enabled = true;
         $pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_TYPE] = trim($this->checkVar(Entity\CloudCredentialsProperty::AWS_ACCOUNT_TYPE, 'string', "AWS Account Type required", SERVER_PLATFORMS::EC2));
         $pars[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY] = trim($this->checkVar(Entity\CloudCredentialsProperty::AWS_ACCESS_KEY, 'string', "AWS Access Key required", SERVER_PLATFORMS::EC2));
         $pars[Entity\CloudCredentialsProperty::AWS_SECRET_KEY] = trim($this->checkVar(Entity\CloudCredentialsProperty::AWS_SECRET_KEY, 'password', "AWS Access Key required", SERVER_PLATFORMS::EC2));
         $pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] = $this->checkVar(Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY, 'file', '', SERVER_PLATFORMS::EC2);
         $pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] = $this->checkVar(Entity\CloudCredentialsProperty::AWS_CERTIFICATE, 'file', '', SERVER_PLATFORMS::EC2);
         if ($this->getContainer()->analytics->enabled) {
             $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_ENABLED] = $this->checkVar2(Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_ENABLED, 'bool', '', SERVER_PLATFORMS::EC2);
             if (!empty($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_ENABLED])) {
                 $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET] = $this->checkVar(Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET, 'string', "Detailed billing bucket name is required", SERVER_PLATFORMS::EC2);
                 $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT] = $this->checkVar2(Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT, 'string', '', SERVER_PLATFORMS::EC2);
                 $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_REGION] = $this->checkVar(Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_REGION, 'string', "Aws region is required", SERVER_PLATFORMS::EC2);
             } else {
                 $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET] = false;
                 $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT] = false;
                 $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_REGION] = false;
             }
         }
         // user can mull certificate and private key, check it
         if (strpos($pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY], 'BEGIN CERTIFICATE') !== FALSE && strpos($pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE], 'BEGIN PRIVATE KEY') !== FALSE) {
             // swap it
             $key = $pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY];
             $pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] = $pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE];
             $pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] = $key;
         }
         if ($pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_TYPE] == Entity\CloudCredentialsProperty::AWS_ACCOUNT_TYPE_GOV_CLOUD) {
             $region = \Scalr\Service\Aws::REGION_US_GOV_WEST_1;
         } else {
             if ($pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_TYPE] == Entity\CloudCredentialsProperty::AWS_ACCOUNT_TYPE_CN_CLOUD) {
                 $region = \Scalr\Service\Aws::REGION_CN_NORTH_1;
             } else {
                 $region = \Scalr\Service\Aws::REGION_US_EAST_1;
             }
         }
         if (!count($this->checkVarError)) {
             if ($pars[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY] != $ccProps[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY] or $pars[Entity\CloudCredentialsProperty::AWS_SECRET_KEY] != $ccProps[Entity\CloudCredentialsProperty::AWS_SECRET_KEY] or $pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] != $ccProps[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] or $pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] != $ccProps[Entity\CloudCredentialsProperty::AWS_CERTIFICATE]) {
                 $aws = $this->env->aws($region, $pars[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $pars[Entity\CloudCredentialsProperty::AWS_SECRET_KEY], !empty($pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE]) ? $pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] : null, !empty($pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY]) ? $pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] : null);
                 //Validates private key and certificate if they are provided
                 if (!empty($pars[Entity\CloudCredentialsProperty::AWS_CERTIFICATE]) || !empty($pars[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY])) {
                     try {
                         //SOAP is not supported anymore
                         //$aws->validateCertificateAndPrivateKey();
                     } catch (Exception $e) {
                         throw new Exception(_("Incorrect format of X.509 certificate or private key. Make sure that you are using files downloaded from AWS profile. ({$e->getMessage()})"));
                     }
                 }
                 //Validates both access and secret keys
                 try {
                     $buckets = $aws->s3->bucket->getList();
                 } catch (Exception $e) {
                     throw new Exception(sprintf(_("Failed to verify your EC2 access key and secret key: %s"), $e->getMessage()));
                 }
                 //Extract AWS Account ID
                 $pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID] = $aws->getAccountNumber();
                 try {
                     if ($ccProps[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID] != $pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID]) {
                         $this->db->Execute("DELETE FROM client_environment_properties WHERE name LIKE 'ec2.vpc.default%' AND env_id = ?", [$this->env->id]);
                     }
                 } catch (Exception $e) {
                 }
             } else {
                 $pars[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID] = $ccProps[Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID];
             }
         } else {
             $this->response->failure();
             $this->response->data(['errors' => $this->checkVarError]);
             return;
         }
     }
     if ($enabled && $this->getContainer()->analytics->enabled && !empty($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET])) {
         try {
             $region = $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_REGION];
             $aws = $this->env->aws($region, $pars[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $pars[Entity\CloudCredentialsProperty::AWS_SECRET_KEY]);
             if (!empty($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]) && $aws->getAccountNumber() != $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]) {
                 $payerCredentials = $this->getUser()->getAccount()->cloudCredentialsList([SERVER_PLATFORMS::EC2], [], [Entity\CloudCredentialsProperty::AWS_ACCOUNT_ID => [['value' => $pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_PAYER_ACCOUNT]]]]);
                 if (count($payerCredentials) == 0) {
                     throw new Exception("Payer account not found!");
                 }
                 $payerCredentials = $payerCredentials->current();
                 $aws = $this->env->aws($region, $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_SECRET_KEY], !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] : null, !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] : null);
             }
             try {
                 $bucketObjects = $aws->s3->bucket->listObjects($pars[Entity\CloudCredentialsProperty::AWS_DETAILED_BILLING_BUCKET]);
             } catch (ClientException $e) {
                 if ($e->getErrorData() && $e->getErrorData()->getCode() == ErrorData::ERR_AUTHORIZATION_HEADER_MALFORMED && preg_match("/expecting\\s+'(.+?)'/", $e->getMessage(), $matches) && in_array($matches[1], Aws::getCloudLocations())) {
                     $expectingRegion = $matches[1];
                     if (isset($payerCredentials)) {
                         $aws = $this->env->aws($expectingRegion, $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_SECRET_KEY], !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_CERTIFICATE] : null, !empty($payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY]) ? $payerCredentials->properties[Entity\CloudCredentialsProperty::AWS_PRIVATE_KEY] : null);
                     } else {
                         $aws = $this->env->aws($expectingRegion, $pars[Entity\CloudCredentialsProperty::AWS_ACCESS_KEY], $pars[Entity\CloudCredentialsProperty::AWS_SECRET_KEY]);
                     }
//.........这里部分代码省略.........
开发者ID:scalr,项目名称:scalr,代码行数:101,代码来源:Clouds.php

示例11: skipIfEc2PlatformDisabled

 /**
  * Skips test functionals tests are skipped or if Ec2 platform is not enabled.
  */
 protected function skipIfEc2PlatformDisabled()
 {
     if ($this->isSkipFunctionalTests() || !$this->environment || !$this->environment->isPlatformEnabled(\SERVER_PLATFORMS::EC2)) {
         $this->markTestSkipped('Ec2 platform is not enabled.');
     }
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:9,代码来源:AwsTestCase.php

示例12: saveOpenstack

 private function saveOpenstack()
 {
     $pars = array();
     $enabled = false;
     $platform = $this->getParam('platform');
     $bNew = !$this->env->isPlatformEnabled($platform);
     if (!$bNew) {
         $oldUrl = $this->env->getPlatformConfigValue($this->getOpenStackOption('KEYSTONE_URL'));
     }
     if ($this->getParam("{$platform}_is_enabled")) {
         $enabled = true;
         $pars[$this->getOpenStackOption('KEYSTONE_URL')] = trim($this->checkVar(OpenstackPlatformModule::KEYSTONE_URL, 'string', 'KeyStone URL required'));
         $pars[$this->getOpenStackOption('SSL_VERIFYPEER')] = trim($this->checkVar(OpenstackPlatformModule::SSL_VERIFYPEER, 'int'));
         $pars[$this->getOpenStackOption('USERNAME')] = $this->checkVar(OpenstackPlatformModule::USERNAME, 'string', 'Username required');
         $pars[$this->getOpenStackOption('PASSWORD')] = $this->checkVar(OpenstackPlatformModule::PASSWORD, 'password', '', '', false, $platform);
         $pars[$this->getOpenStackOption('API_KEY')] = $this->checkVar(OpenstackPlatformModule::API_KEY, 'string');
         if ($platform == SERVER_PLATFORMS::ECS) {
             $pars[$this->getOpenStackOption('TENANT_NAME')] = $this->checkVar(OpenstackPlatformModule::TENANT_NAME, 'password', '', '', false, $platform);
         } else {
             $pars[$this->getOpenStackOption('TENANT_NAME')] = $this->checkVar(OpenstackPlatformModule::TENANT_NAME, 'string');
         }
         if (empty($this->checkVarError) && empty($pars[$this->getOpenStackOption('PASSWORD')]) && empty($pars[$this->getOpenStackOption('API_KEY')])) {
             $this->checkVarError['api_key'] = $this->checkVarError['password'] = 'Either API Key or password must be provided.';
         }
     }
     if (count($this->checkVarError)) {
         $this->response->failure();
         $this->response->data(array('errors' => $this->checkVarError));
     } else {
         if ($this->getParam($platform . "_is_enabled")) {
             $os = new OpenStack(new OpenStackConfig($pars[$this->getOpenStackOption('USERNAME')], $pars[$this->getOpenStackOption('KEYSTONE_URL')], 'fake-region', $pars[$this->getOpenStackOption('API_KEY')], null, null, $pars[$this->getOpenStackOption('PASSWORD')], $pars[$this->getOpenStackOption('TENANT_NAME')]));
             //It throws an exception on failure
             $zones = $os->listZones();
             $zone = array_shift($zones);
             $os = new OpenStack(new OpenStackConfig($pars[$this->getOpenStackOption('USERNAME')], $pars[$this->getOpenStackOption('KEYSTONE_URL')], $zone->name, $pars[$this->getOpenStackOption('API_KEY')], null, null, $pars[$this->getOpenStackOption('PASSWORD')], $pars[$this->getOpenStackOption('TENANT_NAME')]));
             // Check SG Extension
             $pars[$this->getOpenStackOption('EXT_SECURITYGROUPS_ENABLED')] = (int) $os->servers->isExtensionSupported(ServersExtension::securityGroups());
             // Check Floating Ips Extension
             $pars[$this->getOpenStackOption('EXT_FLOATING_IPS_ENABLED')] = (int) $os->servers->isExtensionSupported(ServersExtension::floatingIps());
             // Check Cinder Extension
             $pars[$this->getOpenStackOption('EXT_CINDER_ENABLED')] = (int) $os->hasService('volume');
             // Check Swift Extension
             $pars[$this->getOpenStackOption('EXT_SWIFT_ENABLED')] = (int) $os->hasService('object-store');
             // Check LBaas Extension
             $pars[$this->getOpenStackOption('EXT_LBAAS_ENABLED')] = $os->hasService('network') ? (int) $os->network->isExtensionSupported('lbaas') : 0;
         }
         $this->db->BeginTrans();
         try {
             $this->env->enablePlatform($platform, $enabled);
             if ($enabled) {
                 $this->env->setPlatformConfig($pars);
                 if ($this->getContainer()->analytics->enabled && ($bNew || $oldUrl !== $pars[$this->getOpenStackOption('KEYSTONE_URL')])) {
                     $this->getContainer()->analytics->notifications->onCloudAdd($platform, $this->env, $this->user);
                 }
             } else {
                 $this->env->setPlatformConfig(array("{$platform}." . OpenstackPlatformModule::AUTH_TOKEN => false));
             }
             if (!$this->user->getAccount()->getSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED)) {
                 $this->user->getAccount()->setSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED, time());
             }
             $this->response->success('Cloud credentials have been ' . ($enabled ? 'saved' : 'removed from Scalr'));
             $this->response->data(array('enabled' => $enabled));
         } catch (Exception $e) {
             $this->db->RollbackTrans();
             throw new Exception(_('Failed to save ' . ucfirst($platform) . ' settings'));
         }
         $this->db->CommitTrans();
     }
 }
开发者ID:rickb838,项目名称:scalr,代码行数:69,代码来源:Clouds.php


注:本文中的Scalr_Environment::isPlatformEnabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。