Run esxcli Command in A Browser: Hidden But Probably Better Hack

My article “Run esxcli Command in a Web Browser: Another ESXi Hack” got quite some interests from the community. Although it works, I am not quite satisfied with the fact that the real esxcfg-info.cgi is disabled to run the esxcli.cgi.

There is actually another way to run the esxcli command in a browser that is less hacky even though the user interface is not as good as the esxcli.cgi, and there is no central page that links them together. In other words, you cannot navigate the pages and have to type in individual URLs. Luckily, there is a pretty straightforward pattern in the URLs, so it’s not a big deal.

Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.

This approach was first discovered by William Lam in one of his posts in 2010 with ESXi 4.1. With the 5.1, the exact URLs may not be working due to the changes of the ESXi product, mainly the esxcli command itself. Because it’s hidden, VMware can change it without notifying anyone. The URL pattern, however, remain the same.

In ESXi 4.1 as William found out, the following URL points to the vms/vm namespace or managed object:

https://[esx_or_esxi_server]/mob/?moid=ha-cli-handler-vms-vm

The new name space for the same(?) object in ESXi 5.1/5.5 is:

https://192.168.88.132/mob/?moid=ha-cli-handler-vm-process

Once you get the page as below, you can use it the same way as with other managed objects in MOB. Here, for example, you can simply click on a method link and got a popup page on which you can click “Invoke Method” for the return information.

The invoke page can also be accessed directly with the URL with method parameter as follows:

https://192.168.88.132/mob/?moid=ha-cli-handler-vm-process&method=list

Now, let’s cover a bit more on the URL pattern. Everything is pretty much the same as other URLs in MOB. The key here is the string after “moid=,” which is essentially the value of ManagedObjectReference. The string has two parts: one is the “ha-cli-handler-“ which is fixed for the esxcli related managed objects. The second part is the so called namespace. It has to be the leaf namespace (just think the namespaces as a tree) that does not have no “Available Namespaces:” when trying out the command on ESXi. The storage-filesystem, for example, is a leaf namespace but storage is not. When not sure, just type in the esxcli command. With a leaf namespace in esxcli command, you can replace the space with “-“, and compile a full URL. The URL for the storage filesystem URL is as follows:

https://192.168.88.132/mob/?moid=ha-cli-handler-storage-filesystem

While it’s not quite important on the type of the managed object, the type name for the above storage filesystem is “VimEsxCLIstoragefilesystem”. I am sure you can easily generalize a pattern out of it for the type names.

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

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>

  • NEED HELP?


    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__ doublecloud.org.

    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.