The Managed Object Browser or MOB is a tool that is bundled with vCenter and ESXi, and it can be used to visually explore the structure of various vSphere related objects, such as Virtual Machines, Datastores and Clusters. This becomes invaluable when developing automation or reporting on infrastructure.
Each object within the MOB contains an array of data, from common information such as the objects name, configured CPU & Memory or its overall status, to less explored data such hardware device keys, VMX file paths and snapshot tree structure.
Not only can the MOB be used to explore this information, but it can also be used to invoke various methods against the various objects. For example, when viewing a Virtual Machine object you can invoke ShutdownGuest
and CreateSnapshot
tasks.
#MOB Key Components
- Property Path: Used to identify where you are within an object. The path can be “walked” to reach specific information.
- Properties/Attributes: The information on part of the path, referencing this property with something like PowerCLI or vRO will return the value of the property, for example
vm.name
would return thename
of the virtual machine object you are working with. - Property Types: The property type shows what form the data is, such as
string
,number
, or anotherobject
. When the value of a property is another object, the path can continue to be walked. - Parent Object Managed ID: This is often known as the moRef value, it is a unique ID generated by vCenter for a given object. This will be shown at the top of the page for the object you are in.
- Browser Address Bar: The address bar gives you a direct link to wherever you are in the MOB,
https://<vcenter-server-IP-or-FQDN>/mob/?moid=vm-725&doPath=guest
- including the moRef of the vCenter object (e.g.vm-725
)
#MOB Guided Tour
To connect to your vCenter MOB, navigate to https://<vcenter-server-IP-or-FQDN>/mob
and login with valid credentials.
At the top of your page you should see a table, the first column is the property/attribute name, followed by its type, and then the value. This structure will be used throughout the MOB.
- Click on the link for
content
.
This second page shows us various Service Managers that vCenter provides, such as FileManager
and OvfManager
, these provide various actions and functions, but for now we are only interested in consuming existing information.
- Click on the link against the property
rootFolder
, the value should begroup-d1 (Datacenters)
At the top of this next page you will see a childEntity
property, you should see some familiar values here - your Datacenters, their names will be shown within brackets ( ).
- Click on one of your
Datacenters
.
Within the Datacenter object screen you will see a lot of familiar information, this is the real start of what you would see within vCenter. On this page you will see links to your Datastores and Networks. At the bottom you will also see vmFolder
.
You might have noticed that Datastores start with datastore-
and Networks start with network-
. As you browse the MOB you will see that various vSphere related objects have a naming prefix to them. (vm-
for VMs, host-
for Hosts etc).
- Click the link next to
vmFolder
.
Inside the top level VM folder, which has the name vm
(find the name
property), you will find all child folders as well as any virtual machines that have not been organised in to a folder. This is the root, or top level, vm folder - some applications such as govc
rely on this when providing the path to an object, for example if you wanted to move a vm in to a folder: govc object.mv /dc1/vm/vm-foo-* /dc1/vm/folder-foo
.
- Find a virtual machine and click its link, if your VMs are organised into folders select one of those to find a VM object (remember to look for an object that starts
vm-
).
Take some time to look through this object, take note of the values against the datastore
and network
properties. Now compare these to what you see within the vCenter UI, they should match.
- Next, click the link next to the
guest
property.
We are now looking at the guest
information for our Virtual Machine. Take a look at the guestState
and hostname
properties. Once again, these should match what you see within vCenter - is the VM powered on or off? What is the hostname shown on the summary tab?
- Go back a page to the top level of the virtual machine object you selected, scroll down and select
summary
Take note of the Property Path
at the top of the page, this currently shows summary
.
- Press the
config
link
Check the Property Path
again, you should now see that we are in summary.config
. The path shows us where we are within an object, so at the moment we are within vm.summary.confg
.
Take a look at some of the properties listed here, such as the guestFullName
, check it against vCenter. The full path to this property would be vm.summary.config.guestFullName
#Example with PowerCLI
- Install PowerCLI:
Install-Module -Name VMware.PowerCLI
. - Connect to vCenter:
Connect-VIServer -Server "vcenter.domain.com" -User "username" -Password "password"
. - Get the VM object we looked at earlier in the MOB:
$vm = Get-VM -Name "vm-name"
.
To access the data we would normally see on an object within the MOB, via PowerCLI, we need to use the ExtensionData
property.
- Output all ExtensionData, cross reference what you see as an output with what you see in the MOB:
$vm.extensiondata
. - Get the hostName of our VM object (step 6 above):
$vm.extensiondata.guest.hostname
. - Get the guestFullName of our VM object (step 8 above):
$vm.extensiondata.summary.config.guestFullName
.
Ignoring the ExtensionData property, we can see in the two simple examples above that the path we have gone down to get our data through PowerCLI matches the same path we went down to get the data from MOB.
#Example with vRO
- Create a new workflow, name it VM Details.
- Create a new Input call
vm
with the typeVC:VirtualMachine
.
- Drag a Scripting object on to the canvas, between the Start and End, rename it if necessary.
- Map the Input to the scripting object
- Update the code within the scripting object
System.log(vm.guest.hostName);
System.log(vm.summary.config.guestFullName);
- Run the workflow, the output should show the same information as vCenter