Class: Fog::Parsers::Compute::Voxel::DevicesList
- Inherits:
-
Base
- Object
- Nokogiri::XML::SAX::Document
- Base
- Fog::Parsers::Compute::Voxel::DevicesList
- Defined in:
- lib/fog/compute/parsers/voxel/devices_list.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#attr_value, #characters, #initialize, #value
Constructor Details
This class inherits a constructor from Fog::Parsers::Base
Instance Method Details
#end_element(name) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/fog/compute/parsers/voxel/devices_list.rb', line 69 def end_element(name) case name when 'access_method' @device['access_methods'] << @access_method when 'architecture' @device['operating_system'][name] = value.to_i when 'cage', 'facility', 'rack', 'row', 'zone' @device['location'][name]['value'] = value when 'cores' @device['processor'][name] = value.to_i when 'description' @device[name] = value when 'device' @response['devices'] << @device @device = {} when 'drive' @device['drives'] << @drive @drive = {} when 'cores' @device['processing_cores'] = value.to_i when 'ipassignment' @device['ipassignments'].last['value'] = value when 'model', 'type' @device[name]['value'] = value when 'name' @device['operating_system'][name] = value when 'position' @device['location'][name] = value when 'power_consumption' @device[name] = [value, @device[name]].join(' ') when 'size' @drive[name] = value.to_i when 'host', 'password', 'protocol', 'username' @access_method[name] = value end end |
#reset ⇒ Object
8 9 10 11 12 |
# File 'lib/fog/compute/parsers/voxel/devices_list.rb', line 8 def reset @device = {} @response = { 'devices' => [] } @in_storage = false end |
#start_element(name, attrs = []) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fog/compute/parsers/voxel/devices_list.rb', line 14 def start_element(name, attrs = []) super case name when 'accessmethod' @access_method = { 'type' => attr_value('type', attrs) } when 'accessmethods' @device['access_methods'] = [] when 'device' @device = { 'id' => attr_value('id', attrs), 'label' => attr_value('label', attrs), 'status' => attr_value('status', attrs) } when 'err' @response['err'] = { 'code' => attr_value('code', attrs), 'msg' => attr_value('msg', attrs) } when 'cage', 'facility', 'rack', 'row', 'zone' @device['location'][name] = { 'id' => attr_value('id', attrs) } if code = attr_value('code', attrs) @device['location'][name]['code'] = code end when 'drive' @drive = { 'position' => attr_value('position', attrs) } when 'ipassignment' type = attr_value('type', attrs) @device['ipassignments'] = [] @device['ipassignments'] << { 'id' => attr_value('id', attrs), 'type' => attr_value('type', attrs), 'description' => attr_value('description', attrs), } when 'ipassignments' @device['ipassignments'] = {} when 'location' @device['location'] = {} when 'memory' @device['memory'] = { 'size' => attr_value('size', attrs).to_i } when 'model', 'type' @device[name] = { 'id' => attr_value('id', attrs) } when 'operating_system' @device['operating_system'] = {} when 'power_consumption' @device[name] = attr_value('unit', attrs) when 'processor' @device['processor'] = {} when 'rsp' @response['stat'] = attr_value('stat', attrs) when 'storage' @device['drives'] = [] end end |