Class: VSphereCloud::Resources::Cluster
- Inherits:
-
Object
- Object
- VSphereCloud::Resources::Cluster
- Includes:
- VimSdk
- Defined in:
- lib/cloud/vsphere/resources/cluster.rb
Constant Summary collapse
- PROPERTIES =
%w(name datastore resourcePool host)
- HOST_PROPERTIES =
%w(hardware.memorySize runtime.inMaintenanceMode)
- HOST_COUNTERS =
%w(mem.usage.average)
Constants included from VimSdk
VimSdk::BASE_VERSION, VimSdk::DYNAMIC_TYPES, VimSdk::SOAP_BODY_END, VimSdk::SOAP_BODY_START, VimSdk::SOAP_BODY_TAG, VimSdk::SOAP_END, VimSdk::SOAP_ENVELOPE_END, VimSdk::SOAP_ENVELOPE_START, VimSdk::SOAP_ENVELOPE_TAG, VimSdk::SOAP_FAULT_TAG, VimSdk::SOAP_HEADER_END, VimSdk::SOAP_HEADER_START, VimSdk::SOAP_HEADER_TAG, VimSdk::SOAP_NAMESPACE_MAP, VimSdk::SOAP_START, VimSdk::VERSION1, VimSdk::XMLNS_SOAPENC, VimSdk::XMLNS_SOAPENV, VimSdk::XMLNS_VMODL_BASE, VimSdk::XMLNS_XSD, VimSdk::XMLNS_XSI, VimSdk::XML_ENCODING, VimSdk::XML_HEADER
Instance Attribute Summary collapse
-
#allocated_after_sync ⇒ Integer
Memory allocated since utilization sync in MB.
-
#datacenter ⇒ Object
Returns the value of attribute datacenter.
-
#mob ⇒ Object
Returns the value of attribute mob.
-
#resource_pool ⇒ Object
Returns the value of attribute resource_pool.
Instance Method Summary collapse
-
#allocate(memory) ⇒ void
Marks the memory reservation against the cached utilization data.
- #ephemeral_datastores ⇒ Object
-
#free_memory ⇒ Integer
Amount of free memory in the cluster.
-
#initialize(datacenter, datacenter_datastore_pattern, datacenter_persistent_datastore_pattern, mem_overcommit, cluster_config, properties, logger, client) ⇒ Cluster
constructor
Creates a new Cluster resource from the specified datacenter, cluster configuration, and prefetched properties.
-
#inspect ⇒ String
Debug cluster information.
-
#name ⇒ String
Cluster name.
-
#persistent(datastore_name) ⇒ Datastore?
Returns the persistent datastore by name.
- #persistent_datastores ⇒ Object
-
#pick_ephemeral(size) ⇒ Datastore
Picks the best datastore for the specified ephemeral disk.
-
#pick_persistent(size) ⇒ Datastore
Picks the best datastore for the specified persistent disk.
- #total_free_ephemeral_disk_in_mb ⇒ Object
- #total_free_persistent_disk_in_mb ⇒ Object
Constructor Details
#initialize(datacenter, datacenter_datastore_pattern, datacenter_persistent_datastore_pattern, mem_overcommit, cluster_config, properties, logger, client) ⇒ Cluster
Creates a new Cluster resource from the specified datacenter, cluster configuration, and prefetched properties.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 35 def initialize(datacenter, datacenter_datastore_pattern, datacenter_persistent_datastore_pattern, mem_overcommit, cluster_config, properties, logger, client) @datacenter = datacenter @logger = logger @client = client @properties = properties @config = cluster_config @mob = properties[:obj] @resource_pool = ResourcePool.new(@client, @logger, cluster_config, properties["resourcePool"]) @datacenter_datastore_pattern = datacenter_datastore_pattern @datacenter_persistent_datastore_pattern = datacenter_persistent_datastore_pattern @mem_overcommit = mem_overcommit @allocated_after_sync = 0 end |
Instance Attribute Details
#allocated_after_sync ⇒ Integer
Returns memory allocated since utilization sync in MB.
26 27 28 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 26 def allocated_after_sync @allocated_after_sync end |
#datacenter ⇒ Object
Returns the value of attribute datacenter.
18 19 20 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 18 def datacenter @datacenter end |
#mob ⇒ Object
Returns the value of attribute mob.
14 15 16 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 14 def mob @mob end |
#resource_pool ⇒ Object
Returns the value of attribute resource_pool.
22 23 24 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 22 def resource_pool @resource_pool end |
Instance Method Details
#allocate(memory) ⇒ void
This method returns an undefined value.
Marks the memory reservation against the cached utilization data.
77 78 79 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 77 def allocate(memory) @allocated_after_sync += memory end |
#ephemeral_datastores ⇒ Object
109 110 111 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 109 def ephemeral_datastores @ephemeral_datastores ||= select_datastores(@datacenter_datastore_pattern) end |
#free_memory ⇒ Integer
Returns amount of free memory in the cluster.
60 61 62 63 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 60 def free_memory synced_free_memory - (@allocated_after_sync * @mem_overcommit).to_i end |
#inspect ⇒ String
Returns debug cluster information.
105 106 107 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 105 def inspect "<Cluster: #{mob} / #{config.name}>" end |
#name ⇒ String
Returns cluster name.
100 101 102 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 100 def name config.name end |
#persistent(datastore_name) ⇒ Datastore?
Returns the persistent datastore by name. This could be either from the exclusive or shared datastore pools.
55 56 57 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 55 def persistent(datastore_name) persistent_datastores[datastore_name] end |
#persistent_datastores ⇒ Object
113 114 115 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 113 def persistent_datastores @persistent_datastores ||= select_datastores(@datacenter_persistent_datastore_pattern) end |
#pick_ephemeral(size) ⇒ Datastore
Picks the best datastore for the specified ephemeral disk.
95 96 97 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 95 def pick_ephemeral(size) pick_store(:ephemeral, size) end |
#pick_persistent(size) ⇒ Datastore
Picks the best datastore for the specified persistent disk.
86 87 88 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 86 def pick_persistent(size) pick_store(:persistent, size) end |
#total_free_ephemeral_disk_in_mb ⇒ Object
65 66 67 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 65 def total_free_ephemeral_disk_in_mb ephemeral_datastores.values.map(&:free_space).inject(0, :+) end |
#total_free_persistent_disk_in_mb ⇒ Object
69 70 71 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 69 def total_free_persistent_disk_in_mb persistent_datastores.values.map(&:free_space).inject(0, :+) end |