Class: RbVmomi::VIM::HostSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/rvc/extensions/HostSystem.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

Class Method Details

.ls_propertiesObject



22
23
24
25
26
# File 'lib/rvc/extensions/HostSystem.rb', line 22

def self.ls_properties
  %w(name summary.hardware.memorySize summary.hardware.cpuModel
     summary.hardware.cpuMhz summary.hardware.numCpuPkgs
     summary.hardware.numCpuCores summary.hardware.numCpuThreads)
end

Instance Method Details

#childrenObject



34
35
36
37
38
39
# File 'lib/rvc/extensions/HostSystem.rb', line 34

def children
  {
    'vms' => RVC::FakeFolder.new(self, :ls_vms),
    'datastores' => RVC::FakeFolder.new(self, :ls_datastores),
  }
end

#ls_datastoresObject



45
46
47
# File 'lib/rvc/extensions/HostSystem.rb', line 45

def ls_datastores
  RVC::Util.collect_children self, :datastore
end

#ls_text(r) ⇒ Object



28
29
30
31
32
# File 'lib/rvc/extensions/HostSystem.rb', line 28

def ls_text r
  memorySize, cpuModel, cpuMhz, numCpuPkgs, numCpuCores =
    %w(memorySize cpuModel cpuMhz numCpuPkgs numCpuCores).map { |x| r["summary.hardware.#{x}"] }
  " (host): cpu #{numCpuPkgs}*#{numCpuCores}*#{"%.2f" % (cpuMhz.to_f/1000)} GHz, memory #{"%.2f" % (memorySize/10**9)} GB"
end

#ls_vmsObject



41
42
43
# File 'lib/rvc/extensions/HostSystem.rb', line 41

def ls_vms
  RVC::Util.collect_children self, :vm
end