From 5f70d69b55bdb49d29c44b58e276d57e67dccdcb Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 20 Jul 2010 00:34:02 +0200 Subject: [PATCH] feature #200 Delete upcase from XMLUtils and XMLElement and XMLPool for Pool --- src/oca/ruby/OpenNebula/Pool.rb | 4 +++- src/oca/ruby/OpenNebula/XMLUtils.rb | 28 ++-------------------------- 2 files changed, 5 insertions(+), 27 deletions(-) diff --git a/src/oca/ruby/OpenNebula/Pool.rb b/src/oca/ruby/OpenNebula/Pool.rb index f2138abf2e..f9636eca3e 100644 --- a/src/oca/ruby/OpenNebula/Pool.rb +++ b/src/oca/ruby/OpenNebula/Pool.rb @@ -2,8 +2,10 @@ module OpenNebula # The Pool class represents a generic OpenNebula Pool in XML format # and provides the basic functionality to handle the Pool elements + require 'pp' class Pool include Enumerable + include XMLUtilsElement include XMLUtilsPool protected @@ -42,7 +44,7 @@ module OpenNebula rc = @client.call(xml_method,*args) if !OpenNebula.is_error?(rc) - @xml = initialize_xml(rc) + @xml = XMLUtilsElement::initialize_xml(rc,@pool_name) rc = nil end diff --git a/src/oca/ruby/OpenNebula/XMLUtils.rb b/src/oca/ruby/OpenNebula/XMLUtils.rb index 2163eb5c10..c0c9dca0ff 100644 --- a/src/oca/ruby/OpenNebula/XMLUtils.rb +++ b/src/oca/ruby/OpenNebula/XMLUtils.rb @@ -48,12 +48,12 @@ module OpenNebula # ['HISTORY/HOSTNAME'] # get the hostname from the history def [](key) if NOKOGIRI - element=@xml.xpath(key.to_s.upcase) + element=@xml.xpath(key.to_s) if element.size == 0 return nil end else - element=@xml.elements[key.to_s.upcase] + element=@xml.elements[key.to_s] end if element @@ -177,17 +177,6 @@ module OpenNebula ########################################################################### module XMLUtilsPool - #Initialize a XML document for the element - #xml:: _String_ the XML document of the object - #[return] _XML_ object for the underlying XML engine - def initialize_xml(xml) - if NOKOGIRI - Nokogiri::XML(xml).xpath("/#{@pool_name}") - else - xml=REXML::Document.new(xml).root - end - end - #Executes the given block for each element of the Pool #block:: _Block_ def each_element(block) @@ -204,19 +193,6 @@ module OpenNebula end end - def to_xml(pretty=false) - if NOKOGIRI - @xml.to_xml - else - str = "" - if pretty - REXML::Formatters::Pretty.new(1).write(@xml,str) - else - REXML::Formatters::Default.new.write(@xml,str) - end - str - end - end def to_hash if !@hash && @xml