Add Suspend and Unsuspend functions to Container class

feature/node-rewrite
Sven Slootweg 13 years ago
parent 01019116ca
commit f8a84a3403

@ -443,6 +443,48 @@ class Container extends CPHPDatabaseRecordClass
}
}
public function Suspend()
{
if($this->sStatus != CVM_STATUS_SUSPENDED)
{
try
{
$this->Stop();
$this->uStatus = CVM_STATUS_SUSPENDED;
$this->InsertIntoDatabase();
}
catch (ContainerStopException $e)
{
throw new ContainerSuspendException("Suspension failed as the container could not be stopped.", 1, $this->sInternalId, $e);
}
}
else
{
throw new ContainerSuspendException("The container is already suspended.", 1, $this->sInternalId);
}
}
public function Unsuspend()
{
if($this->sStatus == CVM_STATUS_SUSPENDED)
{
try
{
$this->Start();
$this->uStatus = CVM_STATUS_STARTED;
$this->InsertIntoDatabase();
}
catch (ContainerStopException $e)
{
throw new ContainerUnsuspendException("Unsuspension failed as the container could not be started.", 1, $this->sInternalId, $e);
}
}
else
{
throw new ContainerUnsuspendException("The container is not suspended.", 1, $this->sInternalId);
}
}
public function AddIp($ip)
{
$command = shrink_command("vzctl set {$this->sInternalId}

@ -41,6 +41,8 @@ class ContainerCreateException extends ContainerException {}
class ContainerConfigureException extends ContainerException {}
class ContainerStartException extends ContainerException {}
class ContainerStopException extends ContainerException {}
class ContainerSuspendException extends ContainerException {}
class ContainerUnsuspendException extends ContainerException {}
class ContainerDestroyException extends ContainerException {}
class ContainerReinstallException extends ContainerException {}
class ContainerDeployException extends ContainerException {}

Loading…
Cancel
Save