From 96b2f27dee232bdf2c30a4db3643aac690648f06 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 29 Apr 2012 16:19:18 +0200 Subject: [PATCH] IP adding/removing stuff --- frontend/classes/class.container.php | 19 +++++++++++++++++++ frontend/includes/include.exceptions.php | 1 + frontend/test.php | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/frontend/classes/class.container.php b/frontend/classes/class.container.php index 2749328..3f4dcd2 100644 --- a/frontend/classes/class.container.php +++ b/frontend/classes/class.container.php @@ -225,6 +225,25 @@ class Container extends CPHPDatabaseRecordClass } } + public function RemoveIp($ip) + { + $command = shrink_command("vzctl set {$this->sInternalId} + --ipdel {$ip} + --save + "); + + $result = $this->sNode->ssh->RunCommand($command, false); + + if($result->returncode == 0) + { + return true; + } + else + { + throw new ContainerIpRemoveException($result->stderr, $result->returncode, $this->sInternalId); + } + } + public function EnableTunTap() { // TODO: Finish EnableTunTap function, check whether tun module is available on host diff --git a/frontend/includes/include.exceptions.php b/frontend/includes/include.exceptions.php index cd8fc8b..225fad7 100644 --- a/frontend/includes/include.exceptions.php +++ b/frontend/includes/include.exceptions.php @@ -42,4 +42,5 @@ class ContainerConfigureException extends ContainerException {} class ContainerStartException extends ContainerException {} class ContainerStopException extends ContainerException {} class ContainerIpAddException extends ContainerException {} +class ContainerIpRemoveException extends ContainerException {} ?> diff --git a/frontend/test.php b/frontend/test.php index b7188c7..f6c247e 100644 --- a/frontend/test.php +++ b/frontend/test.php @@ -23,6 +23,14 @@ elseif($_GET['action'] == "bw") $values = split_whitespace($lines[0]); pretty_dump($values); } +elseif($_GET['action'] == "ip") +{ + $sContainer->AddIp($_GET['ip']); +} +else +{ + echo("idk"); +} echo("Done!"); ?>