@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | public function createHost($groupDef, $provisioningVars = array()) |
| 89 | 89 | { |
| 90 | 90 | // what are we doing? |
| 91 | - $log =Log::usingLog()->startAction('register blackbox(es)'); |
|
| 91 | + $log = Log::usingLog()->startAction('register blackbox(es)'); |
|
| 92 | 92 | |
| 93 | 93 | // make sure we like the provided details |
| 94 | 94 | if (!isset($groupDef->details)) { |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | if (empty($groupDef->details->machines)) { |
| 101 | 101 | throw Exceptions::newActionFailedException(__METHOD__, "groupDef->details->machines cannot be empty"); |
| 102 | 102 | } |
| 103 | - foreach($groupDef->details->machines as $hostId => $machine) { |
|
| 103 | + foreach ($groupDef->details->machines as $hostId => $machine) { |
|
| 104 | 104 | // TODO: it would be great to autodetect this one day |
| 105 | 105 | if (!isset($machine->roles)) { |
| 106 | 106 | throw Exceptions::newActionFailedException(__METHOD__, "missing groupDef->details->machines['$hostId']->roles"); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | // if it is not, that is NOT our responsibility |
| 122 | 122 | |
| 123 | 123 | // store the details |
| 124 | - foreach($groupDef->details->machines as $hostId => $machine) |
|
| 124 | + foreach ($groupDef->details->machines as $hostId => $machine) |
|
| 125 | 125 | { |
| 126 | 126 | // we want all the details from the config file |
| 127 | 127 | $vmDetails = clone $machine; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | public function destroyHost($groupDef) |
| 201 | 201 | { |
| 202 | 202 | // what are we doing? |
| 203 | - $log =Log::usingLog()->startAction("de-register blackbox(es)"); |
|
| 203 | + $log = Log::usingLog()->startAction("de-register blackbox(es)"); |
|
| 204 | 204 | |
| 205 | 205 | // de-register all the hosts |
| 206 | 206 | foreach ($groupDef->details->machines as $hostId => $machine) |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | public function createHost($vmDetails, $provisioningVars = array()) |
| 90 | 90 | { |
| 91 | 91 | // what are we doing? |
| 92 | - $log =Log::usingLog()->startAction('provision new VM'); |
|
| 92 | + $log = Log::usingLog()->startAction('provision new VM'); |
|
| 93 | 93 | |
| 94 | 94 | // make sure we like the provided details |
| 95 | - foreach(array('name', 'environment', 'osName', 'amiId', 'securityGroup') as $param) { |
|
| 95 | + foreach (array('name', 'environment', 'osName', 'amiId', 'securityGroup') as $param) { |
|
| 96 | 96 | if (!isset($vmDetails->$param)) { |
| 97 | 97 | throw Exceptions::newActionFailedException(__METHOD__, "missing vmDetails['{$param}']"); |
| 98 | 98 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $client->createTags(array( |
| 133 | 133 | 'Resources' => array($response['Instances'][0]['InstanceId']), |
| 134 | 134 | 'Tags' => array( |
| 135 | - array ( |
|
| 135 | + array( |
|
| 136 | 136 | 'Key' => 'Name', |
| 137 | 137 | 'Value' => $vmDetails->ec2Name |
| 138 | 138 | ) |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | public function startHost($vmDetails) |
| 200 | 200 | { |
| 201 | 201 | // what are we doing? |
| 202 | - $log =Log::usingLog()->startAction("start VM"); |
|
| 202 | + $log = Log::usingLog()->startAction("start VM"); |
|
| 203 | 203 | |
| 204 | 204 | // is the VM actually running? |
| 205 | 205 | if ($this->isRunning($vmDetails)) { |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | public function stopHost($vmDetails) |
| 265 | 265 | { |
| 266 | 266 | // what are we doing? |
| 267 | - $log =Log::usingLog()->startAction("stop VM"); |
|
| 267 | + $log = Log::usingLog()->startAction("stop VM"); |
|
| 268 | 268 | |
| 269 | 269 | // is the VM actually running? |
| 270 | 270 | if (!$this->isRunning($vmDetails)) { |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | public function restartHost($vmDetails) |
| 320 | 320 | { |
| 321 | 321 | // what are we doing? |
| 322 | - $log =Log::usingLog()->startAction("restart VM"); |
|
| 322 | + $log = Log::usingLog()->startAction("restart VM"); |
|
| 323 | 323 | |
| 324 | 324 | // stop and start |
| 325 | 325 | $this->stopHost($vmDetails); |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | public function destroyHost($vmDetails) |
| 351 | 351 | { |
| 352 | 352 | // what are we doing? |
| 353 | - $log =Log::usingLog()->startAction("destroy VM"); |
|
| 353 | + $log = Log::usingLog()->startAction("destroy VM"); |
|
| 354 | 354 | |
| 355 | 355 | // get our Ec2 client from the SDK |
| 356 | 356 | $client = fromAws()->getEc2Client(); |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | public function isRunning($vmDetails) |
| 420 | 420 | { |
| 421 | 421 | // what are we doing? |
| 422 | - $log =Log::usingLog()->startAction("determine status of EC2 VM '{$vmDetails->hostId}'"); |
|
| 422 | + $log = Log::usingLog()->startAction("determine status of EC2 VM '{$vmDetails->hostId}'"); |
|
| 423 | 423 | |
| 424 | 424 | // get the instance data |
| 425 | 425 | $instance = fromEc2()->getInstance($vmDetails->hostId); |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | public function determineIpAddress($vmDetails) |
| 447 | 447 | { |
| 448 | 448 | // what are we doing? |
| 449 | - $log =Log::usingLog()->startAction("determine IP address of EC2 VM '{$vmDetails->hostId}'"); |
|
| 449 | + $log = Log::usingLog()->startAction("determine IP address of EC2 VM '{$vmDetails->hostId}'"); |
|
| 450 | 450 | |
| 451 | 451 | // we need to get a fresh copy of the instance details |
| 452 | 452 | $dnsName = fromEc2Instance($vmDetails->hostId)->getPublicDnsName(); |
@@ -59,143 +59,143 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | class Story_Checkpoint implements IteratorAggregate |
| 61 | 61 | { |
| 62 | - /** |
|
| 63 | - * the StoryTeller object |
|
| 64 | - * |
|
| 65 | - * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
| 66 | - */ |
|
| 67 | - private $st; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * keep track of whether the checkpoint is readonly (true) or |
|
| 71 | - * read-write(false) |
|
| 72 | - * |
|
| 73 | - * @var boolean |
|
| 74 | - */ |
|
| 75 | - private $readOnly = false; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * the data stored inside the checkpoint |
|
| 79 | - * |
|
| 80 | - * @var array |
|
| 81 | - */ |
|
| 82 | - private $data = array(); |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * our constructor |
|
| 86 | - * |
|
| 87 | - * @param StoryTeller $st |
|
| 88 | - * The StoryTeller object (which we will cache) |
|
| 89 | - */ |
|
| 90 | - public function __construct(StoryTeller $st) |
|
| 91 | - { |
|
| 92 | - // remember the StoryTeller object for future use |
|
| 93 | - $this->st = $st; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * is the checkpoint currently readonly? |
|
| 98 | - * |
|
| 99 | - * @return boolean |
|
| 100 | - * TRUE if the checkpoint is currently readonly |
|
| 101 | - * FALSE if you can change the data in the checkpoint |
|
| 102 | - */ |
|
| 103 | - public function getReadOnly() |
|
| 104 | - { |
|
| 105 | - return $this->readOnly; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * put the checkpoint into readonly mode |
|
| 110 | - */ |
|
| 111 | - public function setReadOnly() |
|
| 112 | - { |
|
| 113 | - $this->readOnly = true; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * put the checkpoint into read-write mode |
|
| 118 | - */ |
|
| 119 | - public function setReadWrite() |
|
| 120 | - { |
|
| 121 | - $this->readOnly = false; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 125 | - * magic method to retrieve data from the checkpoint |
|
| 126 | - * |
|
| 127 | - * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
| 128 | - * to get data that does not exist |
|
| 129 | - * |
|
| 130 | - * @param string $key |
|
| 131 | - * the name of the data to store |
|
| 132 | - * @return mixed |
|
| 133 | - * the data stored in the checkpoint |
|
| 134 | - */ |
|
| 135 | - public function &__get($key) |
|
| 136 | - { |
|
| 137 | - // what are we doing? |
|
| 138 | - $log = Log::usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
| 139 | - |
|
| 140 | - // do we have the data to return? |
|
| 141 | - if (!isset($this->data[$key])) { |
|
| 142 | - // no, we do not |
|
| 143 | - $log->endAction("'{$key}' is not in the checkpoint"); |
|
| 144 | - throw new E5xx_NoSuchDataInCheckpoint($key); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - // yes, we do |
|
| 62 | + /** |
|
| 63 | + * the StoryTeller object |
|
| 64 | + * |
|
| 65 | + * @var \DataSift\Storyplayer\PlayerLib\StoryTeller |
|
| 66 | + */ |
|
| 67 | + private $st; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * keep track of whether the checkpoint is readonly (true) or |
|
| 71 | + * read-write(false) |
|
| 72 | + * |
|
| 73 | + * @var boolean |
|
| 74 | + */ |
|
| 75 | + private $readOnly = false; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * the data stored inside the checkpoint |
|
| 79 | + * |
|
| 80 | + * @var array |
|
| 81 | + */ |
|
| 82 | + private $data = array(); |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * our constructor |
|
| 86 | + * |
|
| 87 | + * @param StoryTeller $st |
|
| 88 | + * The StoryTeller object (which we will cache) |
|
| 89 | + */ |
|
| 90 | + public function __construct(StoryTeller $st) |
|
| 91 | + { |
|
| 92 | + // remember the StoryTeller object for future use |
|
| 93 | + $this->st = $st; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * is the checkpoint currently readonly? |
|
| 98 | + * |
|
| 99 | + * @return boolean |
|
| 100 | + * TRUE if the checkpoint is currently readonly |
|
| 101 | + * FALSE if you can change the data in the checkpoint |
|
| 102 | + */ |
|
| 103 | + public function getReadOnly() |
|
| 104 | + { |
|
| 105 | + return $this->readOnly; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * put the checkpoint into readonly mode |
|
| 110 | + */ |
|
| 111 | + public function setReadOnly() |
|
| 112 | + { |
|
| 113 | + $this->readOnly = true; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * put the checkpoint into read-write mode |
|
| 118 | + */ |
|
| 119 | + public function setReadWrite() |
|
| 120 | + { |
|
| 121 | + $this->readOnly = false; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + /** |
|
| 125 | + * magic method to retrieve data from the checkpoint |
|
| 126 | + * |
|
| 127 | + * throws the E5xx_NoSuchDataInCheckpoint exception if you attempt |
|
| 128 | + * to get data that does not exist |
|
| 129 | + * |
|
| 130 | + * @param string $key |
|
| 131 | + * the name of the data to store |
|
| 132 | + * @return mixed |
|
| 133 | + * the data stored in the checkpoint |
|
| 134 | + */ |
|
| 135 | + public function &__get($key) |
|
| 136 | + { |
|
| 137 | + // what are we doing? |
|
| 138 | + $log = Log::usingLog()->startAction("retrieve '{$key}' from the checkpoint"); |
|
| 139 | + |
|
| 140 | + // do we have the data to return? |
|
| 141 | + if (!isset($this->data[$key])) { |
|
| 142 | + // no, we do not |
|
| 143 | + $log->endAction("'{$key}' is not in the checkpoint"); |
|
| 144 | + throw new E5xx_NoSuchDataInCheckpoint($key); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + // yes, we do |
|
| 148 | 148 | $log->endAction($this->data[$key]); |
| 149 | 149 | |
| 150 | - // all done |
|
| 151 | - return $this->data[$key]; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * magic method to tell if the data is stored in the checkpoint or not |
|
| 156 | - * |
|
| 157 | - * @param string $key |
|
| 158 | - * the name of the data to test for |
|
| 159 | - * @return boolean |
|
| 160 | - * TRUE if the data exists in the checkpoint |
|
| 161 | - * FALSE if the data does not exist in the checkpoint |
|
| 162 | - */ |
|
| 163 | - public function __isset($key) |
|
| 164 | - { |
|
| 165 | - return (isset($this->data[$key])); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * magic method to store data in the checkpoint |
|
| 170 | - * |
|
| 171 | - * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
| 172 | - * to store data when the checkpoint is in readonly mode |
|
| 173 | - * |
|
| 174 | - * @param string $key |
|
| 175 | - * the name of the data to store |
|
| 176 | - * @param mixed $value |
|
| 177 | - * the value to store in the checkpoint |
|
| 178 | - * @return void |
|
| 179 | - */ |
|
| 180 | - public function __set($key, $value) |
|
| 181 | - { |
|
| 182 | - // what are we doing? |
|
| 183 | - $log = Log::usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
| 184 | - |
|
| 185 | - // are we allowed to change the data at this time? |
|
| 186 | - if ($this->readOnly) |
|
| 187 | - { |
|
| 188 | - // no, we are not |
|
| 189 | - $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
| 190 | - throw new E5xx_CheckpointIsReadOnly(); |
|
| 191 | - } |
|
| 192 | - |
|
| 193 | - // if we get here, we're allowed to change the checkpoint |
|
| 194 | - $this->data[$key] = $value; |
|
| 195 | - |
|
| 196 | - // all done |
|
| 197 | - $log->endAction($value); |
|
| 198 | - } |
|
| 150 | + // all done |
|
| 151 | + return $this->data[$key]; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * magic method to tell if the data is stored in the checkpoint or not |
|
| 156 | + * |
|
| 157 | + * @param string $key |
|
| 158 | + * the name of the data to test for |
|
| 159 | + * @return boolean |
|
| 160 | + * TRUE if the data exists in the checkpoint |
|
| 161 | + * FALSE if the data does not exist in the checkpoint |
|
| 162 | + */ |
|
| 163 | + public function __isset($key) |
|
| 164 | + { |
|
| 165 | + return (isset($this->data[$key])); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * magic method to store data in the checkpoint |
|
| 170 | + * |
|
| 171 | + * throws the E5xx_CheckpointIsReadOnly exception if you attempt |
|
| 172 | + * to store data when the checkpoint is in readonly mode |
|
| 173 | + * |
|
| 174 | + * @param string $key |
|
| 175 | + * the name of the data to store |
|
| 176 | + * @param mixed $value |
|
| 177 | + * the value to store in the checkpoint |
|
| 178 | + * @return void |
|
| 179 | + */ |
|
| 180 | + public function __set($key, $value) |
|
| 181 | + { |
|
| 182 | + // what are we doing? |
|
| 183 | + $log = Log::usingLog()->startAction("store '{$key}' in the checkpoint"); |
|
| 184 | + |
|
| 185 | + // are we allowed to change the data at this time? |
|
| 186 | + if ($this->readOnly) |
|
| 187 | + { |
|
| 188 | + // no, we are not |
|
| 189 | + $log->endAction("checkpoint is readonly; did not store '{$key}'"); |
|
| 190 | + throw new E5xx_CheckpointIsReadOnly(); |
|
| 191 | + } |
|
| 192 | + |
|
| 193 | + // if we get here, we're allowed to change the checkpoint |
|
| 194 | + $this->data[$key] = $value; |
|
| 195 | + |
|
| 196 | + // all done |
|
| 197 | + $log->endAction($value); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | 200 | // ==================================================================== |
| 201 | 201 | // |