Class: VSphereCloud::Resources::Datastore
- Inherits:
-
Object
- Object
- VSphereCloud::Resources::Datastore
- Defined in:
- lib/cloud/vsphere/resources/datastore.rb
Overview
Datastore resource.
Constant Summary collapse
- PROPERTIES =
%w(summary.freeSpace summary.capacity name)
Instance Attribute Summary collapse
-
#allocated_after_sync ⇒ Integer
Allocated space since vSphere fetch.
-
#mob ⇒ Vim::Datastore
Datastore vSphere MOB.
-
#name ⇒ String
Datastore name.
-
#synced_free_space ⇒ Integer
Datastore free space when fetched from vSphere.
-
#total_space ⇒ Integer
Datastore capacity.
Instance Method Summary collapse
-
#allocate(space) ⇒ void
Marks the disk space against the cached utilization data.
-
#free_space ⇒ Integer
Free disk space available for allocation.
-
#initialize(properties) ⇒ Datastore
constructor
Creates a Datastore resource from the prefetched vSphere properties.
-
#inspect ⇒ String
Debug datastore information.
Constructor Details
#initialize(properties) ⇒ Datastore
Creates a Datastore resource from the prefetched vSphere properties.
32 33 34 35 36 37 38 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 32 def initialize(properties) @mob = properties[:obj] @name = properties["name"] @total_space = properties["summary.capacity"].to_i / BYTES_IN_MB @synced_free_space = properties["summary.freeSpace"].to_i / BYTES_IN_MB @allocated_after_sync = 0 end |
Instance Attribute Details
#allocated_after_sync ⇒ Integer
Returns allocated space since vSphere fetch.
26 27 28 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 26 def allocated_after_sync @allocated_after_sync end |
#mob ⇒ Vim::Datastore
Returns datastore vSphere MOB.
10 11 12 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 10 def mob @mob end |
#name ⇒ String
Returns datastore name.
14 15 16 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 14 def name @name end |
#synced_free_space ⇒ Integer
Returns datastore free space when fetched from vSphere.
22 23 24 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 22 def synced_free_space @synced_free_space end |
#total_space ⇒ Integer
Returns datastore capacity.
18 19 20 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 18 def total_space @total_space end |
Instance Method Details
#allocate(space) ⇒ void
This method returns an undefined value.
Marks the disk space against the cached utilization data.
49 50 51 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 49 def allocate(space) @allocated_after_sync += space end |
#free_space ⇒ Integer
Returns free disk space available for allocation.
41 42 43 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 41 def free_space @synced_free_space - @allocated_after_sync end |
#inspect ⇒ String
Returns debug datastore information.
54 55 56 |
# File 'lib/cloud/vsphere/resources/datastore.rb', line 54 def inspect "<Datastore: #@mob / #@name>" end |