Destroy and Reinstall functions for Container class

feature/node-rewrite
Sven Slootweg 12 years ago
parent 09f97c6e28
commit c95ccad6df

@ -367,6 +367,39 @@ class Container extends CPHPDatabaseRecordClass
}
}
public function Destroy()
{
$this->Stop();
$command = "vzctl destroy {$this->sInternalId}";
$result = $this->sNode->ssh->RunCommand($command, false);
if($result->returncode == 0)
{
return true;
}
else
{
throw new ContainerDestroyException("Destroying container failed: {$result->stderr}", $result->returncode, $this->sInternalId);
}
}
public function Reinstall()
{
try
{
$this->Destroy();
$this->Deploy();
}
catch (ContainerDestroyException $e)
{
throw new ContainerReinstallException("Reinstalling container failed during destroying: " . $e->getMessage(), $e->getCode(), $this->sInternalId);
}
catch (ContainerDeployException $e)
{
throw new ContainerReinstallException("Reinstalling container failed during deploying: " . $e->getMessage(), $e->getCode(), $this->sInternalId);
}
}
public function Start()
{
$command = "vzctl start {$this->sInternalId}";

@ -41,6 +41,9 @@ class ContainerCreateException extends ContainerException {}
class ContainerConfigureException extends ContainerException {}
class ContainerStartException extends ContainerException {}
class ContainerStopException extends ContainerException {}
class ContainerDestroyException extends ContainerException {}
class ContainerReinstallException extends ContainerException {}
class ContainerDeployException extends ContainerException {}
class ContainerIpAddException extends ContainerException {}
class ContainerIpRemoveException extends ContainerException {}
class ContainerTrafficRetrieveException extends ContainerException {}

Loading…
Cancel
Save