The esxcli is a command tool that is available on VMware ESXi for managing ESXi. Unlike the vim-cmd command, it focuses on underlying infrastructure and touches lower level of controls of the ESXi hypervisor itself. Although it’s just one command, it packs a lot of functionalities with different namespaces/sub-namespaces, and sub-commands. Because they are organized in nice tree hierarchy, it’s actually quite easy to use most times.
APD stands for all path down. It’s a storage issue that is discussed in VMware KB article Intermittent NFS APDs on VMware ESXi 5.5 U1 (2076392). You can install a patch to address the issue with ESXi 5.5.
It’s pretty easy to create a new user using vSphere APIs in Java. If you want one or two lines of scripts, you can write a few line Python script using PyVimomi wrapped by a command line. Even easier is a solution discussed at PureVirtual.
The trick is really about how to access the adduser command, which is available but not accessible from console as it is. To use the command, you have to type the following command from ESXi console: (I assume there are a few more commands that can be used in the same way)
VMware has evaluation license for ESXi servers. After 60 days, it expires and you have to apply a paid or free license to continue. Technically, there is a trick to reset the evaluation key by deleting two files (/etc/vmware/vmware.lic and /etc/vmware/license.cfg) and rebooting the server. It’s of course not complying with VMwrae license terms. Under some circumstances like training lab, it may be OK. Make sure to consult VMware on this if you are not working for VMware. But wait – if you are working for VMware, do you need evaluation license? In his reply to my tweet, Duncan mentioned he never saw license expiration.
Although VMware ESXi supports common Linux commands, its implementation is based on busybox. Some of the commands are not supported, or functionalities are reduced. Setting time is one of the cases.
To find out the current time, you issue the following command:
~ # date Sun Jul 13 10:50:59 UTC 2014
Now if you want to use the same date command to change the time, it’s a different story. In fact, the help of the date command works as normal, but when you really type in full command, you’ll see it won’t work.
Happy New Year 2014!
When adding a new ESXi host to vCenter server via vSphere API, you can supply the certificate thumbprint of the ESXi server expected to have. Before calling the vSphere API, you can get the thumbprint directly or indirectly from the ESXi server to be added. Here are three different ways to do that. The first two approaches retrieve SSL certificate with which you can generate thumbprint.
I just got into a very interesting problem recently – the vim-cmd does not work as expected when used for renaming a datastore in vSphere.
What is the problem exactly?
The following command, for example, should change the name of a datastore from datastore1 (which is the default datastore name) to doublecloudDS.
# vim-cmd hostsvc/datastore/rename datastore1 doubecloudDS
After the command is executed, there is no error message reported. But the datastore name remains the same as shown in either the vSphere Client or using the following command:
In my recent consulting projects, I really got into a lot of scripting either command lines or Python with ESXi management. As I mentioned the hidden HTML formatter in esxcli command, you may have speculated what could the usage. The answer is simple: Web. But it’s not quite clear how it can be used. That’s where my curiosity started.
For those who run ESXi on a virtual machine, it’s a great news that VMware has released VMware Tools for nested ESXi as a fling in VMware Labs. Why? With the VMware Tools, you can get guest OS (really the ESXi here) information, like the IP address directly. It may sounds trivial as you can see the IP address from the virtual machine console of a virtualized ESXi. But for automation, it’s pretty hacky to get it programatically. Some people may wonder, “why not run commands via SSH?” It’s true that it’s easy to get the IP by running esxcli command, but you have to get IP first before running the command. With the VMware Tools, you can easily get the IP from vSphere Java API as would with any other normal virtual machines. Even more, you can also run commands like vim-cmd/esxcli in the virtual ESXi via APIs.
Besides the vim-cmd command I covered earlier, there is another powerful set of commands in ESXi – esxcli. As you can find from the help of the command, it covers 10 namespaces and drills down several layers down. The typical operations with the namespaces are get, set, and list. If you are familiar with REST API, you can think of the bottom level namespaces are resources.
If you have read my previous article on the vim-cmd, you may have realized how handy it is, especially when it comes to manage virtual machines. There is however a pretty challenging problem to use it – for most commands for a virtual machine, it requires vmid which is an integer that uniquely identifies the virtual machine in the context of an ESXi server. It’s like primary key in SQL database to locate a record (virtual machine instance) in a table (virtual machine type). For people who are familiar with vSphere APIs, the vmid is the same as the value of ManagedObjectReference value of a virtual machine in ESXi. Because most administrators who use commands are not necessarily familiar with vSphere API, it doesn’t help much.
vSphere Client and vSphere Web Client allow administrators to download system logs from different ESXi hosts with choices of predefined groups of information like System, Storage, Network, UserWorld, etc. Under each group, there could be multiple types. For example, under the UserWorld, there are HostAgent and ProcessInformation.
As a powerful virtualization server, ESXi has a built-in SSH server even though it’s not enabled by default. That is what most system adminstrators use to remotely run commands there. ESXi also has a built-in SSH client so that you can ssh to other servers from ESXi. To use SSH as either server or client, you need to open up firewall. You can use vSphere Client to do it ( on host’s Configuration tab, check out the Security Profile in Software section), or simple with command line as follows.
Command lines are very important for system administrors when it comes to automation. Although GUIs are more likely (not always as I’ve seen too many bad ones) to be more intuitive and easier to get started with, sooner or later administrators will use command lines more for better productivity. Check out DoubleCloud ICE if you want the best of both GUI and command lines.
Libvirt is an open source project for managing almost all hypervisors and containers. It’s implemented in C and can be exposed through different language bindings.
There are both server (a.k.a daemon or agent) and client. If you are familiar with VMware vSphere (I assume you are if you read my blog), the server is very much like the hostd running on the ESXi side. The client is like the VI Java API that can be used for remote management.
Even if you haven’t heard about BusyBox, you may have used it. It runs in every ESXi, which doesn’t have a full OS as console like classic ESX. Still, you need an easy way to interact the hypervisor directly. So the ESXi includes a tiny console that uses BusyBox (reduced version) due to its small size.
The BusyBox has been ported to Windows as well. You can download the 600+K executable here. It’s really a simple exe file and you can place it anywhere.
In a recent experiment, I needed to get the VMware Tools installer. Somehow after searching many different places, I couldn’t find it. While writing this article, I found a link to all the installers organized per ESX versions and CPU architectures. The installers are single files, different from an installable CD which I hacked.
Yesterday the VMware community noticed that the direct ESX download links were removed from vSphere download page. When I checked the download page, the ESX link is not with the bundles but at the end of the page in its own section.
To my own curiosity, I wonder what the adoption ratio of these two hypervisors is today. As an engineer, I don’t have sales data in front of me. Even I have, I am sure if I can share it here.
Instead, I tried
VMware ESX and ESXi (a.k.a. vSphere Hypervisor) support the most guest operating systems among all the hypervisors. From the vSphere API, you can determine what operating system is installed on a virtual machine.
The related managed object is the VirtualMachine and there are multiple ways to
With a vSphere Client, you can easily check the memory information of a host, either ESX or ESXi. To get that, you click on a host from the inventory tree, and then configuration tab. From the left side Hardware section of the configuration page, you click Memory and see a pane displaying the memory info as follows:
Note that if you have chosen a ESXi host, you won’t see the Service Console part because there is no console OS any more in ESXi. BTW, VMware wants you to migrate from ESX to ESXi and here is a link with helps.
This seemingly easy information is actually not easy to get. At first glance, it should be in the config property of HostSystem (managed object representing an ESX or ESXi). The config property has a sub property called systemResources, typed as HostSystemResourceInfo. But you will get null for the systemResources property most, if not all, of the time, as reported in VI Java API forum.
Interestingly enough, HostSystem has a systemResources property in peer to the config property as well. Luckily, it’s not null so you can dig down for something. Still, with 3 sub properties of complex types included, how to get the memory from the data object?
Here are the steps to collect and calculate the numbers: