Class: OpenNebula::VirtualMachinePool

Inherits:
Pool show all
Defined in:
lib/OpenNebula/VirtualMachinePool.rb

Constant Summary collapse

VM_POOL_METHODS =

Constants and Class attribute accessors

{
    :info => "vmpool.info"
}
INFO_NOT_DONE =

Constants for info queries (include/RequestManagerPoolInfoFilter.h)

-1
INFO_ALL_VM =
-2

Constants inherited from Pool

Pool::INFO_ALL, Pool::INFO_GROUP, Pool::INFO_MINE

Instance Method Summary collapse

Methods inherited from Pool

#each, #to_str

Methods inherited from XMLPool

#each_element

Methods inherited from XMLElement

#[], #attr, build_xml, #each, #each_xpath, #has_elements?, #initialize_xml, #name, #retrieve_elements, #template_like_str, #template_str, #text, #to_hash, #to_xml

Constructor Details

#initialize(client, user_id = 0) ⇒ VirtualMachinePool

client a Client object that represents a XML-RPC connection user_id is to refer to a Pool with VirtualMachines from that user



39
40
41
42
43
# File 'lib/OpenNebula/VirtualMachinePool.rb', line 39

def initialize(client, user_id=0)
    super('VM_POOL','VM',client)

    @user_id  = user_id
end

Instance Method Details

#factory(element_xml) ⇒ Object

Default Factory Method for the Pools



46
47
48
# File 'lib/OpenNebula/VirtualMachinePool.rb', line 46

def factory(element_xml)
    OpenNebula::VirtualMachine.new(element_xml,@client)
end

#info(*args) ⇒ Object

Retrieves all or part of the VirtualMachines in the pool. No arguments, returns the not-in-done VMs for the user

user_id, start_id, end_id
user_id, start_id, end_id, state


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/OpenNebula/VirtualMachinePool.rb', line 58

def info(*args)
    case args.size
        when 0
            info_filter(VM_POOL_METHODS[:info],
                        @user_id,
                        -1,
                        -1,
                        INFO_NOT_DONE)
        when 1
            info_filter(VM_POOL_METHODS[:info],
                        args[0],
                        -1,
                        -1,
                        INFO_NOT_DONE)
        when 3
            info_filter(VM_POOL_METHODS[:info],
                        args[0],
                        args[1],
                        args[2],
                        INFO_NOT_DONE)
        when 4
            info_filter(VM_POOL_METHODS[:info],
                        args[0],
                        args[1],
                        args[2],
                        args[3])
    end
end

#info_allObject



87
88
89
90
91
92
93
# File 'lib/OpenNebula/VirtualMachinePool.rb', line 87

def info_all()
    return info_filter(VM_POOL_METHODS[:info],
                       INFO_ALL,
                       -1,
                       -1,
                       INFO_NOT_DONE)
end

#info_groupObject



103
104
105
106
107
108
109
# File 'lib/OpenNebula/VirtualMachinePool.rb', line 103

def info_group()
    return info_filter(VM_POOL_METHODS[:info],
                       INFO_GROUP,
                       -1,
                       -1,
                       INFO_NOT_DONE)
end

#info_mineObject



95
96
97
98
99
100
101
# File 'lib/OpenNebula/VirtualMachinePool.rb', line 95

def info_mine()
    return info_filter(VM_POOL_METHODS[:info],
                       INFO_MINE,
                       -1,
                       -1,
                       INFO_NOT_DONE)
end