2009-07-11 16:41:21 -04:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
module AWS
|
2009-07-11 16:41:21 -04:00
|
|
|
class DescribeVolumes < Fog::Parsers::Base
|
|
|
|
def reset
|
|
|
|
@attachment = {}
|
|
|
|
@in_attachment_set = false
|
2009-08-01 04:15:44 -04:00
|
|
|
@response = { 'volumeSet' => [] }
|
2010-10-13 17:01:56 -04:00
|
|
|
@tag = {}
|
|
|
|
@volume = { 'attachmentSet' => [], 'tagSet' => {} }
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
2010-05-05 16:39:41 -04:00
|
|
|
super
|
2010-10-12 14:00:59 -04:00
|
|
|
case name
|
|
|
|
when 'attachmentSet'
|
2009-07-11 16:41:21 -04:00
|
|
|
@in_attachment_set = true
|
2010-10-12 14:00:59 -04:00
|
|
|
when 'tagSet'
|
|
|
|
@in_tag_set = true
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
if @in_attachment_set
|
|
|
|
case name
|
|
|
|
when 'attachmentSet'
|
|
|
|
@in_attachment_set = false
|
|
|
|
when 'attachTime'
|
2011-05-12 16:15:13 -04:00
|
|
|
@attachment[name] = Time.parse(value)
|
2010-11-15 14:49:16 -05:00
|
|
|
when 'deleteOnTermination'
|
2011-05-12 16:15:13 -04:00
|
|
|
@attachment[name] = value == 'true'
|
2009-08-01 04:15:44 -04:00
|
|
|
when 'device', 'instanceId', 'status', 'volumeId'
|
2011-05-12 16:15:13 -04:00
|
|
|
@attachment[name] = value
|
2009-07-11 16:41:21 -04:00
|
|
|
when 'item'
|
2009-08-01 04:15:44 -04:00
|
|
|
@volume['attachmentSet'] << @attachment
|
2009-07-11 16:41:21 -04:00
|
|
|
@attachment = {}
|
|
|
|
end
|
2010-10-12 14:00:59 -04:00
|
|
|
elsif @in_tag_set
|
|
|
|
case name
|
|
|
|
when 'key', 'value'
|
2011-05-12 16:15:13 -04:00
|
|
|
@tag[name] = value
|
2010-10-12 14:00:59 -04:00
|
|
|
when 'item'
|
|
|
|
@volume['tagSet'][@tag['key']] = @tag['value']
|
2010-10-13 17:01:56 -04:00
|
|
|
@tag = {}
|
2010-10-12 14:00:59 -04:00
|
|
|
when 'tagSet'
|
|
|
|
@in_tag_set = false
|
|
|
|
end
|
2009-07-11 16:41:21 -04:00
|
|
|
else
|
|
|
|
case name
|
2012-08-01 09:56:22 -04:00
|
|
|
when 'availabilityZone', 'snapshotId', 'status', 'volumeId', 'volumeType'
|
2011-05-12 16:15:13 -04:00
|
|
|
@volume[name] = value
|
2009-07-11 16:41:21 -04:00
|
|
|
when 'createTime'
|
2011-05-12 16:15:13 -04:00
|
|
|
@volume[name] = Time.parse(value)
|
2009-07-11 16:41:21 -04:00
|
|
|
when 'item'
|
2009-08-01 04:15:44 -04:00
|
|
|
@response['volumeSet'] << @volume
|
2010-10-13 17:01:56 -04:00
|
|
|
@volume = { 'attachmentSet' => [], 'tagSet' => {} }
|
2009-07-11 16:41:21 -04:00
|
|
|
when 'requestId'
|
2011-05-12 16:15:13 -04:00
|
|
|
@response[name] = value
|
2012-08-01 09:56:22 -04:00
|
|
|
when 'size', 'iops'
|
2011-05-12 16:15:13 -04:00
|
|
|
@volume[name] = value.to_i
|
2009-07-11 16:41:21 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|