Scalr\Modules\Platforms\GoogleCE\GoogleCEPlatformModule::getImageInfo PHP Method

getImageInfo() public method

See also: PlatformModuleInterface::getImageInfo()
public getImageInfo ( Scalr_Environment $environment, $cloudLocation, $imageId )
$environment Scalr_Environment
    public function getImageInfo(\Scalr_Environment $environment, $cloudLocation, $imageId)
    {
        /* @var $client \Google_Service_Compute */
        $client = $this->getClient($environment);
        // for global images we use another projectId
        $ind = strpos($imageId, '/global/');
        if ($ind !== false) {
            $projectId = substr($imageId, 0, $ind);
            $id = str_replace("{$projectId}/global/images/", '', $imageId);
        } else {
            $ind = strpos($imageId, '/images/');
            $projectId = $ind !== false ? substr($imageId, 0, $ind) : $environment->keychain(SERVER_PLATFORMS::GCE)->properties[Entity\CloudCredentialsProperty::GCE_PROJECT_ID];
            $id = str_replace("{$projectId}/images/", '', $imageId);
        }
        $snap = $client->images->get($projectId, $id);
        return ["name" => $snap->name, "size" => $snap->diskSizeGb, "architecture" => "x86_64"];
    }