Scalr\Modules\Platforms\Openstack\OpenstackPlatformModule::CheckServerSnapshotStatus PHP Метод

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

См. также: Scalr\Modules\PlatformModuleInterface::CheckServerSnapshotStatus()
public CheckServerSnapshotStatus ( BundleTask $BundleTask )
$BundleTask BundleTask
    public function CheckServerSnapshotStatus(BundleTask $BundleTask)
    {
        try {
            $DBServer = DBServer::LoadByID($BundleTask->serverId);
            $client = $this->getOsClient($DBServer->GetEnvironmentObject(), $DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION));
            $info = $client->servers->getImage($BundleTask->snapshotId);
            switch ($info->status) {
                case 'SAVING':
                    $BundleTask->Log(sprintf(_("Creating new image. Progress: %s%%"), $info->progress));
                    break;
                case "DELETED":
                    $BundleTask->SnapshotCreationFailed("Image was removed");
                    break;
                case "ERROR":
                    $BundleTask->SnapshotCreationFailed("Image is in ERROR state");
                    break;
                case "ACTIVE":
                    $BundleTask->SnapshotCreationComplete($BundleTask->snapshotId, array());
                    break;
                default:
                    trigger_error(sprintf("Unexpected server snapshot status %s", serialize($info)), E_USER_WARNING);
                    break;
            }
        } catch (\Exception $e) {
            $BundleTask->SnapshotCreationFailed($e->getMessage());
        }
    }