Class: RbVmomi::VIM::Datastore
- Inherits:
-
Object
- Object
- RbVmomi::VIM::Datastore
- Defined in:
- lib/rvc/extensions/Datastore.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
Class Method Details
.ls_properties ⇒ Object
32 33 34 |
# File 'lib/rvc/extensions/Datastore.rb', line 32 def self.ls_properties %w(name summary.capacity summary.freeSpace) end |
Instance Method Details
#children ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/rvc/extensions/Datastore.rb', line 43 def children { 'files' => FakeDatastoreFolder.new(self, ""), 'vms' => RVC::FakeFolder.new(self, :children_vms), 'hosts' => RVC::FakeFolder.new(self, :children_hosts), } end |
#children_hosts ⇒ Object
55 56 57 58 |
# File 'lib/rvc/extensions/Datastore.rb', line 55 def children_hosts # XXX optimize Hash[host.map(&:key).map { |x| [x.name, x] }] end |
#children_vms ⇒ Object
51 52 53 |
# File 'lib/rvc/extensions/Datastore.rb', line 51 def children_vms RVC::Util.collect_children self, :vm end |
#display_info ⇒ Object
22 23 24 25 26 27 28 29 30 |
# 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 "uuid: #{info.vmfs.uuid}" 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) end |
#ls_text(r) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rvc/extensions/Datastore.rb', line 36 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 |