Class OpenNebula::PoolElement

  1. OpenNebula/Pool.rb
Pool VirtualNetworkPool ClusterPool ImagePool VirtualMachinePool HostPool UserPool XMLElement PoolElement XMLPool User VirtualNetwork Cluster Image VirtualMachine Host Enumerable Client ImageRepository Error OpenNebula dot/f_0.png

The PoolElement Class represents a generic element of a Pool in XML format

Methods

public class

  1. new
  2. new_with_id

public instance

  1. id
  2. name
  3. to_str

protected instance

  1. allocate
  2. delete
  3. info
  4. update

Public class methods

new (node, client)
node:_XML_is a XML element that represents the Pool element
client:Client represents a XML-RPC connection
[show source]
    # 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
new_with_id (id, client=nil)

Creates new element specifying its id

id:identifyier of the element
client:initialized OpenNebula::Client object
[show source]
     # 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

id ()

Returns element identifier

return
Integer the PoolElement ID
[show source]
     # File OpenNebula/Pool.rb, line 172
172:         def id
173:             @pe_id
174:         end
name ()

Gets element name

return
String the PoolElement name
[show source]
     # File OpenNebula/Pool.rb, line 178
178:         def name
179:             @name
180:         end
to_str ()

DO NOT USE - ONLY REXML BACKEND

[show source]
     # 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

allocate (xml_method, *args)

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
[show source]
     # 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
delete (xml_method)

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
[show source]
     # 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
info (xml_method, root_element)

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
[show source]
     # 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
update (xml_method, name, value)

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
[show source]
     # 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