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