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']);
     }
 }
Exemplo 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;
    }
Exemplo n.º 3
0
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     $this->availabilityZones = new Ec2\AvailabilityZones('access_key', 'secret_access_key');
     $adapter = new \Zend\Http\Client\Adapter\Test();
     $client = new \Zend\Http\Client(null, array('adapter' => $adapter));
     $this->adapter = $adapter;
     Ec2\AvailabilityZones::setDefaultHttpClient($client);
 }
Exemplo n.º 4
0
 /**
  * Prepares the environment before running a test.
  */
 protected function setUp()
 {
     parent::setUp();
     $this->Zend_Service_Amazon_Ec2_Availabilityzones = new Ec2\AvailabilityZones('access_key', 'secret_access_key');
     $adapter = new \Zend\HTTP\Client\Adapter\Test();
     $client = new \Zend\HTTP\Client(null, array('adapter' => $adapter));
     $this->adapter = $adapter;
     Ec2\AvailabilityZones::setDefaultHTTPClient($client);
 }
Exemplo n.º 5
0
 /**
  * Return all the available zones
  * 
  * @return array
  */
 public function zonesInstance()
 {
     if (!isset($this->ec2Zone)) {
         $this->ec2Zone = new Ec2Zone($this->accessKey, $this->accessSecret, $this->region);
     }
     $this->adapterResult = $this->ec2Zone->describe();
     $zones = array();
     foreach ($this->adapterResult as $zone) {
         if (strtolower($zone['zoneState']) === 'available') {
             $zones[] = array(Instance::INSTANCE_ZONE => $zone['zoneName']);
         }
     }
     return $zones;
 }