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