2011-02-20 22:01:28 -05:00
|
|
|
module Fog
|
|
|
|
module Parsers
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
module Voxel
|
2011-02-20 22:01:28 -05:00
|
|
|
|
|
|
|
class ImagesList < Fog::Parsers::Base
|
|
|
|
|
|
|
|
def reset
|
|
|
|
@image = {}
|
2011-02-23 18:00:56 -05:00
|
|
|
@response = { 'images' => [] }
|
2011-02-20 22:01:28 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def start_element(name, attrs = [])
|
|
|
|
super
|
|
|
|
|
|
|
|
case name
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'err'
|
|
|
|
@response['err'] = {
|
|
|
|
'code' => attr_value('code', attrs),
|
|
|
|
'msg' => attr_value('msg', attrs)
|
|
|
|
}
|
|
|
|
when 'size'
|
|
|
|
@image['filesystem']['units'] = attr_value('units', attrs)
|
2011-02-20 22:01:28 -05:00
|
|
|
when 'image'
|
|
|
|
@image = {
|
2011-02-23 18:00:56 -05:00
|
|
|
'id' => attr_value('id', attrs).to_i,
|
|
|
|
'summary' => attr_value('summary', attrs)
|
2011-02-20 22:01:28 -05:00
|
|
|
}
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'filesystem', 'operating_system'
|
|
|
|
@image[name] = {}
|
2011-02-20 22:01:28 -05:00
|
|
|
when 'rsp'
|
2011-02-23 18:00:56 -05:00
|
|
|
@response['stat'] = attr_value('stat', attrs)
|
2011-02-20 22:01:28 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def end_element(name)
|
|
|
|
case name
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'architecture'
|
2011-05-12 16:15:13 -04:00
|
|
|
@image['operating_system'][name] = value.to_i
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'admin_username', 'family', 'product_family', 'product_version', 'version'
|
2011-05-12 16:15:13 -04:00
|
|
|
@image['operating_system'][name] = value
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'description'
|
2011-05-12 16:15:13 -04:00
|
|
|
@image[name] = value
|
2011-02-20 22:01:28 -05:00
|
|
|
when 'image'
|
2011-02-23 18:00:56 -05:00
|
|
|
@response['images'] << @image
|
2011-02-20 22:01:28 -05:00
|
|
|
@image = {}
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'size'
|
2011-05-12 16:15:13 -04:00
|
|
|
@image['filesystem'][name] = value.to_i
|
2011-02-23 18:00:56 -05:00
|
|
|
when 'type'
|
2011-05-12 16:15:13 -04:00
|
|
|
@image['filesystem'][name] = value
|
2011-02-20 22:01:28 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-02-23 18:00:56 -05:00
|
|
|
end
|