Scalr\Modules\Platforms\Openstack\OpenstackPlatformModule::GetServersList PHP Method

GetServersList() public method

public GetServersList ( Scalr_Environment $environment, $cloudLocation, $skipCache = false )
$environment Scalr_Environment
    public function GetServersList(\Scalr_Environment $environment, $cloudLocation, $skipCache = false)
    {
        if (!isset($this->instancesListCache[$environment->id])) {
            $this->instancesListCache[$environment->id] = array();
        }
        if (!isset($this->instancesListCache[$environment->id][$cloudLocation])) {
            $this->instancesListCache[$environment->id][$cloudLocation] = array();
        }
        if (empty($this->instancesListCache[$environment->id][$cloudLocation]) || $skipCache) {
            $client = $this->getOsClient($environment, $cloudLocation);
            $result = $client->servers->list();
            do {
                foreach ($result as $server) {
                    $this->instancesListCache[$environment->id][$cloudLocation][$server->id] = $server->status;
                    if (empty($this->instancesDetailsCache[$server->id])) {
                        $this->instancesDetailsCache[$server->id] = new \stdClass();
                        $this->instancesDetailsCache[$server->id]->addresses = $server->addresses;
                    }
                }
            } while (false !== ($result = $result->getNextPage()));
        }
        return $this->instancesListCache[$environment->id][$cloudLocation];
    }