本文整理汇总了PHP中Scalr\Modules\PlatformFactory::getCloudstackBasedPlatforms方法的典型用法代码示例。如果您正苦于以下问题:PHP PlatformFactory::getCloudstackBasedPlatforms方法的具体用法?PHP PlatformFactory::getCloudstackBasedPlatforms怎么用?PHP PlatformFactory::getCloudstackBasedPlatforms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalr\Modules\PlatformFactory
的用法示例。
在下文中一共展示了PlatformFactory::getCloudstackBasedPlatforms方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run4
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]);
}
}
示例2: _cloudCredentialsType
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()]]];
}
}
示例3: getDisabledResources
/**
* 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;
}
示例4: _cloudCredentialsType
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]];
}
}
示例5: getSupportedClouds
/**
* 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())));
}
示例6: defaultAction
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']);
}