Class: RbVmomi::VIM::ManagedEntity

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

Instance Method Summary collapse

Instance Method Details

#pathObject



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rbvmomi/extensions.rb', line 59

def path
  filterSpec = VIM.PropertyFilterSpec(
    objectSet: [{
      obj: self,
      selectSet: [
        VIM.TraversalSpec(
          name: 'tsME',
          type: 'ManagedEntity',
          path: 'parent',
          skip: false,
          selectSet: [
            VIM.SelectionSpec(name: 'tsME')
          ]
        )
      ]
    }],
    propSet: [{
      pathSet: %w(name parent),
      type: 'ManagedEntity'
    }]
  )

  result = @soap.propertyCollector.RetrieveProperties(specSet: [filterSpec])

  tree = {}
  result.each { |x| tree[x.obj] = [x['parent'], x['name']] }
  a = []
  cur = self
  while cur
    parent, name = *tree[cur]
    a << [cur, name]
    cur = parent
  end
  a.reverse
end