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

fixe describe instances spec/docs and some missed stuff on run instances

This commit is contained in:
Wesley Beary 2009-07-21 10:56:38 -07:00
parent 4c92ee236e
commit 43b23e9147
6 changed files with 93 additions and 9 deletions

View file

@ -23,7 +23,7 @@ module Fog
def end_element(name)
case name
when 'amiLaunchIndex'
@instance[:ami_launch_index] = @value
@instance[:ami_launch_index] = @value.to_i
when 'availabilityZone'
@instance[:placement] << @value
when 'code'

View file

@ -22,7 +22,7 @@ module Fog
def end_element(name)
case name
when 'amiLaunchIndex'
@instance[:ami_launch_index] = @value
@instance[:ami_launch_index] = @value.to_i
when 'availabilityZone'
@instance[:placement][:availability_zone] = @value
when 'code'
@ -33,6 +33,8 @@ module Fog
@response[:group_set] << @value
when 'groupSet'
@in_group_set = false
when 'kernelId'
@instance[:kernel_id] = @value
when 'keyName'
@instance[:key_name] = @value
when 'imageId'

View file

@ -11,7 +11,31 @@ module Fog
# * response<~Fog::AWS::Response>:
# * body<~Hash>:
# * :request_id<~String> - Id of request
# FIXME: docs
# * :reservation_set<~Array>:
# * :group_set<~Array> - Group names for reservation
# * :owner_id<~String> - AWS Access Key ID of reservation owner
# * :reservation_id<~String> - Id of the reservation
# * :instances_set<~Array>:
# * instance<~Hash>:
# * :ami_launch_index<~Integer> - reference to instance in launch group
# * :dns_name<~String> - public dns name, blank until instance is running
# * :image_id<~String> - image id of ami used to launch instance
# * :instance_id<~String> - id of the instance
# * :instance_state<~Hash>:
# * :code<~Integer> - current status code
# * :name<~String> - current status name
# * :instance_type<~String> - type of instance
# * :kernel_id<~String> - Id of kernel used to launch instance
# * :key_name<~String> - name of key used launch instances or blank
# * :launch_time<~Time> - time instance was launched
# * :monitoring<~Hash>:
# * :state<~Boolean - state of monitoring
# * :placement<~Hash>:
# * :availability_zone<~String> - Availability zone of the instance
# * :product_codes<~Array> - Product codes for the instance
# * :private_dns_name<~String> - private dns name, blank until instance is running
# * :ramdisk_id<~String> - Id of ramdisk used to launch instance
# * :reason<~String> - reason for most recent state transition, or blank
def describe_instances(instance_id = [])
params = indexed_params('InstanceId', instance_id)
request({

View file

@ -39,7 +39,7 @@ module Fog
# * group_name<~String> - Name of group
# * :instances_set<~Array>: returned instances
# * instance<~Hash>:
# * :ami_launch_index<~String> - reference to instance in launch group
# * :ami_launch_index<~Integer> - reference to instance in launch group
# * :dns_name<~String> - public dns name, blank until instance is running
# * :image_id<~String> - image id of ami used to launch instance
# * :instance_id<~String> - id of the instance
@ -47,6 +47,7 @@ module Fog
# * :code<~Integer> - current status code
# * :name<~String> - current status name
# * :instance_type<~String> - type of instance
# * :kernel_id<~String> - Id of kernel used to launch instance
# * :key_name<~String> - name of key used launch instances or blank
# * :launch_time<~Time> - time instance was launched
# * :monitoring<~Hash>:
@ -54,6 +55,8 @@ module Fog
# * :placement<~Hash>:
# * :availability_zone<~String> - Availability zone of the instance
# * :private_dns_name<~String> - private dns name, blank until instance is running
# * :product_codes<~Array> - Product codes for the instance
# * :ramdisk_id<~String> - Id of ramdisk used to launch instance
# * :reason<~String> - reason for most recent state transition, or blank
# * :owner_id<~String> - Id of owner
# * :request_id<~String> - Id of request

View file

@ -14,11 +14,64 @@ describe 'EC2.describe_instances' do
it "should return proper attributes with no params" do
actual = ec2.describe_instances
p actual
# reservation = actual.body[:reservation_set].select {|reservation| reservation[:reservation_id] == @reservation_id}
# instance = reservation[:instances_set].select {|instance| instance[:instance_id] == @instance_id}
reservation = actual.body[:reservation_set].select {|reservation| reservation[:reservation_id] == @reservation_id}.first
reservation[:group_set].should be_an(Array)
reservation[:group_set].first.should be_a(String)
reservation[:owner_id].should be_a(String)
reservation[:reservation_id].should be_a(String)
instance = reservation[:instances_set].select {|instance| instance[:instance_id] == @instance_id}.first
instance[:ami_launch_index].should be_an(Integer)
instance[:dns_name].should be_a(String)
instance[:image_id].should be_a(String)
instance[:instance_id].should be_a(String)
instance[:instance_state].should be_a(Hash)
state = instance[:instance_state]
state[:code].should be_a(String)
state[:name].should be_a(String)
instance[:instance_type].should be_a(String)
instance[:kernel_id].should be_a(String)
# instance[:key_name].should be_a(String)
instance[:launch_time].should be_a(Time)
instance[:monitoring].should be_a(Hash)
[true, false].should include(instance[:monitoring][:state])
instance[:placement].should be_an(Array)
instance[:placement].first.should be_a(String)
instance[:private_dns_name].should be_a(String)
instance[:product_codes].should be_an(Array)
# instance[:product_codes].first.should be_a(String)
instance[:ramdisk_id].should be_a(String)
instance[:reason].should be_a(String)
end
it "should return proper attributes with params"
it "should return proper attributes with params" do
actual = ec2.describe_instances(@instance_id)
reservation = actual.body[:reservation_set].select {|reservation| reservation[:reservation_id] == @reservation_id}.first
reservation[:group_set].should be_an(Array)
reservation[:group_set].first.should be_a(String)
reservation[:owner_id].should be_a(String)
reservation[:reservation_id].should be_a(String)
instance = reservation[:instances_set].select {|instance| instance[:instance_id] == @instance_id}.first
instance[:ami_launch_index].should be_an(Integer)
instance[:dns_name].should be_a(String)
instance[:image_id].should be_a(String)
instance[:instance_id].should be_a(String)
instance[:instance_state].should be_a(Hash)
state = instance[:instance_state]
state[:code].should be_a(String)
state[:name].should be_a(String)
instance[:instance_type].should be_a(String)
instance[:kernel_id].should be_a(String)
# instance[:key_name].should be_a(String)
instance[:launch_time].should be_a(Time)
instance[:monitoring].should be_a(Hash)
[true, false].should include(instance[:monitoring][:state])
instance[:placement].should be_an(Array)
instance[:placement].first.should be_a(String)
instance[:private_dns_name].should be_a(String)
instance[:product_codes].should be_an(Array)
# instance[:product_codes].first.should be_a(String)
instance[:ramdisk_id].should be_a(String)
instance[:reason].should be_a(String)
end
end

View file

@ -13,7 +13,7 @@ describe 'EC2.run_instances' do
actual.body[:group_set].first.should be_a(String)
actual.body[:instances_set].should be_an(Array)
instance = actual.body[:instances_set].first
instance[:ami_launch_index].should be_a(String)
instance[:ami_launch_index].should be_a(Integer)
instance[:dns_name].should be_a(String)
instance[:image_id].should be_a(String)
instance[:instance_id].should be_a(String)
@ -21,6 +21,7 @@ describe 'EC2.run_instances' do
instance[:instance_state][:code].should be_an(Integer)
instance[:instance_state][:name].should be_an(String)
instance[:instance_type].should be_a(String)
instance[:kernel_id].should be_a(String)
# instance[:key_name].should be_a(String)
instance[:launch_time].should be_a(Time)
instance[:monitoring].should be_a(Hash)
@ -28,6 +29,7 @@ describe 'EC2.run_instances' do
instance[:placement].should be_a(Hash)
instance[:placement][:availability_zone].should be_a(String)
instance[:private_dns_name].should be_a(String)
instance[:ramdisk_id].should be_a(String)
instance[:reason].should be_a(String)
actual.body[:owner_id].should be_a(String)
actual.body[:request_id].should be_a(String)