2009-07-17 03:36:42 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
module AWS
|
2009-07-17 03:36:42 -04:00
|
|
|
|
|
|
|
class TerminateInstances < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
2010-01-26 01:46:18 -05:00
|
|
|
@instance = { 'previousState' => {}, 'currentState' => {} }
|
2009-08-01 04:15:44 -04:00
|
|
|
@response = { 'instancesSet' => [] }
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
2010-05-05 16:39:41 -04:00
|
|
|
super
|
2009-07-17 03:36:42 -04:00
|
|
|
if name == 'previousState'
|
|
|
|
@in_previous_state = true
|
2010-01-26 01:46:18 -05:00
|
|
|
elsif name == 'currentState'
|
|
|
|
@in_current_state = true
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
2009-07-19 19:50:19 -04:00
|
|
|
when 'instanceId'
|
2011-05-12 16:15:13 -04:00
|
|
|
@instance[name] = value
|
2009-07-17 03:36:42 -04:00
|
|
|
when 'item'
|
2009-08-01 04:15:44 -04:00
|
|
|
@response['instancesSet'] << @instance
|
2010-01-26 01:46:18 -05:00
|
|
|
@instance = { 'previousState' => {}, 'currentState' => {} }
|
2009-07-17 03:36:42 -04:00
|
|
|
when 'code'
|
|
|
|
if @in_previous_state
|
2011-05-12 16:15:13 -04:00
|
|
|
@instance['previousState'][name] = value.to_i
|
2010-01-26 01:46:18 -05:00
|
|
|
elsif @in_current_state
|
2011-05-12 16:15:13 -04:00
|
|
|
@instance['currentState'][name] = value.to_i
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
when 'name'
|
|
|
|
if @in_previous_state
|
2011-05-12 16:15:13 -04:00
|
|
|
@instance['previousState'][name] = value
|
2010-01-26 01:46:18 -05:00
|
|
|
elsif @in_current_state
|
2011-05-12 16:15:13 -04:00
|
|
|
@instance['currentState'][name] = value
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
when 'previousState'
|
|
|
|
@in_previous_state = false
|
|
|
|
when 'requestId'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2010-01-26 01:46:18 -05:00
|
|
|
when 'currentState'
|
|
|
|
@in_current_state = false
|
2009-07-17 03:36:42 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|