public function OnHostDown(\HostDownEvent $event)
 {
     if (!$event->DBServer->isOpenstack()) {
         return;
     }
     OpenstackHelper::removeIpFromServer($event->DBServer);
 }
Beispiel #2
0
 public function xServerCancelOperationAction()
 {
     if (!$this->request->isAllowed(Acl::RESOURCE_FARMS_SERVERS) && !$this->request->isAllowed(Acl::RESOURCE_FARMS_ROLES, Acl::PERM_FARMS_ROLES_CREATE)) {
         throw new Scalr_Exception_InsufficientPermissions();
     }
     $this->request->defineParams(array('serverId'));
     $dbServer = DBServer::LoadByID($this->getParam('serverId'));
     $this->user->getPermissions()->validate($dbServer);
     $bt_id = $this->db->GetOne("\n            SELECT id FROM bundle_tasks WHERE server_id=? AND prototype_role_id='0' AND status NOT IN (?,?,?) LIMIT 1\n        ", array($dbServer->serverId, SERVER_SNAPSHOT_CREATION_STATUS::FAILED, SERVER_SNAPSHOT_CREATION_STATUS::SUCCESS, SERVER_SNAPSHOT_CREATION_STATUS::CANCELLED));
     if ($bt_id) {
         $BundleTask = BundleTask::LoadById($bt_id);
         $BundleTask->SnapshotCreationFailed("Server was terminated before snapshot was created.");
     }
     if ($dbServer->status == SERVER_STATUS::IMPORTING) {
         $dbServer->Remove();
     } else {
         $dbServer->terminate(DBServer::TERMINATE_REASON_SNAPSHOT_CANCELLATION, true, $this->user);
         if (PlatformFactory::isOpenstack($dbServer->platform)) {
             OpenstackHelper::removeIpFromServer($dbServer);
         }
     }
     $this->response->success("Server was successfully canceled and removed from database");
 }