コード例 #1
0
ファイル: Ec2ImageBase.php プロジェクト: datasift/storyplayer
 public function __construct(StoryTeller $st, $params = array())
 {
     // call our parent
     parent::__construct($st, $params);
     // remember the name of this VM
     $this->amiId = $params[0];
     // get the data about the instance from EC2
     $this->image = fromEc2()->getImage($this->amiId);
 }
コード例 #2
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;
     }
 }
コード例 #3
0
ファイル: Ec2Vm.php プロジェクト: datasift/storyplayer
 /**
  *
  * @param  Ec2VmDetails $vmDetails
  * @return boolean
  */
 public function isRunning($vmDetails)
 {
     // what are we doing?
     $log = usingLog()->startAction("determine status of EC2 VM '{$vmDetails->hostId}'");
     // get the instance data
     $instance = fromEc2()->getInstance($vmDetails->hostId);
     if (!$instance) {
         $log->endAction("no such instance");
         return false;
     }
     $isRunning = fromEc2InstanceIsRunning($vmDetails->ec2Name)->getInstanceIsRunning();
     if (!$isRunning) {
         $log->endAction("VM is not running");
         return false;
     }
     // all done
     $log->endAction("VM is running");
     return true;
 }
コード例 #4
0
 public function markAllVolumesAsDeleteOnTermination()
 {
     $this->requiresValidHost(__METHOD__);
     // what are we doing?
     $log = usingLog()->startAction("mark all volumes on EC2 VM '{$this->instanceName}' to be deleted on termination");
     // create a list of all of the volumes we're going to modify
     $ebsVolumes = array();
     foreach ($this->instance['BlockDeviceMappings'] as $origEbsVolume) {
         $ebsVolume = array('DeviceName' => $origEbsVolume['DeviceName'], 'Ebs' => array('DeleteOnTermination' => true));
         $ebsVolumes[] = $ebsVolume;
     }
     // get the AWS EC2 client to work with
     $ec2Client = fromAws()->getEc2Client();
     // let's mark all of the volumes as needing to be deleted
     // on termination
     $ec2Client->modifyInstanceAttribute(array('InstanceId' => $this->instance['InstanceId'], 'BlockDeviceMappings' => $ebsVolumes));
     // now, we need to make sure that actually worked
     $this->instance = fromEc2()->getInstance($this->instanceName);
     // var_dump("\n\n\nAFTER MODIFY INSTANCE ATTRIBUTE\n\n");
     // var_dump($this->instance);
     // that should be that
     $log->endAction();
 }