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

add support for describe_reserved_instances to ec2

This commit is contained in:
geemus (Wesley Beary) 2010-02-18 16:57:50 -08:00
parent 956177f235
commit 6afa66ecb8
3 changed files with 90 additions and 0 deletions

View file

@ -47,6 +47,7 @@ module Fog
"fog/aws/parsers/ec2/describe_availability_zones.rb",
"fog/aws/parsers/ec2/describe_images.rb",
"fog/aws/parsers/ec2/describe_instances.rb",
"fog/aws/parsers/ec2/describe_reserved_instances.rb",
"fog/aws/parsers/ec2/describe_key_pairs.rb",
"fog/aws/parsers/ec2/describe_regions.rb",
"fog/aws/parsers/ec2/describe_security_groups.rb",
@ -72,6 +73,7 @@ module Fog
"fog/aws/requests/ec2/describe_availability_zones.rb",
"fog/aws/requests/ec2/describe_images.rb",
"fog/aws/requests/ec2/describe_instances.rb",
"fog/aws/requests/ec2/describe_reserved_instances.rb",
"fog/aws/requests/ec2/describe_key_pairs.rb",
"fog/aws/requests/ec2/describe_regions.rb",
"fog/aws/requests/ec2/describe_security_groups.rb",

View file

@ -0,0 +1,36 @@
module Fog
module Parsers
module AWS
module EC2
class DescribeReservedInstances < Fog::Parsers::Base
def reset
@reserved_instance = {}
@response = { 'reservedInstancesSet' => [] }
end
def end_element(name)
case name
when 'availabilityZone', 'instanceType', 'productDescription', 'reservedInstancesId', 'state'
@reserved_instance[name] = @value
when 'duration', 'instanceCount'
@reserved_instance[name] = @value.to_i
when 'fixedPrice', 'usagePrice'
@reserved_instance[name] = @value.to_f
when 'item'
@response['reservedInstancesSet'] << @reserved_instance
@reserved_instance = {}
when 'requestId'
@response[name] = @value
when 'start'
@response[name] = Time.parse(@value)
end
end
end
end
end
end
end

View file

@ -0,0 +1,52 @@
unless Fog.mocking?
module Fog
module AWS
class EC2
# Describe all or specified reserved instances
#
# ==== Parameters
# * reserved_instances_id<~Array> - List of reserved instance ids to describe, defaults to all
#
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'requestId'<~String> - Id of request
# * 'reservedInstancesSet'<~Array>:
# * 'availabilityZone'<~String> - availability zone of the instance
# * 'duration'<~Integer> - duration of reservation, in seconds
# * 'fixedPrice'<~Float> - purchase price of reserved instance
# * 'instanceType'<~String> - type of instance
# * 'instanceCount'<~Integer> - number of reserved instances
# * 'productDescription'<~String> - reserved instance description
# * 'reservedInstancesId'<~String> - id of the instance
# * 'start'<~Time> - start time for reservation
# * 'state'<~String> - state of reserved instance purchase, in .[pending-payment, active, payment-failed, retired]
# * 'usagePrice"<~Float> - usage price of reserved instances, per hour
def describe_reserved_instances(reserved_instances_id = [])
params = AWS.indexed_param('ReservedInstancesId', reserved_instances_id)
request({
'Action' => 'DescribeReservedInstances'
}.merge!(params), Fog::Parsers::AWS::EC2::DescribeReservedInstances.new)
end
end
end
end
else
module Fog
module AWS
class EC2
def describe_reserved_instances(reserved_instances_id = {})
raise MockNotImplemented.new("Contributions welcome!")
end
end
end
end
end