Method: RbVmomi::VIM::EsxcliNamespace.root

Defined in:
lib/rbvmomi/vim/HostSystem.rb

.root(host) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rbvmomi/vim/HostSystem.rb', line 57

def self.root host
  type_hash = host.dti.toRbvmomiTypeHash
  VIM.loader.add_types type_hash
  all_instances = host.dtm.DynamicTypeMgrQueryMoInstances
  instances = Hash[all_instances.select { |x| x.moType.start_with? ESXCLI_PREFIX }.
                                 map { |x| [x.moType,x.id] }]
  type_infos = Hash[host.dti.managedTypeInfo.map { |x| [x.name,x] }]
  new('root', nil, host).tap do |root|
    instances.each do |type,instance|
      path = type.split('.')[2..-1]
      ns = path.inject(root) { |b,v| b.namespaces[v] }
      ns.realize type, instance, type_infos[type]
    end
  end
end