Add Vps::Terminate function

feature/node-rewrite
Sven Slootweg 12 years ago
parent a48c6fea70
commit 33fb4ef499

@ -43,6 +43,9 @@ class Vps extends CPHPDatabaseRecordClass
'OutgoingTrafficLimit' => "OutgoingTrafficLimit", 'OutgoingTrafficLimit' => "OutgoingTrafficLimit",
'TotalTrafficLimit' => "TotalTrafficLimit" 'TotalTrafficLimit' => "TotalTrafficLimit"
), ),
'timestamp' => array(
"TerminationDate" => "TerminationDate"
),
'node' => array( 'node' => array(
'Node' => "NodeId" '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) public function AddIp($ip)
{ {
$command = array("sudo", "vzctl", "set", $this->sInternalId, "--ipadd", $ip, "--save"); $command = array("sudo", "vzctl", "set", $this->sInternalId, "--ipadd", $ip, "--save");

Loading…
Cancel
Save