cleanupServerObjects() public static method

public static cleanupServerObjects ( DBServer $dbServer )
$dbServer DBServer
Example #1
0
 /**
  * Removes server from database
  * @return void
  */
 public function Remove()
 {
     try {
         // 1. Clean up cloud objects
         if ($this->platform == SERVER_PLATFORMS::AZURE) {
             AzureHelper::cleanupServerObjects($this);
         }
         // 2. Cleanup scalr db
         $this->Db->BeginTrans();
         // We need to perpetuate server_properties records for removed servers
         $this->Db->Execute("DELETE FROM servers WHERE server_id=?", array($this->serverId));
         $this->Db->Execute("DELETE FROM messages WHERE server_id=?", array($this->serverId));
         $this->Db->Execute("\n                UPDATE `dm_deployment_tasks` SET status=? WHERE server_id=?\n            ", array(Scalr_Dm_DeploymentTask::STATUS_ARCHIVED, $this->serverId));
         $importantProperties = \SERVER_PROPERTIES::getImportantList();
         $properties = array_diff(array_keys($this->GetAllProperties()), $importantProperties);
         if (!empty($properties)) {
             $and = " AND (";
             foreach ($properties as $name) {
                 $and .= "name=" . $this->Db->qstr($name) . " OR ";
             }
             $and = substr($and, 0, -3) . ")";
             $this->Db->Execute("DELETE FROM server_properties WHERE server_id=?" . $and, [$this->serverId]);
         }
         $this->Db->CommitTrans();
     } catch (Exception $e) {
         $this->Db->RollbackTrans();
         throw $e;
     }
 }