From aee9034fee98fc20326a13909b85654c41382f0b Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Wed, 9 May 2012 03:42:42 +0200 Subject: [PATCH] Return correct status when suspended or terminated --- frontend/classes/class.container.php | 31 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/frontend/classes/class.container.php b/frontend/classes/class.container.php index b6e09d7..105d539 100644 --- a/frontend/classes/class.container.php +++ b/frontend/classes/class.container.php @@ -99,21 +99,28 @@ class Container extends CPHPDatabaseRecordClass public function GetCurrentStatus() { - $command = "vzctl status {$this->sInternalId}"; - - $result = $this->sNode->ssh->RunCommandCached($command, false); - - if($result->returncode == 0) + if($this->sStatus == CVM_STATUS_SUSPENDED || $this->sStatus == CVM_STATUS_TERMINATED) + { + return $this->sStatus; + } + else { - $values = split_whitespace($result->stdout); + $command = "vzctl status {$this->sInternalId}"; - if($values[4] == "running") - { - return CVM_STATUS_STARTED; - } - else + $result = $this->sNode->ssh->RunCommandCached($command, false); + + if($result->returncode == 0) { - return CVM_STATUS_STOPPED; + $values = split_whitespace($result->stdout); + + if($values[4] == "running") + { + return CVM_STATUS_STARTED; + } + else + { + return CVM_STATUS_STOPPED; + } } } }