1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

feature #200 Delete upcase from XMLUtils and XMLElement and XMLPool for Pool

This commit is contained in:
Daniel Molina 2010-07-20 00:34:02 +02:00 committed by Ruben S. Montero
parent 4075bd89ac
commit 5f70d69b55
2 changed files with 5 additions and 27 deletions

View File

@ -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

View File

@ -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