Ejemplo n.º 1
0
 /**
  * Loads InstanceStateChangeData from simple xml object
  *
  * @param   \SimpleXMLElement $v
  * @return  InstanceStateChangeData Returns InstanceStateChangeData
  */
 protected function _loadInstanceStateChangeData(\SimpleXMLElement $v)
 {
     $item = null;
     if ($this->exist($v)) {
         $item = new InstanceStateChangeData();
         $item->setEc2($this->ec2);
         $item->instanceId = (string) $v->instanceId;
         $item->setCurrentState($this->_loadInstanceStateData($v->currentState));
         $item->setPreviousState($this->_loadInstanceStateData($v->previousState));
     }
     return $item;
 }
Ejemplo n.º 2
0
 /**
  * TerminateInstances
  *
  * Shuts down one or more instances. This operation is idempotent; if you terminate an instance more than
  * once, each call will succeed.
  * Terminated instances will remain visible after termination (approximately one hour).
  *
  * Note! By default, Amazon EC2 deletes all Amazon EBS volumes that were attached when the instance
  * launched. Amazon EBS volumes attached after instance launch continue running.
  * You can stop, start, and terminate EBS-backed instances.You can only terminate S3-backed instances.
  * What happens to an instance differs if you stop it or terminate it. For example, when you stop an instance,
  * the root device and any other devices attached to the instance persist. When you terminate an instance,
  * the root device and any other devices attached during the instance launch are automatically deleted.
  *
  * @param   ListDataType     $instanceIdList
  * @return  InstanceStateChangeList Returns the InstanceStateChangeList
  * @throws  ClientException
  * @throws  Ec2Exception
  */
 public function terminateInstances(ListDataType $instanceIdList)
 {
     $result = null;
     $options = array();
     if ($instanceIdList !== null) {
         $options = array_merge($options, $this->getInstanceIdListQuery($instanceIdList));
     }
     $response = $this->client->call(ucfirst(__FUNCTION__), $options);
     if ($response->getError() === false) {
         //Success
         $sxml = simplexml_load_string($response->getRawContent());
         $result = new InstanceStateChangeList();
         $result->setEc2($this->ec2);
         if (!empty($sxml->instancesSet->item)) {
             foreach ($sxml->instancesSet->item as $v) {
                 $item = new InstanceStateChangeData();
                 $item->setEc2($this->ec2);
                 $item->instanceId = (string) $v->instanceId;
                 $item->setCurrentState($this->_loadInstanceStateData($v->currentState));
                 $item->setPreviousState($this->_loadInstanceStateData($v->previousState));
                 $result->append($item);
             }
         }
     }
     return $result;
 }