Inheritance: implements Scalr\Modules\Platforms\StatusAdapterInterface
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::GetServerRealStatus()
  */
 public function GetServerRealStatus(DBServer $DBServer)
 {
     $cloudLocation = $DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION);
     $environment = $DBServer->GetEnvironmentObject();
     $iid = $DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::SERVER_ID);
     if (!$iid) {
         $status = 'not-found';
     } elseif (!$this->instancesListCache[$environment->id][$cloudLocation][$iid]) {
         $osClient = $this->getOsClient($environment, $cloudLocation);
         try {
             $result = $osClient->servers->getServerDetails($DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::SERVER_ID));
             $status = $result->status;
         } catch (\Exception $e) {
             if (stristr($e->getMessage(), "404") || stristr($e->getMessage(), "could not be found")) {
                 $status = 'not-found';
             } else {
                 throw $e;
             }
         }
     } else {
         $status = $this->instancesListCache[$environment->id][$cloudLocation][$DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::SERVER_ID)];
     }
     return StatusAdapter::load($status);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Modules\PlatformModuleInterface::GetServerRealStatus()
  */
 public function GetServerRealStatus(DBServer $DBServer)
 {
     $cloudLocation = $DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::CLOUD_LOCATION);
     $iid = $DBServer->GetProperty(\OPENSTACK_SERVER_PROPERTIES::SERVER_ID);
     if (!$iid) {
         $status = 'not-found';
     } elseif (!$this->instancesListCache[$DBServer->envId][$cloudLocation][$iid]) {
         $osClient = $this->getOsClient($DBServer->GetEnvironmentObject(), $cloudLocation);
         try {
             $result = $osClient->servers->getServerDetails($iid);
             $status = $result->status;
         } catch (NotFoundException $e) {
             $status = 'not-found';
         }
     } else {
         $status = $this->instancesListCache[$DBServer->envId][$cloudLocation][$iid];
     }
     return StatusAdapter::load($status);
 }