From fc02cb42069fef78c4381670767b2589aabbf450 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Fri, 11 May 2012 00:06:29 +0200 Subject: [PATCH] Add Container::SetOptions function --- frontend/classes/class.container.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/frontend/classes/class.container.php b/frontend/classes/class.container.php index 113409b..e129906 100644 --- a/frontend/classes/class.container.php +++ b/frontend/classes/class.container.php @@ -248,6 +248,25 @@ class Container extends CPHPDatabaseRecordClass } } + public function SetOptions($options) + { + if(is_array($options)) + { + foreach($options as $key => $value) + { + $config_elements[] = "--{$key} {$value}"; + } + + $config_string = implode(" ", $config_elements); + + $this->sNode->ssh->RunCommand("vzctl set {$this->sInternalId} {$config_string} --save", true); + } + else + { + throw new InvalidArgumentException("The option argument to Container::SetOptions should be an array."); + } + } + public function RunCommand($command, $throw_exception = false) { return $this->sNode->ssh->RunCommand("vzctl exec {$this->sInternalId} $command", $throw_exception);