Esempio n. 1
0
 public function __construct(StoryTeller $st, $params = array())
 {
     // call our parent
     parent::__construct($st, $params);
     // get the VM details from the hosts table
     $this->vmDetails = fromHostsTable()->getDetailsForHost($params[0]);
     if ($this->vmDetails) {
         // remember the name of this VM
         $this->instanceName = $this->vmDetails->ec2Name;
         // get the data about the instance from EC2
         $this->instance = fromEc2()->getInstance($this->instanceName);
         // add the instance data to the vmDetails too, to keep that
         // up to date
         $this->vmDetails->ec2Instance = $this->instance;
     }
 }
Esempio n. 2
0
 protected function getHostDetails()
 {
     // shorthand
     $hostId = $this->args[0];
     // do we know anything about this host?
     $hostsTable = fromHostsTable()->getHostsTable();
     if (!isset($hostsTable->{$hostId})) {
         $hostDetails = new BaseObject();
         $hostDetails->hostId = $hostId;
         $hostDetails->osName = "unknown";
         $hostDetails->nameInHostsTable = $hostId;
         $hostDetails->invalidHost = true;
     } else {
         $hostDetails = $hostsTable->{$hostId};
     }
     return $hostDetails;
 }
Esempio n. 3
0
 /**
  *
  * @param  stdClass $groupDef
  * @return void
  */
 public function destroyHost($groupDef)
 {
     // what are we doing?
     $log = usingLog()->startAction("destroy VM(s)");
     // stop all the VMs, one by one
     foreach ($groupDef->details->machines as $hostId => $machine) {
         // get the machine details
         $vmDetails = fromHostsTable()->getDetailsForHost($hostId);
         if ($vmDetails) {
             // is the VM actually running?
             if (fromHost($hostId)->getHostIsRunning()) {
                 // delete the VM from disk
                 //
                 // this will also deregister the host from the
                 // HostsTable and RolesTable
                 usingVagrant()->destroyVm($hostId);
             }
         }
     }
     // all done
     $log->endAction();
 }