2009-07-17 03:36:42 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module AWS
|
|
|
|
module EC2
|
|
|
|
|
|
|
|
class RunInstances < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance = { 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [] }
|
|
|
|
@response = { 'groupSet' => [], 'instancesSet' => [] }
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
|
|
|
if name == 'groupSet'
|
|
|
|
@in_group_set = true
|
|
|
|
elsif name == 'productCodes'
|
|
|
|
@in_product_codes = true
|
|
|
|
end
|
|
|
|
@value = ''
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
|
|
|
when 'amiLaunchIndex'
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance[name] = @value.to_i
|
2009-07-17 03:36:42 -04:00
|
|
|
when 'availabilityZone'
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance['placement'][name] = @value
|
2009-07-19 19:50:19 -04:00
|
|
|
when 'code'
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance['instanceState'][name] = @value.to_i
|
|
|
|
when 'dnsName', 'kernelId', 'keyName', 'imageId', 'instanceId', 'instanceType', 'platform', 'privateDnsName', 'ramdiskId', 'reason', 'requestorId'
|
|
|
|
@instance[name] = @value
|
2009-07-17 03:36:42 -04:00
|
|
|
when 'groupId'
|
2009-08-01 04:15:44 -04:00
|
|
|
@response['groupSet'] << @value
|
2009-07-17 03:36:42 -04:00
|
|
|
when 'groupSet'
|
|
|
|
@in_group_set = false
|
|
|
|
when 'item'
|
|
|
|
unless @in_group_set || @in_product_codes
|
2009-08-01 04:15:44 -04:00
|
|
|
@response['instancesSet'] << @instance
|
|
|
|
@instance = { 'instanceState' => {}, 'monitoring' => {}, 'placement' => {}, 'productCodes' => [] }
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
when 'launchTime'
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance[name] = Time.parse(@value)
|
2009-07-19 19:50:19 -04:00
|
|
|
when 'name'
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance['instanceState'][name] = @value
|
|
|
|
when 'ownerId', 'requestId', 'reservationId'
|
|
|
|
@response[name] = @value
|
2009-07-17 03:36:42 -04:00
|
|
|
when 'product_code'
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance['productCodes'] << @value
|
2009-07-17 03:36:42 -04:00
|
|
|
when 'productCodes'
|
|
|
|
@in_product_codes = false
|
2009-07-17 17:05:05 -04:00
|
|
|
when 'state'
|
|
|
|
if @value == 'true'
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance['monitoring'][name] = true
|
2009-07-17 17:05:05 -04:00
|
|
|
else
|
2009-08-01 04:15:44 -04:00
|
|
|
@instance['monitoring'][name] = false
|
2009-07-17 17:05:05 -04:00
|
|
|
end
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|