Class OpenNebula::Cluster

  1. OpenNebula/Cluster.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

Methods

public class

  1. build_xml
  2. new

public instance

  1. add_host
  2. allocate
  3. delete
  4. info
  5. remove_host

Constants

CLUSTER_METHODS = { :info => "cluster.info", :allocate => "cluster.allocate", :delete => "cluster.delete", :addhost => "cluster.add", :removehost => "cluster.remove", }  

Constants and Class Methods


Public class methods

build_xml (pe_id=nil)

Creates a Cluster description with just its identifier this method should be used to create plain Cluster objects. id the id of the user

Example:

cluster = Cluster.new(User.build_xml(3),rpc_client)
[show source]
    # File OpenNebula/Cluster.rb, line 39
39:         def Cluster.build_xml(pe_id=nil)
40:             if pe_id
41:                 user_xml = "<CLUSTER><ID>#{pe_id}</ID></CLUSTER>"
42:             else
43:                 user_xml = "<CLUSTER></CLUSTER>"
44:             end
45: 
46:             XMLElement.build_xml(user_xml,'CLUSTER')
47:         end
new (xml, client)

Class constructor


[show source]
    # File OpenNebula/Cluster.rb, line 52
52:         def initialize(xml, client)
53:             super(xml,client)
54: 
55:             @client = client
56:         end

Public instance methods

add_host (host_id)

Add a host to the cluster

host_id ID of the Host to be added to the Cluster

[show source]
    # File OpenNebula/Cluster.rb, line 82
82:         def add_host(host_id)
83:             return Error.new('ID not defined') if !@pe_id
84: 
85:             rc = @client.call(CLUSTER_METHODS[:addhost], host_id.to_i, @pe_id)
86:             rc = nil if !OpenNebula.is_error?(rc)
87: 
88:             return rc
89:         end
allocate (clustername)

Allocates a new Cluster in OpenNebula

clustername A string containing the name of the Cluster.

[show source]
    # File OpenNebula/Cluster.rb, line 70
70:         def allocate(clustername)
71:             super(CLUSTER_METHODS[:allocate], clustername)
72:         end
delete ()

Deletes the Cluster

[show source]
    # File OpenNebula/Cluster.rb, line 75
75:         def delete()
76:             super(CLUSTER_METHODS[:delete])
77:         end
info ()

Retrieves the information of the given Cluster.

[show source]
    # File OpenNebula/Cluster.rb, line 63
63:         def info()
64:             super(CLUSTER_METHODS[:info], 'CLUSTER')
65:         end
remove_host (host_id)

Remove a host from the cluster

host_id ID of the Host to be removed from the Cluster

[show source]
     # File OpenNebula/Cluster.rb, line 94
 94:         def remove_host(host_id)
 95:             return Error.new('ID not defined') if !@pe_id
 96: 
 97:             rc = @client.call(CLUSTER_METHODS[:removehost], host_id.to_i)
 98:             rc = nil if !OpenNebula.is_error?(rc)
 99: 
100:             return rc
101:         end