
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 93 93: def initialize(node, client) 94: @xml = node 95: @client = client 96: @hash = nil 97: 98: if self['ID'] 99: @pe_id = self['ID'].to_i 100: else 101: @pe_id = nil 102: end 103: @name = self['NAME'] if self['NAME'] 104: end
Creates new element specifying its id
id: | identifyier of the element |
client: | initialized OpenNebula::Client object |
# File OpenNebula/Pool.rb, line 181 181: def self.new_with_id(id, client=nil) 182: self.new(self.build_xml(id), client) 183: end
Public instance methods
Returns element identifier
- return
- Integer the PoolElement ID
# File OpenNebula/Pool.rb, line 187 187: def id 188: @pe_id 189: end
Gets element name
- return
- String the PoolElement name
# File OpenNebula/Pool.rb, line 193 193: def name 194: @name 195: end
DO NOT USE - ONLY REXML BACKEND
# File OpenNebula/Pool.rb, line 198 198: def to_str 199: str = "" 200: REXML::Formatters::Pretty.new(1).write(@xml,str) 201: 202: return str 203: 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 137 137: def allocate(xml_method, *args) 138: rc = @client.call(xml_method, *args) 139: 140: if !OpenNebula.is_error?(rc) 141: @pe_id = rc 142: rc = nil 143: end 144: 145: return rc 146: 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 167 167: def delete(xml_method) 168: return Error.new('ID not defined') if !@pe_id 169: 170: rc = @client.call(xml_method,@pe_id) 171: rc = nil if !OpenNebula.is_error?(rc) 172: 173: return rc 174: 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 115 115: def info(xml_method, root_element) 116: return Error.new('ID not defined') if !@pe_id 117: 118: rc = @client.call(xml_method,@pe_id) 119: 120: if !OpenNebula.is_error?(rc) 121: initialize_xml(rc, root_element) 122: rc = nil 123: 124: @pe_id = self['ID'].to_i if self['ID'] 125: @name = self['NAME'] if self['NAME'] 126: end 127: 128: return rc 129: 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 154 154: def update(xml_method, name, value) 155: return Error.new('ID not defined') if !@pe_id 156: 157: rc = @client.call(xml_method,@pe_id, name, value) 158: rc = nil if !OpenNebula.is_error?(rc) 159: 160: return rc 161: end