Class: RbVmomi::VIM::ResourcePool

Inherits:
Object
  • Object
show all
Defined in:
lib/rbvmomi/vim/ResourcePool.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resourcePoolSubTree(objs, fields = []) ⇒ Object



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
# File 'lib/rbvmomi/vim/ResourcePool.rb', line 23

def self.resourcePoolSubTree objs, fields = []
  fields = (fields + ['name', 'resourcePool']).uniq
  filterSpec = RbVmomi::VIM.PropertyFilterSpec(
    :objectSet => objs.map do |obj|
      RbVmomi::VIM.ObjectSpec(
        :obj => obj,
        :selectSet => [
          RbVmomi::VIM.TraversalSpec(
            :name => "tsRP",
            :type => 'ResourcePool',
            :path => 'resourcePool',
            :skip => false,
            :selectSet => [
              RbVmomi::VIM.SelectionSpec(:name => "tsRP")
            ]
          )
        ]
      )
    end,
    :propSet => [{
      :pathSet => fields,
      :type => 'ResourcePool'
    }]
  )

  propCollector = objs.first._connection.propertyCollector
  result = propCollector.RetrieveProperties(:specSet => [filterSpec])
  
  Hash[result.map do |x|
    [x.obj, x.to_hash]
  end]
end

Instance Method Details

#find(name) ⇒ VIM::ResourcePool

Retrieve a child ResourcePool.

Parameters:

  • name (String)

    Name of the child.

Returns:



5
6
7
# File 'lib/rbvmomi/vim/ResourcePool.rb', line 5

def find name
  _connection.searchIndex.FindChild(:entity => self, :name => name)
end

#resourcePoolSubTree(fields = []) ⇒ Object



19
20
21
# File 'lib/rbvmomi/vim/ResourcePool.rb', line 19

def resourcePoolSubTree fields = []
  self.class.resourcePoolSubTree [self], fields
end

#traverse(path) ⇒ VIM::ResourcePool

Retrieve a descendant of this ResourcePool.

Parameters:

  • path (String)

    Path delimited by '/'.

Returns:



12
13
14
15
16
17
# File 'lib/rbvmomi/vim/ResourcePool.rb', line 12

def traverse path
  es = path.split('/').reject(&:empty?)
  es.inject(self) do |f,e|
    f.find(e) || return
  end
end