How to Differentiate Folders in vSphere

As we know Folder is a container object in vSphere. It’s used to hold other managed objects in a similar way as directory holding files in an OS. There is an interesting question asking in VI Java API forum on how to tell whether a folder is vmFolder or hostFolder. BTW, you don’t see these two folders displayed in vSphere Client.

The questioner guessed correctly that you can find out by a folder’s childType property. Here is the documentation in API reference on the possible values of the childType property:

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

  • { “vim.Folder”, “vim.Datacenter” } – Identifies the root folder and its descendant folders. Data center folders can contain child data center folders and Datacenter managed objects. Datacenter objects contain virtual machine, compute resource, network entity, and datastore folders.
  • { “vim.Folder”, “vim.Virtualmachine”, “vim.VirtualApp” } – Identifies a virtual machine folder. A virtual machine folder may contain child virtual machine folders. It also can contain VirtualMachine managed objects, templates, and VirtualApp managed objects.
  • { “vim.Folder”, “vim.ComputeResource” } – Identifies a compute resource folder, which contains child compute resource folders and ComputeResource hierarchies.
  • { “vim.Folder”, “vim.Network” } – Identifies a network entity folder. Network entity folders can contain Network, DistributedVirtualSwitch, and DistributedVirtualPort managed objects.
  • { “vim.Folder”, “vim.Datastore” } – Identifies a datastore folder. Datastore folders can contain child datastore folders and Datastore managed objects.

Note that the values in the childType have vim. prefix, which stands for virtual infrastructure management. That is what the convention is.

This may seemingly solve the problem. But the Folder object can be recursive meaning a Folder can contain another folder. For example, a virtual machine folder can contain another virtual machine which has the same childType property. In that case, you have to check its parent. For that, you will find my post on inventory hierarchy very helpful.

The hostFolder is a little tricky because it does not contain HostSystem but ComputeResource instead. Only from the ComputerResource or its subtype ClusterComputerResource can you find HostSystem array. Unlike the virtual machine folder, it’s not recursive. Thanks to Ben North for pointing this out and helping the community on many questions!

This entry was posted in vSphere API and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Ben
    Posted January 28, 2011 at 9:28 am | Permalink

    I assume the “it” in the penultimate sentence refers to the HostSystem array, not the host Folder.
    Host folders (which as you point out are actually
    used for ComputeResources) can be recursive, it’s
    just that not many people use this feature of

    Ditto for datacenter Folders: I’ve never seen
    anyone use anything but the single root.

  2. Posted January 28, 2011 at 10:42 am | Permalink

    Thanks Ben, you are right – according to the childType, the ComputeResource folder can be recursive.

  3. jack
    Posted March 11, 2014 at 10:57 am | Permalink

    Is there a community or forum however small using the pyVmomi ?


  4. Janardan
    Posted July 21, 2014 at 8:54 am | Permalink

    while creating host , folder, datacenter etc facing [NotSupportedFault: null] The Operation is not supported on this object exception.
    can anyone help me?
    giving parent folder as “ha-folder-root”

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.