The PoolElement Class represents a generic element of a Pool in XML format
Methods
public class
public instance
protected instance
Included modules
Public class methods
node: | _XML_is a XML element that represents the Pool element |
client: | Client represents a XML-RPC connection |
# File OpenNebula/Pool.rb, line 77 def initialize(node, client) @xml = node @client = client if self['ID'] @pe_id = self['ID'].to_i else @pe_id = nil end @name = self['NAME'] if self['NAME'] end
Creates new element specifying its id
id: | identifyier of the element |
client: | initialized OpenNebula::Client object |
# File OpenNebula/Pool.rb, line 149 def self.new_with_id(id, client=nil) self.new(self.build_xml(id), client) end
Public instance methods
Returns element identifier
- return
- Integer the PoolElement ID
# File OpenNebula/Pool.rb, line 155 def id @pe_id end
Gets element name
- return
- String the PoolElement name
# File OpenNebula/Pool.rb, line 161 def name @name end
DO NOT USE - ONLY REXML BACKEND
# File OpenNebula/Pool.rb, line 166 def to_str str = "" REXML::Formatters::Pretty.new(1).write(@xml,str) return str end
Protected instance methods
Calls to the corresponding allocate method to create a new element in the OpenNebula core
xml_method: | String the name of the XML-RPC method |
args: | Array additional arguments including the template for the
new element |
- return
- nil in case of success or an Error object
# File OpenNebula/Pool.rb, line 120 def allocate(xml_method, *args) rc = @client.call(xml_method, *args) if !OpenNebula.is_error?(rc) @pe_id = rc rc = nil end return rc end
Calls to the corresponding delete method to remove this element from the OpenNebula core
xml_method: | String the name of the XML-RPC method |
- return
- nil in case of success or an Error object
# File OpenNebula/Pool.rb, line 135 def delete(xml_method) return Error.new('ID not defined') if !@pe_id rc = @client.call(xml_method,@pe_id) rc = nil if !OpenNebula.is_error?(rc) return rc end
Calls to the corresponding info method to retreive the element detailed information in XML format
xml_method: | String the name of the XML-RPC method |
root_element: | String Base XML element |
- return
- nil in case of success or an Error object
# File OpenNebula/Pool.rb, line 98 def info(xml_method, root_element) return Error.new('ID not defined') if !@pe_id rc = @client.call(xml_method,@pe_id) if !OpenNebula.is_error?(rc) @xml = XMLUtilsElement::initialize_xml(rc, root_element) rc = nil @pe_id = self['ID'].to_i if self['ID'] @name = self['NAME'] if self['NAME'] end return rc end