Class: RbVmomi::VIM::Datastore
- Inherits:
-
Object
- Object
- RbVmomi::VIM::Datastore
- Defined in:
- lib/rvc/extensions/Datastore.rb,
lib/rvc/modules/spbm.rb
Overview
Copyright © 2011 VMware, Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Class Method Summary collapse
Instance Method Summary collapse
- #children ⇒ Object
- #children_hosts ⇒ Object
- #children_vms ⇒ Object
- #display_info ⇒ Object
- #ls_text(r) ⇒ Object
- #pbm_capability_profiles ⇒ Object
- #rvc_children_capabilitysets ⇒ Object
- #rvc_list_children_capabilitysets ⇒ Object
- #to_pbmhub ⇒ Object
Class Method Details
.ls_properties ⇒ Object
37 38 39 |
# File 'lib/rvc/extensions/Datastore.rb', line 37 def self.ls_properties %w(name summary.capacity summary.freeSpace) end |
Instance Method Details
#children ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/rvc/extensions/Datastore.rb', line 48 def children { 'files' => FakeDatastoreFolder.new(self, ""), 'vms' => RVC::FakeFolder.new(self, :children_vms), 'hosts' => RVC::FakeFolder.new(self, :children_hosts), } end |
#children_hosts ⇒ Object
60 61 62 63 |
# File 'lib/rvc/extensions/Datastore.rb', line 60 def children_hosts # XXX optimize Hash[host.map(&:key).map { |x| [x.name, x] }] end |
#children_vms ⇒ Object
56 57 58 |
# File 'lib/rvc/extensions/Datastore.rb', line 56 def children_vms RVC::Util.collect_children self, :vm end |
#display_info ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rvc/extensions/Datastore.rb', line 22 def display_info s, info, = collect :summary, :info puts "type: #{s.type}" puts "url: #{s.accessible ? s.url : '<inaccessible>'}" puts "multipleHostAccess: #{s.multipleHostAccess}" puts "capacity: %0.2fGB" % (s.capacity.to_f/10**9) puts "free space: %0.2fGB" % (s.freeSpace.to_f/10**9) case info when VIM::VmfsDatastoreInfo puts "uuid: #{info.vmfs.uuid}" when VIM::NasDatastoreInfo puts "location: #{info.nas.remoteHost}:#{info.nas.remotePath}" end end |
#ls_text(r) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/rvc/extensions/Datastore.rb', line 41 def ls_text r pct_used = 100*(1-(r['summary.freeSpace'].to_f/r['summary.capacity'])) pct_used_text = "%0.1f%%" % pct_used capacity_text = "%0.2fGB" % (r['summary.capacity'].to_f/10**9) ": #{capacity_text} #{pct_used_text}" end |
#pbm_capability_profiles ⇒ Object
124 125 126 |
# File 'lib/rvc/modules/spbm.rb', line 124 def pbm_capability_profiles pbm_associated_profiles end |
#rvc_children_capabilitysets ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/rvc/modules/spbm.rb', line 134 def rvc_children_capabilitysets conn = _connection _catch_spbm_resets(conn) do pbm = _connection.pbm profiles = pbm_capability_profiles Hash[profiles.map do |x| x.instance_variable_set(:@connection, pbm) x.instance_variable_set(:@dc, self) [x.name, x] end] end end |
#rvc_list_children_capabilitysets ⇒ Object
128 129 130 131 132 |
# File 'lib/rvc/modules/spbm.rb', line 128 def rvc_list_children_capabilitysets { 'capabilitysets' => RVC::FakeFolder.new(self, :rvc_children_capabilitysets), } end |
#to_pbmhub ⇒ Object
120 121 122 |
# File 'lib/rvc/modules/spbm.rb', line 120 def to_pbmhub PBM::PbmPlacementHub(:hubType => "Datastore", :hubId => _ref) end |