Esempio n. 1
0
 public function testDescribeMultipleAvailabilityZones()
 {
     $rawHttpResponse = "HTTP/1.1 200 OK\r\n" . "Date: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Server: hi\r\n" . "Last-modified: Fri, 24 Oct 2008 17:24:52 GMT\r\n" . "Status: 200 OK\r\n" . "Content-type: application/xml; charset=utf-8\r\n" . "Expires: Tue, 31 Mar 1981 05:00:00 GMT\r\n" . "Connection: close\r\n" . "\r\n" . "<DescribeAvailabilityZonesResponse xmlns=\"http://ec2.amazonaws.com/doc/2009-04-04/\">\r\n" . "  <availabilityZoneInfo>\r\n" . "    <item>\r\n" . "      <zoneName>us-east-1a</zoneName>\r\n" . "      <zoneState>available</zoneState>\r\n" . "    </item>\r\n" . "    <item>\r\n" . "      <zoneName>us-east-1b</zoneName>\r\n" . "      <zoneState>available</zoneState>\r\n" . "    </item>\r\n" . "    <item>\r\n" . "      <zoneName>us-east-1c</zoneName>\r\n" . "      <zoneState>available</zoneState>\r\n" . "    </item>\r\n" . "  </availabilityZoneInfo>\r\n" . "</DescribeAvailabilityZonesResponse>";
     $this->httpClientTestAdapter->setResponse($rawHttpResponse);
     $response = $this->availabilityZones->describe();
     $this->assertInternalType('array', $response);
     $arrExpected = array('us-east-1a', 'us-east-1b', 'us-east-1c');
     foreach ($response as $k => $node) {
         $this->assertEquals($arrExpected[$k], $node['zoneName']);
     }
 }
Esempio n. 2
0
 /**
  * Return all the available zones
  *
  * @return boolean|array
  */
 public function zonesInstance()
 {
     if (!isset($this->ec2Zone)) {
         $this->ec2Zone = new Ec2Zone($this->accessKey, $this->accessSecret, $this->region);
         $this->ec2Zone->setHttpClient($this->ec2->getHttpClient());
     }
     $this->resetError();
     try {
         $this->adapterResult = $this->ec2Zone->describe();
     } catch (Ec2Exception\RunTimeException $e) {
         $this->setError($e);
         return false;
     }
     $zones = array();
     foreach ($this->adapterResult as $zone) {
         if (strtolower($zone['zoneState']) === 'available') {
             $zones[] = array(Instance::INSTANCE_ZONE => $zone['zoneName']);
         }
     }
     return $zones;
 }