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

fixes for describe_instances, unfortunately sax is choking

This commit is contained in:
Wesley Beary 2009-07-19 21:46:45 -07:00
parent 17edeac776
commit 76e476c4d9
2 changed files with 30 additions and 13 deletions

View file

@ -6,19 +6,15 @@ module Fog
class DescribeInstances < Fog::Parsers::Base
def reset
@instance = { :instance_state => {}, :placement => [], :product_code_set => [] }
@instance = { :instance_state => {}, :monitoring => {}, :placement => [], :product_codes => [] }
@reservation = { :group_set => [], :instances_set => [] }
@response = { :reservation_set => [] }
end
def start_element(name, attrs = [])
if name == 'groupSet'
if name == 'groupSet' || name == 'productCodes'
@in_subset = true
end
if name == 'productCodeSet'
@in_subset = true
end
if name == 'instanceSet'
elsif name == 'instancesSet'
@in_instances_set = true
end
@value = ''
@ -32,7 +28,7 @@ module Fog
@instance[:placement] << @value
when 'code'
@instance[:instance_state][:code] = @value
when 'dnsNmae'
when 'dnsName'
@instance[:dns_name] = @value
when 'groupId'
@reservation[:group_set] << @value
@ -49,10 +45,10 @@ module Fog
when 'item'
if @in_instances_set
@reservation[:instances_set] << @instance
@instance = { :instance_state => {}, :placement => [], :product_code_set => [] }
@instance = { :instance_state => {}, :monitoring => {}, :placement => [], :product_codes => [] }
elsif !@in_subset
@response[:reservation_set] << @reservation
@reservation = { :group_set => [], :instance_set => [] }
@reservation = { :group_set => [], :instances_set => [] }
end
when 'kernelId'
@instance[:kernel_id] = @value
@ -64,6 +60,10 @@ module Fog
@instance[:instance_state][:name] = @value
when 'ownerId'
@reservation[:owner_id] = @value
when 'ramdiskId'
@instance[:ramdisk_id] = @value
when 'reason'
@instance[:reason] = @value
when 'requestId'
@response[:request_id] = @value
when 'reservationId'
@ -71,11 +71,17 @@ module Fog
when 'privateDnsName'
@instance[:private_dns_name] = @value
when 'productCode'
@instance[:product_code_set] << @value
when 'productCodeSet'
@instance[:product_codes] << @value
when 'productCodes'
@in_subset = false
when 'ramdiskId'
@instance[:ramdisk_id] = @value
when 'state'
if @value == 'true'
@instance[:monitoring][:state] = true
else
@instance[:monitoring][:state] = false
end
end
end

View file

@ -2,10 +2,21 @@ require File.dirname(__FILE__) + '/../../spec_helper'
describe 'EC2.describe_instances' do
before(:all) do
run_instances = ec2.run_instances('ami-5ee70037', 1, 1).body
@instance_id = run_instances[:instances_set].first[:instance_id]
@reservation_id = run_instances[:reservation_id]
end
after(:all) do
ec2.terminate_instances([@instance_id])
end
it "should return proper attributes with no params" do
pending
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}
end
it "should return proper attributes with params"