diff --git a/frontend/classes/vps.php b/frontend/classes/vps.php index d842255..b0955b3 100644 --- a/frontend/classes/vps.php +++ b/frontend/classes/vps.php @@ -43,6 +43,9 @@ class Vps extends CPHPDatabaseRecordClass 'OutgoingTrafficLimit' => "OutgoingTrafficLimit", 'TotalTrafficLimit' => "TotalTrafficLimit" ), + 'timestamp' => array( + "TerminationDate" => "TerminationDate" + ), 'node' => array( 'Node' => "NodeId" ), @@ -575,6 +578,28 @@ class Vps extends CPHPDatabaseRecordClass } } + public function Terminate() + { + if($this->sStatus != CVM_STATUS_TERMINATED) + { + try + { + $this->Stop(); + $this->uStatus = CVM_STATUS_TERMINATED; + $this->uTerminationDate = time(); + $this->InsertIntoDatabase(); + } + catch (VpsStopException $e) + { + throw new VpsTerminateException("Termination failed as the VPS could not be stopped.", 1, $this->sInternalId, $e); + } + } + else + { + throw new VpsTerminateException("The VPS is already terminated.", 1, $this->sInternalId); + } + } + public function AddIp($ip) { $command = array("sudo", "vzctl", "set", $this->sInternalId, "--ipadd", $ip, "--save");