
The PoolElement Class represents a generic element of a Pool in XML format
Methods
public class
public instance
protected instance
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 78 78: def initialize(node, client) 79: @xml = node 80: @client = client 81: @hash = nil 82: 83: if self['ID'] 84: @pe_id = self['ID'].to_i 85: else 86: @pe_id = nil 87: end 88: @name = self['NAME'] if self['NAME'] 89: end
Creates new element specifying its id
id: | identifyier of the element |
client: | initialized OpenNebula::Client object |
# File OpenNebula/Pool.rb, line 166 166: def self.new_with_id(id, client=nil) 167: self.new(self.build_xml(id), client) 168: end
Public instance methods
Returns element identifier
- return
- Integer the PoolElement ID
# File OpenNebula/Pool.rb, line 172 172: def id 173: @pe_id 174: end
Gets element name
- return
- String the PoolElement name
# File OpenNebula/Pool.rb, line 178 178: def name 179: @name 180: end
DO NOT USE - ONLY REXML BACKEND
# File OpenNebula/Pool.rb, line 183 183: def to_str 184: str = "" 185: REXML::Formatters::Pretty.new(1).write(@xml,str) 186: 187: return str 188: 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 122 122: def allocate(xml_method, *args) 123: rc = @client.call(xml_method, *args) 124: 125: if !OpenNebula.is_error?(rc) 126: @pe_id = rc 127: rc = nil 128: end 129: 130: return rc 131: 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 152 152: def delete(xml_method) 153: return Error.new('ID not defined') if !@pe_id 154: 155: rc = @client.call(xml_method,@pe_id) 156: rc = nil if !OpenNebula.is_error?(rc) 157: 158: return rc 159: 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 100 100: def info(xml_method, root_element) 101: return Error.new('ID not defined') if !@pe_id 102: 103: rc = @client.call(xml_method,@pe_id) 104: 105: if !OpenNebula.is_error?(rc) 106: initialize_xml(rc, root_element) 107: rc = nil 108: 109: @pe_id = self['ID'].to_i if self['ID'] 110: @name = self['NAME'] if self['NAME'] 111: end 112: 113: return rc 114: end
Calls to the corresponding update method to modify the object’s template
xml_method: | String the name of the XML-RPC method |
name: | String the name of the property to be modified |
value: | String the new value of the property to be modified |
- return
- nil in case of success or an Error object
# File OpenNebula/Pool.rb, line 139 139: def update(xml_method, name, value) 140: return Error.new('ID not defined') if !@pe_id 141: 142: rc = @client.call(xml_method,@pe_id, name, value) 143: rc = nil if !OpenNebula.is_error?(rc) 144: 145: return rc 146: end