38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/awsum/ec2/parsers/instance_parser.rb', line 38
def tag_end(tag)
case tag
when 'DescribeInstancesResponse', 'requestId', 'reservationId'
when 'reservationSet', 'instancesSet', 'productCodes', 'instanceState', 'placement', 'blockDeviceMapping', 'tagSet'
@stack.pop
when 'item'
case @stack[-1]
when 'instancesSet'
@instances << Instance.new(
@ec2,
@current['instanceId'],
@current['imageId'],
@current['instanceType'],
State.new(@state[:code], @state[:name]),
@current['dnsName'],
@current['privateDnsName'],
@current['keyName'],
@current['kernalId'],
Time.parse(@current['launchTime']),
@placement,
@product_codes || [],
@current['ramdisk_id'],
@current['reason'],
@current['amiLaunchIndex'].to_i
)
end
when 'productCode'
@product_codes << @text.strip
when 'availabilityZone'
@placement = @text.strip
when 'code'
@state[:code] = @text.strip.to_i if @stack[-1] == 'instanceState'
when 'name'
@state[:name] = @text.strip if @stack[-1] == 'instanceState'
else
case @stack[-1]
when 'blockDeviceMapping'
unless @text.nil? || @blockDeviceMapping.nil?
text = @text.strip
@blockDeviceMapping[tag] = (text == '' ? nil : text)
end
when 'tagSet'
unless @text.nil? || @blockDeviceMapping.nil?
text = @text.strip
@blockDeviceMapping[tag] = (text == '' ? nil : text)
end
else
unless @text.nil? || @current.nil?
text = @text.strip
@current[tag] = (text == '' ? nil : text)
end
end
end
end
|