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


PHP Scalr_Environment::cloudCredentialsList方法代码示例

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


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

示例1: xSaveRackspaceAction

 public function xSaveRackspaceAction()
 {
     $pars = array();
     $locations = array('rs-ORD1', 'rs-LONx');
     $enabled = false;
     /* @var $currentCloudCredentials Entity\CloudCredentials[] */
     $currentCloudCredentials = $this->env->cloudCredentialsList(array_map(function ($location) {
         return "{$location}." . SERVER_PLATFORMS::RACKSPACE;
     }, $locations));
     foreach ($currentCloudCredentials as $cloudCredential) {
         if ($cloudCredential->isEnabled()) {
             $enabled = true;
             break;
         }
     }
     if (!$enabled) {
         throw new Scalr_Exception_Core('Rackspace cloud has been deprecated. Please use Rackspace Open Cloud instead.');
     } else {
         $enabled = false;
     }
     foreach ($locations as $location) {
         if ($this->getParam("rackspace_is_enabled_{$location}")) {
             $enabled = true;
             $pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_USERNAME] = $this->checkVar(Entity\CloudCredentialsProperty::RACKSPACE_USERNAME, 'string', "Username required", $location . SERVER_PLATFORMS::RACKSPACE);
             $pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_API_KEY] = $this->checkVar(Entity\CloudCredentialsProperty::RACKSPACE_API_KEY, 'string', "API Key required", $location . SERVER_PLATFORMS::RACKSPACE);
             $pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_IS_MANAGED] = $this->checkVar(Entity\CloudCredentialsProperty::RACKSPACE_IS_MANAGED, 'bool', "", $location . SERVER_PLATFORMS::RACKSPACE);
         } else {
             $pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_USERNAME] = false;
             $pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_API_KEY] = false;
             $pars[$location][Entity\CloudCredentialsProperty::RACKSPACE_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->makeCloudCredentials("{$cloud}." . SERVER_PLATFORMS::RACKSPACE, $prs);
                 $this->env->setPlatformConfig([Entity\Account\EnvironmentProperty::RACKSPACE_LOCATIONS => 'enabled'], 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:mheydt,项目名称:scalr,代码行数:55,代码来源:Platform.php


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