Comparing installed ESXi vibs before and after patching

When installing ESXi patches from the commandline, certainly when  a patch contains multiple packages (vibs) to be updated, you need a way to quickly check if all the updates really have been installed.

There are several ways to do this. I will show two ways below using the esxcli and diff commands.
I will be using in /vmfs/volumes/datastore01/Update as the patch to be installed.

Method 1 Esxcli and diff

Query with esxcli for a list of all installed vibs and redirect the output to a file.  Personally I prefer to give the output the name of the update followed by before or after the installation of the patch.

esxcli software vib list > ESXi510-201305001.before

Now proceed to install the patch as usual.

After patching save the list of installed vibs:

esxcli software vib list > ESXi510-201305001.after

The differences introduced by the patch can be found by comparing the two text files. In this example ESXi510-201305001.before and ESXi510-201305001.after.

diff -U0 -b ESXi510-201305001.before ESXi510-201305001.after

Remark: The -U 0 does not print context lines surrounding the detected changes making the result easier to analyze and the -b ignores changes in the amount of whitespace.

The result will resemble something like this:

--- ESXi510-201305001.before
+++ ESXi510-201305001.after
@@ -2 +2 @@
------------------------------  ----------------------------------  ------  ----------------  ------------
+-----------------------------  ------------------------------------  ------  ----------------  ------------
@@ -13 +13 @@
-esx-base                       5.1.0-0.9.914609                    VMware  VMwareCertified   2013-02-16  
+esx-base                       5.1.0-1.13.1117900                    VMware  VMwareCertified   2013-06-02  
@@ -17 +17 @@
-esx-xserver                    5.1.0-0.0.799733                    VMware  VMwareCertified   2012-10-07  
+esx-xserver                    5.1.0-0.11.1063671                    VMware  VMwareCertified   2013-06-02  

<more output removed for brevity>

The above output shows esx-base has upgraded from 5.1.0-0.9.914609 to 5.1.0-1.13.1117900 and that esx-xserver has upgraded from 5.1.0-0.0.799733 to 5.1.0-0.11.1063671.

Method 2 Esxcli and grep

List the the vibs from the patch with esxcli software sources vib list. This will show which vibs are an update compared to the currently installed vibs.

esxcli software sources vib list -d /vmfs/volumes/datastore01/Updates/

Grep for “Update” if you only want to see the updates.

esxcli software sources vib list -d /vmfs/volumes/datastore01/Updates/|grep Update

If the patch contains updates the output will resemble:

esx-base                       5.1.0-1.13.1117900                    VMware  2013-05-01     VMwareCertified   Update
esx-xserver                    5.1.0-0.11.1063671                    VMware  2013-03-22     VMwareCertified   Update   
<more output removed for brevity>

Proceed to install the patch.

List the the vibs from the patch with esxcli software sources vib list again. This time all vibs should have a status of installed.

esxcli software sources vib list -d /vmfs/volumes/datastore01/Updates/

A grep for Update should return no results.

esxcli software sources vib list -d /vmfs/volumes/datastore01/Updates/|grep Update