/**
  * Constructor
  *
  * @param    string     $platform   optional  the name of the platform
  */
 public function __construct($platform = null)
 {
     parent::__construct();
     $this->platform = $platform;
 }
Example #2
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::ResumeServer()
  */
 public function ResumeServer(DBServer $DBServer)
 {
     $gce = $this->getClient($DBServer->GetEnvironmentObject());
     //Check status and allow to resume only if instance is really stopped
     $status = $this->GetServerRealStatus($DBServer);
     if (!$status->isSuspended()) {
         throw new Exception(sprintf("The instance '%s' is not in a state from which it can be started. Please try again in a couple minutes.", $DBServer->serverId));
     }
     try {
         $gce->instances->start($DBServer->GetEnvironmentObject()->keychain(SERVER_PLATFORMS::GCE)->properties[Entity\CloudCredentialsProperty::GCE_PROJECT_ID], $DBServer->GetCloudLocation(), $DBServer->GetProperty(\GCE_SERVER_PROPERTIES::SERVER_NAME));
     } catch (Exception $e) {
         if (stristr($e->getMessage(), "not found")) {
             throw new InstanceNotFoundException($e->getMessage(), $e->getCode(), $e);
         }
         throw $e;
     }
     parent::ResumeServer($DBServer);
     return true;
 }
Example #3
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::ResumeServer()
  */
 public function ResumeServer(DBServer $DBServer)
 {
     $env = $DBServer->GetEnvironmentObject();
     $azure = $env->azure();
     try {
         $res = $azure->compute->virtualMachine->start($env->keychain(SERVER_PLATFORMS::AZURE)->properties[CloudCredentialsProperty::AZURE_SUBSCRIPTION_ID], $DBServer->GetProperty(\AZURE_SERVER_PROPERTIES::RESOURCE_GROUP), $DBServer->GetProperty(\AZURE_SERVER_PROPERTIES::SERVER_NAME));
         if ($res) {
             parent::ResumeServer($DBServer);
             return true;
         } else {
             //TODO: Throw Exception
         }
     } catch (NotFoundException $e) {
         throw new InstanceNotFoundException($e->getMessage(), $e->getCode(), $e);
     }
 }
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::ResumeServer()
  */
 public function ResumeServer(DBServer $DBServer)
 {
     $gce = $this->getClient($DBServer->GetEnvironmentObject());
     try {
         $gce->instances->start($DBServer->GetEnvironmentObject()->getPlatformConfigValue(self::PROJECT_ID), $DBServer->GetCloudLocation(), $DBServer->GetProperty(\GCE_SERVER_PROPERTIES::SERVER_NAME));
     } catch (Exception $e) {
         if (stristr($e->getMessage(), "not found")) {
             throw new InstanceNotFoundException($e->getMessage(), $e->getCode(), $e);
         }
         throw $e;
     }
     parent::ResumeServer($DBServer);
     return true;
 }
Example #5
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::ResumeServer()
  */
 public function ResumeServer(DBServer $DBServer)
 {
     $gce = $this->getClient($DBServer->GetEnvironmentObject());
     try {
         $gce->instances->start($DBServer->GetEnvironmentObject()->cloudCredentials(SERVER_PLATFORMS::GCE)->properties[Entity\CloudCredentialsProperty::GCE_PROJECT_ID], $DBServer->GetCloudLocation(), $DBServer->GetProperty(\GCE_SERVER_PROPERTIES::SERVER_NAME));
     } catch (Exception $e) {
         if (stristr($e->getMessage(), "not found")) {
             throw new InstanceNotFoundException($e->getMessage(), $e->getCode(), $e);
         }
         throw $e;
     }
     parent::ResumeServer($DBServer);
     return true;
 }