esxcli is a new CLI (commandline interface) framework in vSphere that provides a modular architecture for various components called namespaces running in the VMkernel. Some of these namespaces are nmp (Native Multipathing Plugin) for the new VMware Pluggable Storage Architecture, corestorage for claim rules used for masking certain devices to a host, and swiscsi for managing iSCSI interface.
esxcli can be executed within the classic ESX Service Console, the unsupported Busybox console in ESXi or using the vCLI's remote version of esxcli. There are currently 3 namespaces (nmp,corestorage and swiscsi) with the current release of vSphere and we may see others introduced in future releases of vSphere. One important thing to note is that because these modules run within the host, using the vCLI's version of esxcli, you will need to authenticate to the host first to see what modules will be available for access. Currently, esxcli is not vCenter aware, meaning you must connect to a specific ESX or ESXi host when performing an operation.
Here is an example of esxcli executed without connecting to the host first:
Here is an example of esxcli being executed after connecting to the host:
When invoking the esxcli command, you may also notice an esxcli.log is generated. If the command is successfully executed, the log will generally be empty, but if there was an error you may want to take a look at esxcli.log if the command does not provide any output to the screen.
Here is an example of using an auth configuration file and because of the case sensitivity of esxcli, the VI_PROTOCOL entry is failing with HTTPS vs https:
[[email protected] ~]$ cat esxcli.log
[root CRITICAL] Exception:Unsupported protocol
[root CRITICAL] Traceback (most recent call last):
File "esxcli.py", line 387, in _GetStub
File "/vmware/esx40-dev/esx40/bora/vim/py/esxcli/Session.py", line 239, in stub
File "/vmware/esx40-dev/esx40/bora/vim/py/esxcli/Session.py", line 299, in Login
Exception: Unsupported protocol
There is not a whole lot of information available to the public about esxcli. From what I understand after talking to a few VMware engineers, esxcli has an API, but it is currently not exposed to the public for consumption. Not only is there an API, but 3rd party providers or users can potentially create their own modules and install it using the VIB format also known as vSphere Installation Bundle.
Some well known packages that are currently being distributed in the VIB format today are: Cisco Nexus 1000V VEM, HP Insight Manager Agent, EMC PowerPathV/E, Xsigo ESX IB drivers and VMware ESX/ESXi/vMA updates, to name a few. Hopefully in the future, VMware will expose the esxcli API functionality to the developer ecosystem.
Here are a few blog posts with detail examples on using esxcli with the various namespaces:
Stay tuned for Part2 and Part3 where we will look at automating esxcli operations using both the vSphere SDK for Perl and Windows PowerShell!
Ed Grigson says
I'm having issues getting the RCLI version of esxcli working. Commands which work fine on the local host don't work via the RCLI- for example;
esxcli corestorage (executed locally) returns prompts about the valid command lines
esxcli corestorage --server labsvr4.lab.co.uk -username root (from vMA) returns 'connect to localhost failed'. It also doesn't seem to work with vifastpass authentication.
Have you run into this at all?
Ed Grigson says
Doh! Don't you hate it when a minute after you comment you work it out?
I was using;
esxcli corestorage --server
when I should have been using;
esxcli --server corestorage
...which works fine! Sometimes command line syntax is very unforgiving!
Thanks .. i have a task and looking for powercli script.. i need to disable smartd on esx 6.0 u2 host as it is causing esx to non responding state. need to execute below commands ..
chkconfig smartd off
how can i integrate above command with power cli