Scalr\Modules\Platforms\GoogleCE\GoogleCEPlatformModule::GetServerIPAddresses PHP Метод

GetServerIPAddresses() публичный Метод

См. также: Scalr\Modules\PlatformModuleInterface::GetServerIPAddresses()
public GetServerIPAddresses ( DBServer $DBServer )
$DBServer DBServer
    public function GetServerIPAddresses(DBServer $DBServer)
    {
        $serverId = $DBServer->GetCloudServerID();
        $cacheKey = sprintf('%s:%s', $DBServer->envId, $DBServer->cloudLocation);
        if (!isset($this->instancesListCache[$cacheKey][$serverId])) {
            $gce = $this->getClient($DBServer->GetEnvironmentObject());
            $result = $gce->instances->get($DBServer->GetEnvironmentObject()->keychain(SERVER_PLATFORMS::GCE)->properties[Entity\CloudCredentialsProperty::GCE_PROJECT_ID], $DBServer->GetCloudLocation(), $serverId);
            $network = $result->getNetworkInterfaces();
            $this->instancesListCache[$cacheKey][$serverId] = ['localIp' => $network[0]->networkIP, 'remoteIp' => $network[0]->accessConfigs[0]->natIP, 'status' => $result->status, 'type' => $this->getObjectName($result->machineType), '_timestamp' => time()];
        }
        return array('localIp' => $this->instancesListCache[$cacheKey][$serverId]['localIp'], 'remoteIp' => $this->instancesListCache[$cacheKey][$serverId]['remoteIp']);
    }