Class: OpenNebula::Cluster
- Inherits:
-
PoolElement
- Object
- XMLElement
- PoolElement
- OpenNebula::Cluster
- Defined in:
- lib/opennebula/cluster.rb
Constant Summary collapse
- CLUSTER_METHODS =
Constants and Class Methods
{ :info => "cluster.info", :allocate => "cluster.allocate", :delete => "cluster.delete", :addhost => "cluster.addhost", :delhost => "cluster.delhost", :adddatastore => "cluster.adddatastore", :deldatastore => "cluster.deldatastore", :addvnet => "cluster.addvnet", :delvnet => "cluster.delvnet", :update => "cluster.update", :rename => "cluster.rename" }
Instance Attribute Summary
Attributes inherited from PoolElement
Class Method Summary collapse
-
.build_xml(pe_id = nil) ⇒ Object
Creates a Cluster description with just its identifier this method should be used to create plain Cluster objects.
Instance Method Summary collapse
-
#adddatastore(ds_id) ⇒ nil, OpenNebula::Error
Adds a Datastore to this Cluster.
-
#addhost(hid) ⇒ nil, OpenNebula::Error
Adds a Host to this Cluster.
-
#addvnet(vnet_id) ⇒ nil, OpenNebula::Error
Adds a VNet to this Cluster.
-
#allocate(clustername) ⇒ Object
Allocates a new Cluster in OpenNebula.
-
#contains_datastore?(id) ⇒ Boolean
Returns whether or not the datastore with ‘id’ is part of this cluster.
-
#contains_host?(id) ⇒ Boolean
Returns whether or not the host with ‘id’ is part of this cluster.
-
#contains_vnet?(id) ⇒ Boolean
Returns whether or not the vnet with ‘id’ is part of this cluster.
-
#datastore_ids ⇒ Array<Integer>
Returns an array with the numeric datastore ids.
-
#deldatastore(ds_id) ⇒ nil, OpenNebula::Error
Deletes a Datastore from this Cluster.
-
#delete ⇒ Object
Deletes the Cluster.
-
#delhost(hid) ⇒ nil, OpenNebula::Error
Deletes a Host from this Cluster.
-
#delvnet(vnet_id) ⇒ nil, OpenNebula::Error
Deletes a VNet from this Cluster.
-
#host_ids ⇒ Array<Integer>
Returns an array with the numeric host ids.
-
#info(decrypt = false) ⇒ Object
(also: #info!)
Retrieves the information of the given Cluster.
-
#initialize(xml, client) ⇒ Cluster
constructor
Class constructor.
-
#rename(name) ⇒ nil, OpenNebula::Error
Renames this Cluster.
-
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the template contents.
-
#vnet_ids ⇒ Array<Integer>
Returns an array with the numeric vnet ids.
Methods inherited from PoolElement
#id, new_with_id, #replace, #to_str
Methods inherited from XMLElement
#[], #add_element, #attr, #delete_element, #each, #each_xpath, #element_xml, #has_elements?, #initialize_xml, #name, #retrieve_elements, #retrieve_xmlelements, #set_content, #template_like_str, #template_str, #template_xml, #text, #to_hash, #to_xml, #xml_nil?
Constructor Details
#initialize(xml, client) ⇒ Cluster
Class constructor
58 59 60 |
# File 'lib/opennebula/cluster.rb', line 58 def initialize(xml, client) super(xml,client) end |
Class Method Details
.build_xml(pe_id = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/opennebula/cluster.rb', line 47 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 |
Instance Method Details
#adddatastore(ds_id) ⇒ nil, OpenNebula::Error
Adds a Datastore to this Cluster
115 116 117 118 119 120 121 122 |
# File 'lib/opennebula/cluster.rb', line 115 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 |
#addhost(hid) ⇒ nil, OpenNebula::Error
Adds a Host to this Cluster
89 90 91 92 93 94 95 96 |
# File 'lib/opennebula/cluster.rb', line 89 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 |
#addvnet(vnet_id) ⇒ nil, OpenNebula::Error
Adds a VNet to this Cluster
141 142 143 144 145 146 147 148 |
# File 'lib/opennebula/cluster.rb', line 141 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 |
#allocate(clustername) ⇒ Object
Allocates a new Cluster in OpenNebula
clustername
A string containing the name of the Cluster.
76 77 78 |
# File 'lib/opennebula/cluster.rb', line 76 def allocate(clustername) super(CLUSTER_METHODS[:allocate], clustername) end |
#contains_datastore?(id) ⇒ Boolean
Returns whether or not the datastore with ‘id’ is part of this cluster
211 212 213 |
# File 'lib/opennebula/cluster.rb', line 211 def contains_datastore?(id) contains_resource?('DATASTORES/ID', id) end |
#contains_host?(id) ⇒ Boolean
Returns whether or not the host with ‘id’ is part of this cluster
192 193 194 |
# File 'lib/opennebula/cluster.rb', line 192 def contains_host?(id) contains_resource?('HOSTS/ID', id) end |
#contains_vnet?(id) ⇒ Boolean
Returns whether or not the vnet with ‘id’ is part of this cluster
230 231 232 |
# File 'lib/opennebula/cluster.rb', line 230 def contains_vnet?(id) contains_resource?('VNETS/ID', id) end |
#datastore_ids ⇒ Array<Integer>
Returns an array with the numeric datastore ids
217 218 219 220 221 222 223 224 225 |
# File 'lib/opennebula/cluster.rb', line 217 def datastore_ids array = Array.new self.each("DATASTORES/ID") do |id| array << id.text.to_i end return array end |
#deldatastore(ds_id) ⇒ nil, OpenNebula::Error
Deletes a Datastore from this Cluster
128 129 130 131 132 133 134 135 |
# File 'lib/opennebula/cluster.rb', line 128 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 |
#delete ⇒ Object
Deletes the Cluster
81 82 83 |
# File 'lib/opennebula/cluster.rb', line 81 def delete() super(CLUSTER_METHODS[:delete]) end |
#delhost(hid) ⇒ nil, OpenNebula::Error
Deletes a Host from this Cluster
102 103 104 105 106 107 108 109 |
# File 'lib/opennebula/cluster.rb', line 102 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 |
#delvnet(vnet_id) ⇒ nil, OpenNebula::Error
Deletes a VNet from this Cluster
154 155 156 157 158 159 160 161 |
# File 'lib/opennebula/cluster.rb', line 154 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 |
#host_ids ⇒ Array<Integer>
Returns an array with the numeric host ids
198 199 200 201 202 203 204 205 206 |
# File 'lib/opennebula/cluster.rb', line 198 def host_ids array = Array.new self.each("HOSTS/ID") do |id| array << id.text.to_i end return array end |
#info(decrypt = false) ⇒ Object Also known as: info!
Retrieves the information of the given Cluster.
67 68 69 |
# File 'lib/opennebula/cluster.rb', line 67 def info(decrypt = false) super(CLUSTER_METHODS[:info], 'CLUSTER', decrypt) end |
#rename(name) ⇒ nil, OpenNebula::Error
Renames this Cluster
181 182 183 |
# File 'lib/opennebula/cluster.rb', line 181 def rename(name) return call(CLUSTER_METHODS[:rename], @pe_id, name) end |
#update(new_template, append = false) ⇒ nil, OpenNebula::Error
Replaces the template contents
171 172 173 |
# File 'lib/opennebula/cluster.rb', line 171 def update(new_template, append=false) super(CLUSTER_METHODS[:update], new_template, append ? 1 : 0) end |
#vnet_ids ⇒ Array<Integer>
Returns an array with the numeric vnet ids
236 237 238 239 240 241 242 243 244 |
# File 'lib/opennebula/cluster.rb', line 236 def vnet_ids array = Array.new self.each("VNETS/ID") do |id| array << id.text.to_i end return array end |