Class: RbVmomi::VIM::VirtualMachine
- Inherits:
-
Object
- Object
- RbVmomi::VIM::VirtualMachine
- Defined in:
- lib/rvc/extensions/VirtualMachine.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
- #display_info ⇒ Object
- #ls_text(r) ⇒ Object
- #rvc_children_datastores ⇒ Object
- #rvc_children_files ⇒ Object
- #rvc_children_networks ⇒ Object
Class Method Details
.ls_properties ⇒ Object
58 59 60 |
# File 'lib/rvc/extensions/VirtualMachine.rb', line 58 def self.ls_properties %w(name runtime.powerState) end |
Instance Method Details
#children ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rvc/extensions/VirtualMachine.rb', line 66 def children host, resourcePool = collect *%w(runtime.host resourcePool) { 'host' => host, 'resourcePool' => resourcePool, 'datastores' => RVC::FakeFolder.new(self, :rvc_children_datastores), 'networks' => RVC::FakeFolder.new(self, :rvc_children_networks), 'files' => RVC::FakeFolder.new(self, :rvc_children_files), 'snapshots' => RVC::RootSnapshotFolder.new(self), } end |
#display_info ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rvc/extensions/VirtualMachine.rb', line 22 def display_info config, runtime, guest = collect :config, :runtime, :guest RVC::Util.err "Information currently unavailable" unless config and runtime and guest puts "name: #{config.name}" puts "note: #{config.annotation}" if config.annotation and !config.annotation.empty? puts "host: #{runtime.host.path[1..-1].map { |x| x[1] } * '/'}" if runtime.host puts "tools: #{guest.toolsRunningStatus}" puts "hostname: #{guest.hostName} (#{guest.ipAddress})" if guest.hostName and guest.ipAddress puts "VC UUID: #{config.instanceUuid}" if config.instanceUuid and !config.instanceUuid.empty? puts "power: #{runtime.powerState}" if runtime.question puts "question: #{runtime.question.text.lines.to_a.join("> ")}" puts "choices: #{runtime.question.choice.choiceInfo.map(&:label) * ', '}" if i = runtime.question.choice.defaultIndex puts "default: #{runtime.question.choice.choiceInfo[i].label}" end end puts "cpus: #{config.hardware.numCPU}" puts "memory: #{config.hardware.memoryMB} MB" puts "nics:" config.hardware.device.grep RbVmomi::VIM::VirtualEthernetCard do |dev| backing_info = case dev.backing when RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo dev.backing.deviceName.inspect when RbVmomi::VIM::VirtualEthernetCardDistributedVirtualPortBackingInfo dev.backing.port.portgroupKey.inspect else dev.backing.class.name end guest_net = guest.net.find { |x| x.macAddress == dev.macAddress } puts " #{dev.deviceInfo.label}: #{backing_info} #{dev.connectable.connected ? :connected : :disconnected} #{dev.macAddress} #{guest_net ? (guest_net.ipAddress * ' ') : ''}" end end |
#ls_text(r) ⇒ Object
62 63 64 |
# File 'lib/rvc/extensions/VirtualMachine.rb', line 62 def ls_text r ": #{r['runtime.powerState']}" end |
#rvc_children_datastores ⇒ Object
78 79 80 |
# File 'lib/rvc/extensions/VirtualMachine.rb', line 78 def rvc_children_datastores RVC::Util.collect_children self, :datastore end |
#rvc_children_files ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/rvc/extensions/VirtualMachine.rb', line 86 def rvc_children_files files = layoutEx.file datastore_map = RVC::Util.collect_children self, :datastore Hash[files.map do |file| file.name =~ /^\[(.+)\] (.+)$/ or fail "invalid datastore path" ds = datastore_map[$1] or fail "datastore #{$1.inspect} not found" arcs, = RVC::Path.parse $2 arcs.unshift 'files' objs = $shell.fs.traverse ds, arcs fail unless objs.size == 1 [File.basename(file.name), objs.first] end] end |
#rvc_children_networks ⇒ Object
82 83 84 |
# File 'lib/rvc/extensions/VirtualMachine.rb', line 82 def rvc_children_networks RVC::Util.collect_children self, :network end |