1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/voxel/parsers/compute/images_list.rb

59 lines
1.6 KiB
Ruby
Raw Normal View History

2011-02-20 22:01:28 -05:00
module Fog
module Parsers
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'
@image['operating_system'][name] = value.to_i
2011-02-23 18:00:56 -05:00
when 'admin_username', 'family', 'product_family', 'product_version', 'version'
@image['operating_system'][name] = value
2011-02-23 18:00:56 -05:00
when 'description'
@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'
@image['filesystem'][name] = value.to_i
2011-02-23 18:00:56 -05:00
when 'type'
@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