public openstack ( |
||
$platform | The platform name or Openstack config | |
$region | string | optional The region |
return | Returns openstack instance from DI container |
public function openstack($platform, $region = null)
{
$arguments = func_get_args();
for ($i = 0; $i < 2; ++$i) {
if (!isset($arguments[$i])) {
$arguments[$i] = null;
}
}
//Adds Scalr_Environment as third parameter
$arguments[2] = $this;
//Retrieves an instance from the DI container
return $this->__call('openstack', $arguments);
}
/** * {@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; }