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.
-
#ephemeral_datastores ⇒ Object
Returns the value of attribute ephemeral_datastores.
-
#mob ⇒ Object
Returns the value of attribute mob.
-
#persistent_datastores ⇒ Object
Returns the value of attribute persistent_datastores.
-
#resource_pool ⇒ Object
Returns the value of attribute resource_pool.
-
#shared_datastores ⇒ Object
Returns the value of attribute shared_datastores.
-
#synced_free_memory ⇒ Integer
Cached memory utilization in MB.
Instance Method Summary collapse
-
#allocate(memory) ⇒ void
Marks the memory reservation against the cached utilization data.
-
#free_memory ⇒ Integer
Amount of free memory in the cluster.
-
#initialize(datacenter, cloud_config, cluster_config, properties) ⇒ 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.
-
#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.
Constructor Details
#initialize(datacenter, cloud_config, cluster_config, properties) ⇒ Cluster
Creates a new Cluster resource from the specified datacenter, cluster configuration, and prefetched properties.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 49 def initialize(datacenter, cloud_config, cluster_config, properties) @datacenter = datacenter @logger = cloud_config.logger @client = cloud_config.client @properties = properties @config = cluster_config @cloud_config = cloud_config @mob = properties[:obj] @resource_pool = ResourcePool.new(cloud_config, cluster_config, properties["resourcePool"]) @allocated_after_sync = 0 @ephemeral_datastores = {} @persistent_datastores = {} @shared_datastores = {} setup_datastores # Have to use separate mechanisms for fetching utilization depending on # whether we're using resource pools or raw clusters. if @config.resource_pool.nil? fetch_cluster_utilization(properties['host']) else fetch_resource_pool_utilization end end |
Instance Attribute Details
#allocated_after_sync ⇒ Integer
Returns memory allocated since utilization sync in MB.
40 41 42 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 40 def allocated_after_sync @allocated_after_sync end |
#datacenter ⇒ Object
Returns the value of attribute datacenter.
16 17 18 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 16 def datacenter @datacenter end |
#ephemeral_datastores ⇒ Object
Returns the value of attribute ephemeral_datastores.
24 25 26 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 24 def ephemeral_datastores @ephemeral_datastores end |
#mob ⇒ Object
Returns the value of attribute mob.
12 13 14 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 12 def mob @mob end |
#persistent_datastores ⇒ Object
Returns the value of attribute persistent_datastores.
28 29 30 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 28 def persistent_datastores @persistent_datastores end |
#resource_pool ⇒ Object
Returns the value of attribute resource_pool.
20 21 22 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 20 def resource_pool @resource_pool end |
#shared_datastores ⇒ Object
Returns the value of attribute shared_datastores.
32 33 34 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 32 def shared_datastores @shared_datastores end |
#synced_free_memory ⇒ Integer
Returns cached memory utilization in MB.
36 37 38 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 36 def synced_free_memory @synced_free_memory end |
Instance Method Details
#allocate(memory) ⇒ void
This method returns an undefined value.
Marks the memory reservation against the cached utilization data.
96 97 98 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 96 def allocate(memory) @allocated_after_sync += memory end |
#free_memory ⇒ Integer
Returns amount of free memory in the cluster.
87 88 89 90 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 87 def free_memory @synced_free_memory - (@allocated_after_sync * cloud_config.mem_overcommit).to_i end |
#inspect ⇒ String
Returns debug cluster information.
125 126 127 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 125 def inspect "<Cluster: #{mob} / #{config.name}>" end |
#name ⇒ String
Returns cluster name.
120 121 122 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 120 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.
81 82 83 84 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 81 def persistent(datastore_name) @persistent_datastores[datastore_name] || @shared_datastores[datastore_name] end |
#pick_ephemeral(size) ⇒ Datastore?
Picks the best datastore for the specified ephemeral disk.
115 116 117 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 115 def pick_ephemeral(size) pick_store(size, :ephemeral) end |
#pick_persistent(size) ⇒ Datastore?
Picks the best datastore for the specified persistent disk.
106 107 108 |
# File 'lib/cloud/vsphere/resources/cluster.rb', line 106 def pick_persistent(size) pick_store(size, :persistent) end |