Class OpenNebula::Pool

  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 Pool class represents a generic OpenNebula Pool in XML format and provides the basic functionality to handle the Pool elements

Methods

public class

  1. new

public instance

  1. each
  2. to_str

protected instance

  1. factory
  2. info

Included modules

  1. Enumerable

Public class methods

new (pool,element,client)
pool:String XML name of the root element
element:String XML name of the Pool elements
client:Client represents a XML-RPC connection
[show source]
    # File OpenNebula/Pool.rb, line 14
14:         def initialize(pool,element,client)
15:             super(nil)
16: 
17:             @pool_name    = pool.upcase
18:             @element_name = element.upcase
19: 
20:             @client = client
21:             @hash   = nil
22:         end

Public instance methods

each (&block)

Iterates over every PoolElement in the Pool and calls the block with a a PoolElement obtained calling the factory method

block:Block
[show source]
    # File OpenNebula/Pool.rb, line 58
58:         def each(&block)
59:             each_element(block) if @xml
60:         end
to_str ()

DO NOT USE - ONLY REXML BACKEND

[show source]
    # File OpenNebula/Pool.rb, line 63
63:         def to_str
64:             str = ""
65:             REXML::Formatters::Pretty.new(1).write(@xml,str)
66: 
67:             return str
68:         end

Protected instance methods

factory (element_xml)

Default Factory Method for the Pools. The factory method returns an suitable PoolElement object. Each Pool MUST implement the corresponding factory method

element_xml:XML XML element describing the pool element
return
a PoolElement object
[show source]
    # File OpenNebula/Pool.rb, line 29
29:         def factory(element_xml)
30:             OpenNebula::PoolElement.new(element_xml,client)
31:         end
info (xml_method,*args)

Calls to the corresponding info method to retreive the pool representation in XML format

xml_method:String the name of the XML-RPC method
args:Array with additional arguments for the info call
return
nil in case of success or an Error object
[show source]
    # File OpenNebula/Pool.rb, line 42
42:         def info(xml_method,*args)
43:             rc = @client.call(xml_method,*args)
44: 
45:             if !OpenNebula.is_error?(rc)
46:                 initialize_xml(rc,@pool_name)
47:                 rc   = nil
48:             end
49: 
50:             return rc
51:         end