Class: RbVmomi::VIM::ResourcePool

Inherits:
Object
  • Object
show all
Defined in:
lib/rvc/extensions/ResourcePool.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
# File 'lib/rvc/extensions/ResourcePool.rb', line 22

def self.ls_properties
  %w(name config.cpuAllocation config.memoryAllocation)
end

Instance Method Details

#childrenObject



38
39
40
41
42
43
# File 'lib/rvc/extensions/ResourcePool.rb', line 38

def children
  {
    'vms' => RVC::FakeFolder.new(self, :children_vms),
    'pools' => RVC::FakeFolder.new(self, :children_pools),
  }
end

#children_poolsObject



49
50
51
# File 'lib/rvc/extensions/ResourcePool.rb', line 49

def children_pools
  RVC::Util.collect_children self, :resourcePool
end

#children_vmsObject



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

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

#ls_text(r) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rvc/extensions/ResourcePool.rb', line 26

def ls_text r
  cpuAlloc, memAlloc = r['config.cpuAllocation'], r['config.memoryAllocation']

  cpu_shares_text = cpuAlloc.shares.level == 'custom' ? cpuAlloc.shares.shares.to_s : cpuAlloc.shares.level
  mem_shares_text = memAlloc.shares.level == 'custom' ? memAlloc.shares.shares.to_s : memAlloc.shares.level

  ": cpu %0.2f/%0.2f/%s, mem %0.2f/%0.2f/%s" % [
    cpuAlloc.reservation/1000.0, cpuAlloc.limit/1000.0, cpu_shares_text,
    memAlloc.reservation/1000.0, memAlloc.limit/1000.0, mem_shares_text,
  ]
end