저자: Stuart Herbert (stuart.herbert@datasift.com)
 public function __construct(StoryTeller $st, $args)
 {
     // call our parent
     parent::__construct($st, $args);
     // $args[0] should contain the name of a valid provisioning helper
     if (!isset($args[0])) {
         throw new E5xx_ActionFailed(__METHOD__, "Param #0 must be the name of the provisioning engine you want to use");
     }
     // remember the provisioner for later
     $this->adapter = ProvisioningLib::getProvisioner($st, $args[0]);
 }
 public function doPhase($thingBeingPlayed = null)
 {
     // shorthand
     $st = $this->st;
     // our return value
     $phaseResult = $this->getNewPhaseResult();
     // find out what we need to be doing
     $testEnvironmentConfig = $st->getTestEnvironmentConfig();
     // are there any machines to create?
     if (empty($testEnvironmentConfig)) {
         // nothing to do
         $phaseResult->setContinuePlaying();
         return $phaseResult;
     }
     // create the environments
     try {
         foreach ($testEnvironmentConfig->groups as $group) {
             // create the machine(s) in this environment, including:
             //
             // * building any virtual machines
             // * registering in the Hosts table
             // * registering in the Roles table
             $hostAdapter = HostLib::getHostAdapter($st, $group->type);
             $hostAdapter->createHost($group);
             // provision software onto the machines we've just
             // created
             if (isset($group->provisioning)) {
                 $provAdapter = ProvisioningLib::getProvisioner($st, $group->provisioning->engine);
                 $provDef = $provAdapter->buildDefinitionFor($group);
                 $provAdapter->provisionHosts($provDef, $group->provisioning);
             }
         }
         $st->usingTargetsTable()->addCurrentTestEnvironment();
         $phaseResult->setContinuePlaying();
     } catch (E5xx_ActionFailed $e) {
         $phaseResult->setPlayingFailed($phaseResult::FAILED, $e->getMessage(), $e);
     } catch (E5xx_ExpectFailed $e) {
         $phaseResult->setPlayingFailed($phaseResult::FAILED, $e->getMessage(), $e);
     } catch (E5xx_NotImplemented $e) {
         $phaseResult->setPlayingFailed($phaseResult::INCOMPLETE, $e->getMessage(), $e);
     } catch (Exception $e) {
         $phaseResult->setPlayingFailed($phaseResult::ERROR, $e->getMessage() . PHP_EOL . PHP_EOL . $e->getTraceAsString(), $e);
     }
     // all done
     return $phaseResult;
 }