1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

first pass at describe availability zones

This commit is contained in:
Wesley Beary 2009-07-13 09:58:08 -07:00
parent 9382978cbf
commit c673155a7b
3 changed files with 71 additions and 4 deletions

View file

@ -10,6 +10,7 @@ require "#{parsers_directory}/create_key_pair"
require "#{parsers_directory}/create_snapshot"
require "#{parsers_directory}/create_volume"
require "#{parsers_directory}/describe_addresses"
require "#{parsers_directory}/describe_availability_zones"
require "#{parsers_directory}/describe_images"
require "#{parsers_directory}/describe_instances"
require "#{parsers_directory}/describe_key_pairs"
@ -207,7 +208,7 @@ module Fog
# Describe all or specified IP addresses.
#
# ==== Parameters
# * public_ips<~Array> - List of ips to describe, defaults to all
# * public_ip<~Array> - List of ips to describe, defaults to all
#
# ==== Returns
# * response<~Fog::AWS::Response>:
@ -216,13 +217,30 @@ module Fog
# * :address_set<~Array>:
# * :instance_id<~String> - instance for ip address
# * :public_ip<~String> - ip address for instance
def describe_addresses(public_ips = [])
params = indexed_params('PublicIp', public_ips)
def describe_addresses(public_ip = [])
params = indexed_params('PublicIp', public_ip)
request({
'Action' => 'DescribeAddresses'
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAddresses.new)
end
# Describe all or specified availability zones
#
# ==== Params
# * zone_name<~String> - List of availability zones to describe, defaults to all
#
# ==== Returns
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :request_id<~String> - Id of request
# FIXME: docs
def describe_availability_zones(zone_name = [])
params = indexed_params('ZoneName', zone_name)
request({
'Action' => 'DescribeAvailabilityZones'
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeAvailabilityZones.new)
end
# Describe all or specified images.
#
# ==== Params

View file

@ -0,0 +1,34 @@
module Fog
module Parsers
module AWS
module EC2
class DescribeAvailabilityZones < Fog::Parsers::Base
def reset
@zone = {}
@response = { :availability_zone_info => [] }
end
def end_element(name)
case name
when 'item'
@response[:availability_zone_info] << @zone
@zone = {}
when 'regionName'
@zone[:region_name] = @value
when 'requestId'
@response[:request_id] = @value
when 'zoneName'
@zone[:zone_name] = @value
when 'zoneState'
@zone[:zone_state] = @value
end
end
end
end
end
end
end

View file

@ -0,0 +1,15 @@
require File.dirname(__FILE__) + '/../../spec_helper'
describe 'EC2.describe_availability_zones' do
it "should return proper attributes with no params" do
actual = ec2.describe_availability_zones
zone = actual.body[:availability_zone_info].first
zone[:region_name].should be_a(String)
zone[:zone_name].should be_a(String)
zone[:zone_state].should be_a(String)
end
it "should return proper attributes for specific ip"
end