Scalr\Modules\Platforms\RackspaceNgUs\RackspaceNgUsPlatformModule::getLocations PHP Method

getLocations() public method

See also: Scalr\Modules\Platforms\Openstack\OpenstackPlatformModule::getLocations()
public getLocations ( Scalr_Environment $environment = null )
$environment Scalr_Environment
    public function getLocations(\Scalr_Environment $environment = null)
    {
        if (!$environment) {
            return ['ORD' => 'Rackspace US / ORD', 'DFW' => 'Rackspace US / DFW', 'IAD' => 'Rackspace US / IAD', 'SYD' => 'Rackspace US / SYD'];
        } else {
            $retval = [];
            try {
                $client = $environment->openstack($this->platform, "fakeRegion");
                $zones = $client->listZones();
                $endpoints = $client->getConfig()->getAuthToken()->getRegionEndpoints();
                foreach ($zones as $zone) {
                    if (isset($endpoints['compute'][$zone->name])) {
                        $retval[$zone->name] = "Rackspace US / {$zone->name}";
                    }
                }
            } catch (\Exception $e) {
            }
            return $retval;
        }
    }