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