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


PHP PlatformFactory::isOpenstack方法代码示例

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


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

示例1: deleteAction

 public function deleteAction()
 {
     $this->request->defineParams(array('sshKeyId' => array('type' => 'int')));
     $sshKey = Scalr_SshKey::init()->loadById($this->getParam('sshKeyId'));
     $this->user->getPermissions()->validate($sshKey);
     if ($sshKey->type == Scalr_SshKey::TYPE_GLOBAL) {
         if ($sshKey->platform == SERVER_PLATFORMS::EC2) {
             $aws = $this->getEnvironment()->aws($sshKey->cloudLocation);
             $aws->ec2->keyPair->delete($sshKey->cloudKeyName);
             $sshKey->delete();
             $this->response->success();
         } elseif (PlatformFactory::isOpenstack($sshKey->platform)) {
             $os = $this->getEnvironment()->openstack($sshKey->platform, $sshKey->cloudLocation);
             try {
                 $os->servers->keypairs->delete($sshKey->cloudKeyName);
             } catch (Exception $e) {
             }
             $sshKey->delete();
             $this->response->success();
         } else {
             $sshKey->delete();
         }
     } else {
         //TODO:
     }
     $this->response->success("SSH key successfully removed");
 }
开发者ID:rickb838,项目名称:scalr,代码行数:27,代码来源:Sshkeys.php

示例2: adapter

 /**
  * Gets a new Instance of the adapter
  *
  * @param   string|CloudCredentials|object  $name   The name of the adapter, or CloudCredentials entity, or cloud credentials data
  *
  * @return  ApiEntityAdapter    Returns the instance of cloud credentials adapter
  *
  * @throws  ApiErrorException
  */
 public function adapter($name, array $transform = null)
 {
     if (is_object($name)) {
         //
         $property = $name instanceof $this->entityClass ? static::$entityDescriminator : static::$objectDiscriminator;
         $value = empty($transform) ? $name->{$property} : $transform[$name->{$property}];
         switch (true) {
             case PlatformFactory::isOpenstack($value, true):
                 $value = SERVER_PLATFORMS::OPENSTACK;
                 break;
             case PlatformFactory::isCloudstack($value):
                 $value = SERVER_PLATFORMS::CLOUDSTACK;
                 break;
             case PlatformFactory::isRackspace($value):
                 $value = SERVER_PLATFORMS::RACKSPACE;
                 break;
         }
         if (!isset(static::$inheritanceMap[$value])) {
             throw new ApiErrorException(400, ErrorMessage::ERR_INVALID_VALUE, "Unknown cloud '{$value}'");
         }
         $class = empty(static::$inheritanceMap) ? $value : static::$inheritanceMap[$value];
         $name = empty(static::$inheritedNamespace) ? $class : static::$inheritedNamespace . "\\{$class}";
     }
     return parent::adapter($name);
 }
开发者ID:mheydt,项目名称:scalr,代码行数:34,代码来源:CloudCredentials.php

示例3: __construct

 /**
  * Constructor
  *
  * @param    string     $platform    Platform
  * @param    DBFarmRole $DBFarmRole  optional Farm Role object
  * @param    int        $index       optional Server index within the Farm Role scope
  * @param    string     $role_id     optional Identifier of the Role
  */
 public function __construct($platform, DBFarmRole $DBFarmRole = null, $index = null, $role_id = null)
 {
     $this->platform = $platform;
     $this->dbFarmRole = $DBFarmRole;
     $this->index = $index;
     $this->roleId = $role_id === null ? $this->dbFarmRole->RoleID : $role_id;
     if ($DBFarmRole) {
         $this->envId = $DBFarmRole->GetFarmObject()->EnvID;
     }
     //Refletcion
     $Reflect = new ReflectionClass(DBServer::$platformPropsClasses[$this->platform]);
     foreach ($Reflect->getConstants() as $k => $v) {
         $this->platformProps[] = $v;
     }
     if ($DBFarmRole) {
         if (PlatformFactory::isOpenstack($this->platform)) {
             $this->SetProperties(array(OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION => $DBFarmRole->CloudLocation));
         } elseif (PlatformFactory::isCloudstack($this->platform)) {
             $this->SetProperties(array(CLOUDSTACK_SERVER_PROPERTIES::CLOUD_LOCATION => $DBFarmRole->CloudLocation));
         } else {
             switch ($this->platform) {
                 case SERVER_PLATFORMS::GCE:
                     $this->SetProperties(array(GCE_SERVER_PROPERTIES::CLOUD_LOCATION => $DBFarmRole->CloudLocation));
                     break;
                 case SERVER_PLATFORMS::EC2:
                     $this->SetProperties(array(EC2_SERVER_PROPERTIES::REGION => $DBFarmRole->CloudLocation));
                     break;
             }
         }
     }
     $this->SetProperties(array(SERVER_PROPERTIES::SZR_VESION => '0.20.0'));
 }
开发者ID:scalr,项目名称:scalr,代码行数:40,代码来源:class.ServerCreateInfo.php

示例4: xGetInstanceTypesAction

 /**
  * @param string $platform
  * @param string $cloudLocation
  * @throws Exception
  */
 public function xGetInstanceTypesAction($platform, $cloudLocation = null)
 {
     if (!in_array($platform, $this->getEnvironment()->getEnabledPlatforms())) {
         throw new Exception(sprintf('Platform "%s" is not enabled', $platform));
     }
     $p = PlatformFactory::NewPlatform($platform);
     if (PlatformFactory::isOpenstack($platform) && !$cloudLocation) {
         $locations = $p->getLocations($this->getEnvironment());
         $cloudLocation = @array_pop(@array_keys($locations));
     }
     $data = [];
     foreach ($p->getInstanceTypes($this->getEnvironment(), $cloudLocation, true) as $id => $value) {
         $data[] = array_merge(['id' => (string) $id], $value);
     }
     $this->response->data(array('data' => $data));
 }
开发者ID:rickb838,项目名称:scalr,代码行数:21,代码来源:Platforms.php

示例5: parseInstallScriptArgs

 /**
  * Decode params from href depending on type of OS
  *
  * Possible formats (branch is optioanl):
  * for windows: /{repo}/[{branch}/]install_scalarizr.ps1
  * for linux: /{repo}/{platform}/[{branch}]/install_scalarizr.sh
  *
  * @param   array   $params
  * @param   bool    $isLinux
  * @return  array
  */
 protected function parseInstallScriptArgs($params, $isLinux = true)
 {
     $result = ['repo' => '', 'platform' => '', 'repoUrls' => []];
     $repo = array_shift($params);
     $platform = $isLinux ? array_shift($params) : '';
     array_pop($params);
     // pop script name from the end of href
     $branch = implode('/', $params);
     $repos = $this->getContainer()->config('scalr.scalarizr_update.' . ($branch ? 'devel_repos' : 'repos'));
     if (in_array($repo, array_keys($repos))) {
         if ($branch) {
             // strip illegal chars
             $branch = preg_replace('/[^A-Za-z\\/0-9_.-]/', '', $branch);
             if ($repo !== 'snapshot') {
                 // for snapshot don't cut "." (dot)
                 $branch = str_replace(array(".", '/'), array('', '-'), $branch);
             }
         }
         $repoUrls = $repos[$repo];
         if ($branch) {
             foreach ($repoUrls as $key => &$url) {
                 $url = sprintf($url, $branch);
             }
         }
         if ($isLinux) {
             if (in_array($platform, $this->getContainer()->config('scalr.allowed_clouds'))) {
                 if (PlatformFactory::isOpenstack($platform)) {
                     $platform = SERVER_PLATFORMS::OPENSTACK;
                 } else {
                     if (PlatformFactory::isCloudstack($platform)) {
                         $platform = SERVER_PLATFORMS::CLOUDSTACK;
                     }
                 }
                 $result['platform'] = $platform;
                 $result['repo'] = $repo;
                 $result['repoUrls'] = $repoUrls;
             }
         } else {
             $result['repo'] = $repo;
             $result['repoUrls'] = $repoUrls;
         }
     }
     return $result;
 }
开发者ID:scalr,项目名称:scalr,代码行数:55,代码来源:Public.php

示例6: onCreateBackupResult

 public static function onCreateBackupResult(Scalr_Messaging_Msg $message, DBServer $dbServer)
 {
     $dbFarmRole = $dbServer->GetFarmRoleObject();
     $dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BACKUP_LAST_TS, time(), DBFarmRole::TYPE_LCL);
     $dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BACKUP_IS_RUNNING, 0, DBFarmRole::TYPE_LCL);
     //$dbFarmRole->SetSetting(Scalr_Db_Msr::DATA_BACKUP_SERVER_ID, "");
     if (PlatformFactory::isOpenstack($dbServer->platform)) {
         $provider = 'cf';
     } else {
         switch ($dbServer->platform) {
             case SERVER_PLATFORMS::EC2:
                 $provider = 's3';
                 break;
             case SERVER_PLATFORMS::GCE:
                 $provider = 'gcs';
                 break;
             default:
                 $provider = 'unknown';
                 break;
         }
     }
     $backup = Scalr_Db_Backup::init();
     $backup->service = $message->dbType;
     $backup->platform = $dbServer->platform;
     $backup->provider = $provider;
     $backup->envId = $dbServer->envId;
     $backup->farmId = $dbServer->farmId;
     $backup->cloudLocation = $dbServer->GetCloudLocation();
     $backup->status = Scalr_Db_Backup::STATUS_AVAILABLE;
     $total = 0;
     if (isset($message->backupParts) && is_array($message->backupParts)) {
         foreach ($message->backupParts as $item) {
             if (is_object($item) && $item->size) {
                 $backup->addPart(str_replace(array("s3://", "cf://", "gcs://", "swift://"), array("", "", "", ""), $item->path), $item->size);
                 $total = $total + (int) $item->size;
             } else {
                 $backup->addPart(str_replace(array("s3://", "cf://", "gcs://", "swift://"), array("", "", "", ""), $item), 0);
             }
         }
     }
     $backup->size = $total;
     $backup->save();
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:43,代码来源:Msr.php

示例7: run1

 protected function run1($stage)
 {
     foreach ($this->db->GetAll("SELECT id FROM client_environments") as $row) {
         try {
             $environment = Scalr_Environment::init()->loadById($row['id']);
         } catch (Exception $e) {
             continue;
         }
         foreach ($this->getEnabledPlatforms($environment) as $platform) {
             if ($platform == SERVER_PLATFORMS::EC2 || PlatformFactory::isOpenstack($platform)) {
                 $paramName = $platform == SERVER_PLATFORMS::EC2 ? 'aws.tags' : 'openstack.tags';
                 $nameTagValue = null;
                 $row = $this->db->GetRow("SELECT * FROM `governance` WHERE env_id = ? AND category = ? AND name = ?", array($environment->id, $platform, $paramName));
                 $newValue = ['value' => $this->deprecatedTags, 'allow_additional_tags' => 1];
                 if ($row) {
                     if ($row['enabled'] == 1) {
                         $value = json_decode($row['value'], true);
                         foreach ((array) $value['value'] as $k => $v) {
                             if ($platform == SERVER_PLATFORMS::EC2 && $k == 'Name') {
                                 $nameTagValue = $v;
                                 continue;
                             }
                             if (!isset($newValue['value'][$k])) {
                                 $newValue['value'][$k] = $v;
                             }
                         }
                         $newValue['allow_additional_tags'] = $value['allow_additional_tags'] == 1 ? 1 : 0;
                     }
                 }
                 $newValue = json_encode($newValue);
                 $this->db->Execute("\n                        INSERT INTO `governance`\n                        SET `env_id` = ?,\n                            `category` = ?,\n                            `name` = ?,\n                            `value` = ?,\n                            `enabled` = ?\n                        ON DUPLICATE KEY UPDATE\n                            `value` = ?,\n                            `enabled` = ?\n                    ", array($environment->id, $platform, $paramName, $newValue, 1, $newValue, 1));
                 if ($nameTagValue) {
                     $nameTagValue = json_encode(['value' => $nameTagValue]);
                     $this->db->Execute("\n                            INSERT INTO `governance`\n                            SET `env_id` = ?,\n                                `category` = ?,\n                                `name` = ?,\n                                `value` = ?,\n                                `enabled` = ?\n                            ON DUPLICATE KEY UPDATE\n                                `value` = ?,\n                                `enabled` = ?\n                        ", array($environment->id, $platform, 'aws.instance_name_format', $nameTagValue, 1, $nameTagValue, 1));
                 }
             }
         }
     }
 }
开发者ID:hardiku,项目名称:scalr,代码行数:39,代码来源:Update20150401154148.php

示例8: GetCloudUserData

 public function GetCloudUserData()
 {
     $dbFarmRole = $this->GetFarmRoleObject();
     $baseurl = \Scalr::config('scalr.endpoint.scheme') . "://" . \Scalr::config('scalr.endpoint.host');
     if ($this->isOpenstack() && $this->platform != SERVER_PLATFORMS::VERIZON) {
         $platform = SERVER_PLATFORMS::OPENSTACK;
     } else {
         $platform = $this->platform;
     }
     $retval = array("farmid" => $this->farmId, "role" => implode(",", $dbFarmRole->GetRoleObject()->getBehaviors()), "httpproto" => \Scalr::config('scalr.endpoint.scheme'), "region" => $this->GetCloudLocation(), "hash" => $this->GetFarmObject()->Hash, "realrolename" => $dbFarmRole->GetRoleObject()->name, "szr_key" => $this->GetKey(), "serverid" => $this->serverId, 'p2p_producer_endpoint' => $baseurl . "/messaging", 'queryenv_url' => $baseurl . "/query-env", 'behaviors' => implode(",", $dbFarmRole->GetRoleObject()->getBehaviors()), 'farm_roleid' => $dbFarmRole->ID, 'roleid' => $dbFarmRole->RoleID, 'env_id' => $dbFarmRole->GetFarmObject()->EnvID, 'platform' => $platform, 'server_index' => $this->index, 'cloud_server_id' => $this->GetCloudServerID(), 'cloud_location_zone' => $this->cloudLocationZone, "owner_email" => $dbFarmRole->GetFarmObject()->createdByUserEmail);
     $retval['message_format'] = 'json';
     if (PlatformFactory::isOpenstack($this->platform) && $this->platform != SERVER_PLATFORMS::VERIZON) {
         $retval["cloud_storage_path"] = "swift://";
     } else {
         switch ($this->platform) {
             case SERVER_PLATFORMS::EC2:
                 $retval["s3bucket"] = $dbFarmRole->GetSetting(Entity\FarmRoleSetting::AWS_S3_BUCKET);
                 $retval["cloud_storage_path"] = "s3://" . $dbFarmRole->GetSetting(Entity\FarmRoleSetting::AWS_S3_BUCKET);
                 break;
             case SERVER_PLATFORMS::RACKSPACE:
                 $retval["cloud_storage_path"] = "cf://scalr-{$this->GetFarmObject()->Hash}";
                 break;
             case SERVER_PLATFORMS::GCE:
                 $retval["cloud_storage_path"] = "gcs://";
                 break;
         }
     }
     // Custom settings
     foreach ($dbFarmRole->GetSettingsByFilter("user-data") as $k => $v) {
         $retval[str_replace("user-data", "custom", $k)] = $v;
     }
     return $retval;
 }
开发者ID:mheydt,项目名称:scalr,代码行数:33,代码来源:class.DBServer.php

示例9: xGetCloudServersListAction

 /**
  * @param   string  $platform
  * @param   string  $cloudLocation
  * @throws  Exception
  */
 public function xGetCloudServersListAction($platform, $cloudLocation)
 {
     if (!$this->environment->isPlatformEnabled($platform)) {
         throw new Exception(sprintf('Cloud %s is not enabled for current environment', $platform));
     }
     $results = [];
     $platformObj = PlatformFactory::NewPlatform($platform);
     if ($platform == SERVER_PLATFORMS::GCE) {
         $gce = $platformObj->getClient($this->environment);
         $result = $gce->instances->listInstances($this->environment->keychain(SERVER_PLATFORMS::GCE)->properties[CloudCredentialsProperty::GCE_PROJECT_ID], $cloudLocation, []);
         if (is_array($result->items)) {
             foreach ($result->items as $server) {
                 if ($server->status != 'RUNNING') {
                     continue;
                 }
                 $ips = $platformObj->determineServerIps($gce, $server);
                 $itm = ['id' => $server->name, 'localIp' => $ips['localIp'], 'publicIp' => $ips['remoteIp'], 'zone' => $cloudLocation, 'isImporting' => false, 'isManaged' => false];
                 //Check is instance already importing
                 try {
                     $dbServer = DBServer::LoadByPropertyValue(GCE_SERVER_PROPERTIES::SERVER_NAME, $server->name);
                     if ($dbServer && $dbServer->status != SERVER_STATUS::TERMINATED) {
                         if ($dbServer->status == SERVER_STATUS::IMPORTING) {
                             $itm['isImporting'] = true;
                         } else {
                             $itm['isManaged'] = true;
                         }
                         $itm['serverId'] = $dbServer->serverId;
                     }
                 } catch (Exception $e) {
                 }
                 $results[] = $itm;
             }
         }
     } else {
         if ($platform == SERVER_PLATFORMS::AZURE) {
             // cloudLocation is resourceGroup
             $t = $this->getEnvironment()->azure()->compute->virtualMachine->getList($this->getEnvironment()->keychain(SERVER_PLATFORMS::AZURE)->properties[CloudCredentialsProperty::AZURE_SUBSCRIPTION_ID], $cloudLocation);
             foreach ($t as $server) {
                 $itm = ['id' => $server->name, 'isImporting' => false, 'isManaged' => false];
                 $nicInfo = $server->properties->networkProfile->networkInterfaces[0]->id;
                 // get id and call
                 if (!empty($nicInfo->properties->ipConfigurations)) {
                     foreach ($nicInfo->properties->ipConfigurations as $ipConfig) {
                         $privateIp = $ipConfig->properties->privateIPAddress;
                         if ($ipConfig->properties->publicIPAddress) {
                             $publicIp = $ipConfig->properties->publicIPAddress->properties->ipAddress;
                             if ($publicIp) {
                                 break;
                             }
                         }
                     }
                 }
                 $itm['localIp'] = $privateIp;
                 $itm['publicIp'] = $publicIp;
                 $itm['zone'] = $server->location;
                 $results[] = $itm;
             }
         } elseif (PlatformFactory::isOpenstack($platform)) {
             $client = $this->environment->openstack($platform, $cloudLocation);
             $r = $client->servers->list(true);
             do {
                 foreach ($r as $server) {
                     if ($server->status != 'ACTIVE') {
                         continue;
                     }
                     $ips = $platformObj->determineServerIps($client, $server);
                     $itm = array('id' => $server->id, 'localIp' => $ips['localIp'], 'publicIp' => $ips['remoteIp'], 'zone' => $cloudLocation, 'isImporting' => false, 'isManaged' => false, 'fullInfo' => $server);
                     //Check is instance already importing
                     try {
                         $dbServer = DBServer::LoadByPropertyValue(OPENSTACK_SERVER_PROPERTIES::SERVER_ID, $server->id);
                         if ($dbServer && $dbServer->status != SERVER_STATUS::TERMINATED) {
                             if ($dbServer->status == SERVER_STATUS::IMPORTING) {
                                 $itm['isImporting'] = true;
                             } else {
                                 $itm['isManaged'] = true;
                             }
                             $itm['serverId'] = $dbServer->serverId;
                         }
                     } catch (Exception $e) {
                     }
                     $results[] = $itm;
                 }
             } while (false !== ($r = $r->getNextPage()));
         } elseif (PlatformFactory::isCloudstack($platform)) {
             $client = $this->environment->cloudstack($platform);
             $platformObj = PlatformFactory::NewPlatform($platform);
             $r = $client->instance->describe(array('zoneid' => $cloudLocation));
             if (count($r) > 0) {
                 foreach ($r as $server) {
                     $ips = $platformObj->determineServerIps($client, $server);
                     $itm = array('id' => $server->id, 'localIp' => $ips['localIp'], 'publicIp' => $ips['remoteIp'], 'zone' => $cloudLocation, 'isImporting' => false, 'isManaged' => false);
                     //Check is instance already importing
                     try {
                         $dbServer = DBServer::LoadByPropertyValue(CLOUDSTACK_SERVER_PROPERTIES::SERVER_ID, $server->id);
                         if ($dbServer && $dbServer->status != SERVER_STATUS::TERMINATED) {
//.........这里部分代码省略.........
开发者ID:scalr,项目名称:scalr,代码行数:101,代码来源:Import.php

示例10: xRemoveAction

 /**
  * Remove SSH keys
  *
  * @param JsonData $sshKeyId json array of sshKeyId to remove
  * @throws Scalr_Exception_InsufficientPermissions
  * @throws Scalr_UI_Exception_NotFound
  */
 public function xRemoveAction(JsonData $sshKeyId)
 {
     $errors = [];
     foreach ($sshKeyId as $id) {
         try {
             $sshKey = Scalr_SshKey::init()->loadById($id);
             $this->user->getPermissions()->validate($sshKey);
             if ($sshKey->type == Scalr_SshKey::TYPE_GLOBAL) {
                 if ($sshKey->platform == SERVER_PLATFORMS::EC2) {
                     $aws = $this->getEnvironment()->aws($sshKey->cloudLocation);
                     $aws->ec2->keyPair->delete($sshKey->cloudKeyName);
                     $sshKey->delete();
                 } elseif (PlatformFactory::isOpenstack($sshKey->platform)) {
                     $os = $this->getEnvironment()->openstack($sshKey->platform, $sshKey->cloudLocation);
                     $os->servers->keypairs->delete($sshKey->cloudKeyName);
                     $sshKey->delete();
                 } else {
                     $sshKey->delete();
                 }
             } else {
                 //TODO:
             }
         } catch (Exception $e) {
             $errors[] = $e->getMessage();
         }
     }
     if (count($errors)) {
         $this->response->warning("SSH key(s) successfully removed, but some errors occurred:\n" . implode("\n", $errors));
     } else {
         $this->response->success('SSH key(s) successfully removed');
     }
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:39,代码来源:Sshkeys.php

示例11: getContext

 public function getContext()
 {
     $data = array();
     if ($this->user) {
         $data['user'] = array('userId' => $this->user->getId(), 'clientId' => $this->user->getAccountId(), 'userName' => $this->user->getEmail(), 'gravatarHash' => $this->user->getGravatarHash(), 'envId' => $this->getEnvironment() ? $this->getEnvironmentId() : 0, 'envName' => $this->getEnvironment() ? $this->getEnvironment()->name : '', 'envVars' => $this->getEnvironment() ? $this->getEnvironment()->getPlatformConfigValue(Scalr_Environment::SETTING_UI_VARS) : '', 'type' => $this->user->getType());
         $envVars = json_decode($data['user']['envVars'], true);
         $betaMode = $envVars && $envVars['beta'] == 1;
         if (!$this->user->isAdmin()) {
             $data['farms'] = $this->db->getAll('SELECT id, name FROM farms WHERE env_id = ? ORDER BY name', array($this->getEnvironmentId()));
             if ($this->user->getAccountId() != 0) {
                 $data['flags'] = $this->user->getAccount()->getFeaturesList();
                 $data['user']['userIsTrial'] = $this->user->getAccount()->getSetting(Scalr_Account::SETTING_IS_TRIAL) == '1' ? true : false;
             } else {
                 $data['flags'] = array();
             }
             $data['flags']['billingExists'] = \Scalr::config('scalr.billing.enabled');
             $data['flags']['featureUsersPermissions'] = $this->user->getAccount()->isFeatureEnabled(Scalr_Limits::FEATURE_USERS_PERMISSIONS);
             $data['flags']['wikiUrl'] = \Scalr::config('scalr.ui.wiki_url');
             $data['flags']['supportUrl'] = \Scalr::config('scalr.ui.support_url');
             if ($data['flags']['supportUrl'] == '/core/support') {
                 $data['flags']['supportUrl'] .= '?X-Requested-Token=' . Scalr_Session::getInstance()->getToken();
             }
             $data['acl'] = $this->request->getAclRoles()->getAllowedArray(true);
             if ($this->user->isAccountOwner()) {
                 if (!$this->user->getAccount()->getSetting(Scalr_Account::SETTING_DATE_ENV_CONFIGURED)) {
                     if (count($this->environment->getEnabledPlatforms()) == 0) {
                         $data['flags']['needEnvConfig'] = Scalr_Environment::init()->loadDefault($this->user->getAccountId())->id;
                     }
                 }
             }
             $data['environments'] = $this->user->getEnvironments();
             if ($this->getEnvironment() && $this->user->isTeamOwner()) {
                 $data['user']['isTeamOwner'] = true;
             }
         }
         $data['platforms'] = array();
         $allowedClouds = (array) \Scalr::config('scalr.allowed_clouds');
         foreach (SERVER_PLATFORMS::getList() as $platform => $platformName) {
             if (!in_array($platform, $allowedClouds) || $platform == SERVER_PLATFORMS::UCLOUD && !$this->request->getHeaderVar('Interface-Beta')) {
                 continue;
             }
             $data['platforms'][$platform] = array('public' => PlatformFactory::isPublic($platform), 'enabled' => $this->user->isAdmin() ? true : !!$this->environment->isPlatformEnabled($platform), 'name' => $platformName);
             if (!$this->user->isAdmin()) {
                 if ($platform == SERVER_PLATFORMS::EC2 && $this->environment->status == Scalr_Environment::STATUS_INACTIVE && $this->environment->getPlatformConfigValue('system.auto-disable-reason')) {
                     $data['platforms'][$platform]['config'] = array('autoDisabled' => true);
                 }
                 if (PlatformFactory::isOpenstack($platform) && $data['platforms'][$platform]['enabled']) {
                     $data['platforms'][$platform]['config'] = array(OpenstackPlatformModule::EXT_SECURITYGROUPS_ENABLED => PlatformFactory::NewPlatform($platform)->getConfigVariable(OpenstackPlatformModule::EXT_SECURITYGROUPS_ENABLED, $this->getEnvironment(), false), OpenstackPlatformModule::EXT_LBAAS_ENABLED => PlatformFactory::NewPlatform($platform)->getConfigVariable(OpenstackPlatformModule::EXT_LBAAS_ENABLED, $this->getEnvironment(), false), OpenstackPlatformModule::EXT_FLOATING_IPS_ENABLED => PlatformFactory::NewPlatform($platform)->getConfigVariable(OpenstackPlatformModule::EXT_FLOATING_IPS_ENABLED, $this->getEnvironment(), false), OpenstackPlatformModule::EXT_CINDER_ENABLED => PlatformFactory::NewPlatform($platform)->getConfigVariable(OpenstackPlatformModule::EXT_CINDER_ENABLED, $this->getEnvironment(), false), OpenstackPlatformModule::EXT_SWIFT_ENABLED => PlatformFactory::NewPlatform($platform)->getConfigVariable(OpenstackPlatformModule::EXT_SWIFT_ENABLED, $this->getEnvironment(), false));
                 }
             }
         }
         $data['flags']['uiStorageTime'] = $this->user->getSetting(Scalr_Account_User::SETTING_UI_STORAGE_TIME);
         $data['flags']['uiStorage'] = $this->user->getVar(Scalr_Account_User::VAR_UI_STORAGE);
         $data['flags']['allowManageAnalytics'] = (bool) Scalr::isAllowedAnalyticsOnHostedScalrAccount($this->environment->clientId);
     }
     if ($this->user) {
         $data['tags'] = Tag::getAll($this->user->getAccountId());
     }
     $data['flags']['authMode'] = $this->getContainer()->config->get('scalr.auth_mode');
     $data['flags']['specialToken'] = Scalr_Session::getInstance()->getToken();
     $data['flags']['hostedScalr'] = (bool) Scalr::isHostedScalr();
     $data['flags']['analyticsEnabled'] = $this->getContainer()->analytics->enabled;
     return $data;
 }
开发者ID:rickb838,项目名称:scalr,代码行数:64,代码来源:Guest.php

示例12: getUrl

 /**
  * Gets a normalized url for an each platform
  *
  * @param    string $platform Cloud platform
  * @return   string Returns url
  */
 public function getUrl($platform)
 {
     if (!isset($this->aUrl[$platform])) {
         if ($platform == \SERVER_PLATFORMS::EC2) {
             $value = '';
         } else {
             if (PlatformFactory::isOpenstack($platform)) {
                 $value = CloudLocation::normalizeUrl($this->env->getPlatformConfigValue($platform . '.' . OpenstackPlatformModule::KEYSTONE_URL));
             } else {
                 if (PlatformFactory::isCloudstack($platform)) {
                     $value = CloudLocation::normalizeUrl($this->env->getPlatformConfigValue($platform . '.' . CloudstackPlatformModule::API_URL));
                 } else {
                     if ($platform == \SERVER_PLATFORMS::GCE) {
                         $value = '';
                     }
                 }
             }
         }
         $this->aUrl[$platform] = $value;
     }
     return $this->aUrl[$platform];
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:28,代码来源:AnalyticsDemo.php

示例13: xGetPlatformInstanceTypesAction

 /**
  * xGetPlatformInstanceTypesAction
  *
  * @param    string        $platform      The name of the cloud platform
  * @param    string        $cloudLocation The cloud location
  * @param    string        $envId         optional The identifier of the environment
  * @param    string        $effectiveDate optional The date on which prices should be applied YYYY-MM-DD
  * @throws   \Exception
  */
 public function xGetPlatformInstanceTypesAction($platform, $cloudLocation, $envId = null, $effectiveDate = null)
 {
     list($curDate, $effectiveDate) = $this->handleEffectiveDate($effectiveDate);
     $pm = PlatformFactory::NewPlatform($platform);
     $env = null;
     $url = '';
     try {
         if (!empty($envId)) {
             $env = Scalr_Environment::init()->loadById($envId);
             if (PlatformFactory::isOpenstack($platform)) {
                 $key = Entity\CloudCredentialsProperty::OPENSTACK_KEYSTONE_URL;
             } else {
                 if (PlatformFactory::isCloudstack($platform)) {
                     $key = Entity\CloudCredentialsProperty::CLOUDSTACK_API_URL;
                 } else {
                     throw new Exception('This action is not yet supported for the specified cloud platform.');
                 }
             }
             if (empty($url)) {
                 $url = $env->keychain($platform)->properties[$key];
             }
         } else {
             if ($platform == SERVER_PLATFORMS::EC2 || $platform == SERVER_PLATFORMS::GCE) {
                 $gcenvid = $this->getEnvIdByPlatform($platform);
                 $env = Scalr_Environment::init()->loadById($gcenvid);
             }
         }
     } catch (Exception $e) {
         if (stristr($e->getMessage(), 'not found')) {
             //Tries to find url from the cloud_locations table
             if (empty($url) && (PlatformFactory::isOpenstack($platform) || PlatformFactory::isCloudstack($platform))) {
                 $clEntity = CloudLocation::findOne([['platform' => $platform], ['cloudLocation' => $cloudLocation]], null, ['updated' => false]);
                 if ($clEntity instanceof CloudLocation) {
                     $url = $clEntity->url;
                 }
             }
         } else {
             throw $e;
         }
     }
     $result = $this->getTypesWithPrices($cloudLocation, $url, $pm, $platform, $effectiveDate, $env);
     $this->response->data(['data' => $result]);
 }
开发者ID:scalr,项目名称:scalr,代码行数:52,代码来源:Pricing.php

示例14: getUrl

 /**
  * Gets a normalized url for an each platform
  *
  * @param    string $platform Cloud platform
  * @return   string Returns url
  */
 public function getUrl($platform)
 {
     if (!isset($this->aUrl[$platform])) {
         if ($platform == \SERVER_PLATFORMS::EC2 || $platform == \SERVER_PLATFORMS::GCE || $platform == \SERVER_PLATFORMS::AZURE) {
             $value = '';
         } else {
             if (PlatformFactory::isOpenstack($platform)) {
                 $value = CloudLocation::normalizeUrl($this->env->keychain($platform)->properties[CloudCredentialsProperty::OPENSTACK_KEYSTONE_URL]);
             } else {
                 if (PlatformFactory::isCloudstack($platform)) {
                     $value = CloudLocation::normalizeUrl($this->env->keychain($platform)->properties[CloudCredentialsProperty::CLOUDSTACK_API_URL]);
                 }
             }
         }
         $this->aUrl[$platform] = $value;
     }
     return $this->aUrl[$platform];
 }
开发者ID:scalr,项目名称:scalr,代码行数:24,代码来源:AnalyticsDemo.php

示例15: isOpenstack

 public function isOpenstack()
 {
     return PlatformFactory::isOpenstack($this->Platform);
 }
开发者ID:rickb838,项目名称:scalr,代码行数:4,代码来源:class.DBFarmRole.php


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