| @@ 58-75 (lines=18) @@ | ||
| 55 | */ |
|
| 56 | class ExpectsEc2Image extends Ec2ImageBase |
|
| 57 | { |
|
| 58 | public function isAvailable() |
|
| 59 | { |
|
| 60 | $this->requiresValidImage(__METHOD__); |
|
| 61 | ||
| 62 | // what are we doing? |
|
| 63 | $log = usingLog()->startAction("make sure EC2 image '{$this->amiId}' is available"); |
|
| 64 | ||
| 65 | // get the state of the image |
|
| 66 | $imageState = $this->image['State']; |
|
| 67 | ||
| 68 | if ($imageState != 'available') { |
|
| 69 | $log->endAction("image state is '{$imageState}'"); |
|
| 70 | throw Exceptions::newExpectFailedException(__METHOD__, "state is 'available'", "state is '{$imageState}'"); |
|
| 71 | } |
|
| 72 | ||
| 73 | // if we get here, all is well |
|
| 74 | $log->endAction(); |
|
| 75 | } |
|
| 76 | ||
| 77 | public function hasFailed() |
|
| 78 | { |
|
| @@ 77-94 (lines=18) @@ | ||
| 74 | $log->endAction(); |
|
| 75 | } |
|
| 76 | ||
| 77 | public function hasFailed() |
|
| 78 | { |
|
| 79 | $this->requiresValidImage(__METHOD__); |
|
| 80 | ||
| 81 | // what are we doing? |
|
| 82 | $log = usingLog()->startAction("make sure EC2 image '{$this->amiId}' has failed"); |
|
| 83 | ||
| 84 | // get the state of the image |
|
| 85 | $imageState = $this->image['State']; |
|
| 86 | ||
| 87 | if ($imageState != 'failed') { |
|
| 88 | $log->endAction("image state is '{$imageState}'"); |
|
| 89 | throw Exceptions::newExpectFailedException(__METHOD__, "state is 'failed'", "state is '{$imageState}'"); |
|
| 90 | } |
|
| 91 | ||
| 92 | // if we get here, all is well |
|
| 93 | $log->endAction(); |
|
| 94 | } |
|
| 95 | ||
| 96 | public function isPending() |
|
| 97 | { |
|
| @@ 96-113 (lines=18) @@ | ||
| 93 | $log->endAction(); |
|
| 94 | } |
|
| 95 | ||
| 96 | public function isPending() |
|
| 97 | { |
|
| 98 | $this->requiresValidImage(__METHOD__); |
|
| 99 | ||
| 100 | // what are we doing? |
|
| 101 | $log = usingLog()->startAction("make sure EC2 image '{$this->amiId}' is pending"); |
|
| 102 | ||
| 103 | // get the state of the image |
|
| 104 | $imageState = $this->image['State']; |
|
| 105 | ||
| 106 | if ($imageState != 'pending') { |
|
| 107 | $log->endAction("image state is '{$imageState}'"); |
|
| 108 | throw Exceptions::newExpectFailedException(__METHOD__, "state is 'pending'", "state is '{$imageState}'"); |
|
| 109 | } |
|
| 110 | ||
| 111 | // if we get here, all is well |
|
| 112 | $log->endAction(); |
|
| 113 | } |
|
| 114 | } |
|
| @@ 176-189 (lines=14) @@ | ||
| 173 | $log->endAction(); |
|
| 174 | } |
|
| 175 | ||
| 176 | public function screenIsRunning($sessionName) |
|
| 177 | { |
|
| 178 | // what are we doing? |
|
| 179 | $log = usingLog()->startAction("make sure screen session '{$sessionName}' is running on host '{$this->args[0]}'"); |
|
| 180 | ||
| 181 | // is this session still running? |
|
| 182 | if (fromHost($this->args[0])->getScreenIsRunning($sessionName)) { |
|
| 183 | $log->endAction(); |
|
| 184 | return; |
|
| 185 | } |
|
| 186 | ||
| 187 | $log->endAction("session is not running"); |
|
| 188 | throw Exceptions::newExpectFailedException(__METHOD__, "session '{$sessionName}' running", "session '{$sessionName}' not running"); |
|
| 189 | } |
|
| 190 | ||
| 191 | public function screenIsNotRunning($sessionName) |
|
| 192 | { |
|
| @@ 191-204 (lines=14) @@ | ||
| 188 | throw Exceptions::newExpectFailedException(__METHOD__, "session '{$sessionName}' running", "session '{$sessionName}' not running"); |
|
| 189 | } |
|
| 190 | ||
| 191 | public function screenIsNotRunning($sessionName) |
|
| 192 | { |
|
| 193 | // what are we doing? |
|
| 194 | $log = usingLog()->startAction("make sure screen session '{$sessionName}' is not running on host '{$this->args[0]}'"); |
|
| 195 | ||
| 196 | // get the details |
|
| 197 | if (!fromHost($this->args[0])->getScreenIsRunning($sessionName)) { |
|
| 198 | $log->endAction("session is not running"); |
|
| 199 | return; |
|
| 200 | } |
|
| 201 | ||
| 202 | $log->endAction("session is running"); |
|
| 203 | throw Exceptions::newExpectFailedException(__METHOD__, "session not running", "session running as PID {$processDetails->pid}"); |
|
| 204 | } |
|
| 205 | ||
| 206 | /** |
|
| 207 | * the old SPv1 call, when this was part of expectsShell() |
|