2011-12-02 18:27:08 -05:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
|
|
|
module Compute
|
|
|
|
module AWS
|
|
|
|
class DescribeInstanceStatus < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def new_instance
|
2012-02-03 21:56:37 -05:00
|
|
|
@instance = { 'instanceState' => {}, 'systemStatus' => { 'details' => [] }, 'instanceStatus' => { 'details' => [] }, 'event' => {} }
|
2011-12-02 18:27:08 -05:00
|
|
|
end
|
|
|
|
|
2012-02-03 21:56:37 -05:00
|
|
|
def new_item
|
|
|
|
@item = {}
|
2011-12-02 18:27:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@instance_status = {}
|
|
|
|
@response = { 'instanceStatusSet' => [] }
|
2012-02-03 21:56:37 -05:00
|
|
|
@in_system_status = false
|
|
|
|
@in_details = false
|
|
|
|
@in_event = false
|
2011-12-02 18:27:08 -05:00
|
|
|
new_instance
|
2012-02-03 21:56:37 -05:00
|
|
|
new_item
|
2011-12-02 18:27:08 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs=[])
|
|
|
|
super
|
|
|
|
case name
|
2012-02-03 21:56:37 -05:00
|
|
|
when 'systemStatus'
|
|
|
|
@in_system_status = true
|
|
|
|
when 'instanceStatus'
|
|
|
|
@in_instance_status = true
|
|
|
|
when 'details'
|
|
|
|
@in_details = true
|
|
|
|
when 'event'
|
|
|
|
@in_event = true
|
2011-12-02 18:27:08 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
2012-02-03 21:56:37 -05:00
|
|
|
case name
|
|
|
|
when 'name'
|
|
|
|
if @in_details
|
|
|
|
@item[name] = value
|
|
|
|
else
|
2011-12-02 18:27:08 -05:00
|
|
|
@instance['instanceState'][name] = value
|
2012-02-03 21:56:37 -05:00
|
|
|
end
|
|
|
|
when 'status'
|
|
|
|
if @in_details
|
|
|
|
@item[name] = value
|
|
|
|
elsif @in_system_status
|
|
|
|
@instance['systemStatus'][name] = value
|
|
|
|
elsif @in_instance_status
|
|
|
|
@instance['instanceStatus'][name] = value
|
|
|
|
end
|
|
|
|
when 'details'
|
|
|
|
@in_details = false
|
|
|
|
when 'item'
|
|
|
|
if @in_system_status
|
|
|
|
@instance['systemStatus']['details'] << @item
|
|
|
|
elsif @in_instance_status
|
|
|
|
@instance['instanceStatus']['details'] << @item
|
|
|
|
else
|
2011-12-02 18:27:08 -05:00
|
|
|
@response['instanceStatusSet'] << @instance
|
|
|
|
new_instance
|
|
|
|
end
|
2012-02-03 21:56:37 -05:00
|
|
|
new_item
|
|
|
|
when 'instanceStatus'
|
|
|
|
@in_instance_status = false
|
|
|
|
when 'systemStatus'
|
|
|
|
@in_system_status = false
|
|
|
|
when 'code'
|
|
|
|
if @in_event
|
|
|
|
@instance['event'][name] = value.strip
|
|
|
|
else
|
|
|
|
@instance['instanceState'][name] = value
|
|
|
|
end
|
|
|
|
when 'description'
|
|
|
|
if @in_event
|
|
|
|
@instance['event'][name] = value.strip
|
|
|
|
end
|
|
|
|
when 'notAfter', 'notBefore'
|
|
|
|
if @in_event
|
|
|
|
@instance['event'][name] = Time.parse(value)
|
|
|
|
end
|
|
|
|
when 'event'
|
|
|
|
@in_event = false
|
|
|
|
when 'instanceId', 'availabilityZone'
|
|
|
|
@instance[name] = value
|
|
|
|
when 'requestId'
|
|
|
|
@response[name] = value
|
2011-12-02 18:27:08 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|