class OpenNebula::Cluster
Constants
- CLUSTER_METHODS
-
Constants and Class Methods
- PLAN_STATE
Public Class Methods
Source
# File lib/opennebula/cluster.rb, line 52 def Cluster.build_xml(pe_id=nil) if pe_id cluster_xml = "<CLUSTER><ID>#{pe_id}</ID></CLUSTER>" else cluster_xml = "<CLUSTER></CLUSTER>" end XMLElement.build_xml(cluster_xml,'CLUSTER') end
Creates a Cluster
description with just its identifier this method should be used to create plain Cluster
objects. id
the id of the host
Example:
cluster = Cluster.new(Cluster.build_xml(3),rpc_client)
Source
# File lib/opennebula/cluster.rb, line 63 def initialize(xml, client) super(xml,client) end
Class constructor
Public Instance Methods
Source
# File lib/opennebula/cluster.rb, line 120 def adddatastore(ds_id) return Error.new('ID not defined') if !@pe_id rc = @client.call(CLUSTER_METHODS[:adddatastore], @pe_id, ds_id) rc = nil if !OpenNebula.is_error?(rc) return rc end
Adds a Datastore
to this Cluster
@param ds_id [Integer] Datastore
ID @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 94 def addhost(hid) return Error.new('ID not defined') if !@pe_id rc = @client.call(CLUSTER_METHODS[:addhost], @pe_id, hid) rc = nil if !OpenNebula.is_error?(rc) return rc end
Adds a Host
to this Cluster
@param hid [Integer] Host
ID @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 146 def addvnet(vnet_id) return Error.new('ID not defined') if !@pe_id rc = @client.call(CLUSTER_METHODS[:addvnet], @pe_id, vnet_id) rc = nil if !OpenNebula.is_error?(rc) return rc end
Adds a VNet to this Cluster
@param vnet_id [Integer] VNet ID @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 81 def allocate(clustername) super(CLUSTER_METHODS[:allocate], clustername) end
Allocates a new Cluster
in OpenNebula
clustername
A string containing the name of the Cluster
.
Source
# File lib/opennebula/cluster.rb, line 240 def contains_datastore?(id) contains_resource?('DATASTORES/ID', id) end
Returns whether or not the datastore with ‘id’ is part of this cluster @param id [Integer|Array] datastore ID @return [Boolean] true if found
Source
# File lib/opennebula/cluster.rb, line 221 def contains_host?(id) contains_resource?('HOSTS/ID', id) end
Returns whether or not the host with ‘id’ is part of this cluster @param id [Integer|Array] host ID @return [Boolean] true if found
Source
# File lib/opennebula/cluster.rb, line 259 def contains_vnet?(id) contains_resource?('VNETS/ID', id) end
Returns whether or not the vnet with ‘id’ is part of this cluster @param id [Integer|Arrray] vnet ID @return [Boolean] true if found
Source
# File lib/opennebula/cluster.rb, line 246 def datastore_ids array = Array.new self.each("DATASTORES/ID") do |id| array << id.text.to_i end return array end
Returns an array with the numeric datastore ids @return [Array<Integer>]
Source
# File lib/opennebula/cluster.rb, line 133 def deldatastore(ds_id) return Error.new('ID not defined') if !@pe_id rc = @client.call(CLUSTER_METHODS[:deldatastore], @pe_id, ds_id) rc = nil if !OpenNebula.is_error?(rc) return rc end
Deletes a Datastore
from this Cluster
@param ds_id [Integer] Datastore
ID @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 86 def delete() super(CLUSTER_METHODS[:delete]) end
Deletes the Cluster
Source
# File lib/opennebula/cluster.rb, line 107 def delhost(hid) return Error.new('ID not defined') if !@pe_id rc = @client.call(CLUSTER_METHODS[:delhost], @pe_id, hid) rc = nil if !OpenNebula.is_error?(rc) return rc end
Deletes a Host
from this Cluster
@param hid [Integer] Host
ID @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 159 def delvnet(vnet_id) return Error.new('ID not defined') if !@pe_id rc = @client.call(CLUSTER_METHODS[:delvnet], @pe_id, vnet_id) rc = nil if !OpenNebula.is_error?(rc) return rc end
Deletes a VNet from this Cluster
@param vnet_id [Integer] VNet ID @return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 227 def host_ids array = Array.new self.each("HOSTS/ID") do |id| array << id.text.to_i end return array end
Returns an array with the numeric host ids @return [Array<Integer>]
Source
# File lib/opennebula/cluster.rb, line 72 def info(decrypt = false) super(CLUSTER_METHODS[:info], 'CLUSTER', decrypt) end
Retrieves the information of the given Cluster
.
Source
# File lib/opennebula/cluster.rb, line 194 def optimize() return call(CLUSTER_METHODS[:optimize], @pe_id) end
Create optimization plan for the Cluster
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 285 def plan_actions [self.to_hash['CLUSTER']['PLAN']['ACTION']].flatten end
Returns an array plan actions @return [Array<PlanAction>]
Source
# File lib/opennebula/cluster.rb, line 210 def plan_delete() return call(CLUSTER_METHODS[:plandelete], @pe_id) end
Delete optimization plan for the Cluster
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 202 def plan_execute() return call(CLUSTER_METHODS[:planexecute], @pe_id) end
Start applying the optimization plan for the Cluster
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 277 def plan_state state = self['PLAN/STATE'] || -1 state.to_i end
Returns state of optimization plan @return [Integer] -1 if no plan
Source
# File lib/opennebula/cluster.rb, line 186 def rename(name) return call(CLUSTER_METHODS[:rename], @pe_id, name) end
Renames this Cluster
@param name [String] New name for the Cluster
.
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 176 def update(new_template, append=false) super(CLUSTER_METHODS[:update], new_template, append ? 1 : 0) end
Replaces the template contents
@param new_template [String] New template contents @param append [true, false] True to append new attributes instead of
replace the whole template
@return [nil, OpenNebula::Error
] nil in case of success, Error
otherwise
Source
# File lib/opennebula/cluster.rb, line 265 def vnet_ids array = Array.new self.each("VNETS/ID") do |id| array << id.text.to_i end return array end
Returns an array with the numeric vnet ids @return [Array<Integer>]
Private Instance Methods
Source
# File lib/opennebula/cluster.rb, line 291 def contains_resource?(xpath, id) id_array = retrieve_elements(xpath) return false if id_array.nil? id = [id] if id.class != Array id.each { |i| return false if !id_array.include?(i.to_s) } return true end