Module: Zona
- Defined in:
- zona.rb,
zona/VDCPool.rb,
zona/ZonePool.rb,
zona/OZonesPool.rb,
zona/OZonesJSON.rb,
zona/VDCElement.rb,
zona/ZoneElement.rb,
zona/OZonesElement.rb
Overview
This module contains all the OZones API related classes and utilities.
Defined Under Namespace
Classes: Client, Error, JSONElement, JSONPool, OZonesElement, OZonesJSON, OZonesPool, VDC, VDCPool, Zone, ZonePool
Class Method Summary (collapse)
-
+ (Boolean) is_error?(value)
Returns true if instance of Error.
-
+ (Boolean) is_http_error?(value)
Returns true if HTTP return code is not OK.
-
+ (String, Zona::Error) parse_template(kind, tmpl_str)
Parses a OpenNebula template string and turns it into a JSON string.
Class Method Details
+ (Boolean) is_error?(value)
Returns true if instance of Error
324 325 326 |
# File 'zona.rb', line 324 def self.is_error?(value) value.class==Zona::Error end |
+ (Boolean) is_http_error?(value)
Returns true if HTTP return code is not OK
329 330 331 |
# File 'zona.rb', line 329 def self.is_http_error?(value) value.class != Net::HTTPOK end |
+ (String, Zona::Error) parse_template(kind, tmpl_str)
Parses a OpenNebula template string and turns it into a JSON string
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'zona.rb', line 305 def self.parse_template(kind, tmpl_str) name_reg =/[\w\d_-]+/ variable_reg =/\s*(#{name_reg})\s*=\s*/ single_variable_reg =/^#{variable_reg}([^\[]+?)(#.*)?$/ tmpl = Hash.new tmpl_str.scan(single_variable_reg) do | m | key = m[0].strip.upcase value = m[1].strip tmpl[key] = value end res = { "#{kind.upcase}" => tmpl } return OZonesJSON.to_json(res) end |