VMware Cloud Community
MCioe
Enthusiast
Enthusiast
Jump to solution

What's the best way to get a customized version # out of an ESXi host?

Every quarter we generate a suite of updates (including patches and security scripts) that are manually run on our ESXi 5.0 hosts. I don't have internet connectivity so I have to do it this way.  I would like to be able to identify the latest quarterly update that has been run on the servers from vCenter and/or VI Client.

Right now, I'm thinking of appending the quarter, e.g. 1Q13 onto the DCUI message, then using PowerCLI at the vCenter to retrieve the DCUI message, parse it and paste the quarter into the Host Annotations field on vCenter.

Kind of ugly, but I can't figure out a cool way to get data like this out of the host.  I don't want to rely on my user manually updating anything, e.g. the Annotations field on vCenter, it's too error prone.

I would really like something that can also be seen on the VI Client, too, as annotations are only on vCenter.

I would appreciate any ideas on the best approach to tackle this.

Thanks,

0 Kudos
1 Solution

Accepted Solutions
MCioe
Enthusiast
Enthusiast
Jump to solution

Not sure if this is the best way, but this is what I ended up doing.   It feels like there should be a better way.

I updated my quarterly script to append it's version number to the bottom of the file, /etc/vmware/welcome, whenever it's run on an ESXi host (e.g. myScript version: v1.0 Date: 04June2013).  This file is displayed as the DCUI banner.

Then I wrote a powerCLI script to do roughly the following:

foreach ($vmHostObj in Get-VMHost -name *) {

     # Get the full DCUI message in /etc/vmware/welcome 

     $msgObj = echo $vmHostObj | Get-VMHostAdvancedConfiguration -name Annotations.WelcomeMessage

     # Convert the welcome message from a hashtable to a string

     $msgTxt = echo $msgObj.Item("Annotations.WelcomeMessage")

     # find the index for the string containing my script info, which is at the end of the welcome message,

     # this is significant because the substring function below will extract everything after the index.

     $idx = $msgTxt.IndexOf("myScript version:")

     if ($idx -gt 0) { 

          $label = $msgTxt.Substring($idx)

          Set-Annotation -Entity $vmHostObj -CustomAttribute Notes -Value $label

     }

}

This will overwrite the Notes field for each host, someday I may go back and make it more friendly where it replaces the version leaving the rest of the notes field intact.

View solution in original post

0 Kudos
6 Replies
a_nut_in
Expert
Expert
Jump to solution

How about the build number? That would change and increment with every update.

Also for the hosts, you can try

#vmware -v

or

#vmware -l

Another way of doing would be to check the vib's installed and making a list of changes per host

so you could do a

#esxcli software vib list

And this will give you a list of vib's installed

You could pipe it to a text file

#esxcli software vib list > list_host1.txt

So you could later do a "diff" to check if all hosts have similar vib's installed

You can also use powercli

http://communities.vmware.com/message/2176980

That script is to remove a vib but should be simple enough to list vib's installed as well

As to the Virtual Center, there are no "patch" releases for Virtual Center but "bundle" releases - so the build number can be taken as reference

Hope this helps!

Regards

a

Do remember to mark my post as "helpful" or "correct" if I've helped resolve or answer your query!
0 Kudos
peetz
Leadership
Leadership
Jump to solution

How about a PowerCLI script that determines the ESXi build number, translates that to the quarter-string (using a table that you need to provide) and then sets a vCenter custom attribute to this string?

- Andreas

Twitter: @VFrontDe, @ESXiPatches | https://esxi-patches.v-front.de | https://vibsdepot.v-front.de
0 Kudos
MCioe
Enthusiast
Enthusiast
Jump to solution

I don't think this will work.  First I have to assume there would always be a patch released by VMware every quarter which may not be the case.  Also, I would have to update the PowerCLI script on my vCenter computer each quarter to recognize the new VMware patch and to track the previous patches with previous quarters.  

My user community is not always up-to-date on their patching, which is why I have this problem in the first place.   I could easily run into a situation where the host has been updated, but the vCenter computer has not.

I think I'm still stuck with my ugly solution.

Thanks for the feedback,

Maureen

0 Kudos
MCioe
Enthusiast
Enthusiast
Jump to solution

Not sure if this is the best way, but this is what I ended up doing.   It feels like there should be a better way.

I updated my quarterly script to append it's version number to the bottom of the file, /etc/vmware/welcome, whenever it's run on an ESXi host (e.g. myScript version: v1.0 Date: 04June2013).  This file is displayed as the DCUI banner.

Then I wrote a powerCLI script to do roughly the following:

foreach ($vmHostObj in Get-VMHost -name *) {

     # Get the full DCUI message in /etc/vmware/welcome 

     $msgObj = echo $vmHostObj | Get-VMHostAdvancedConfiguration -name Annotations.WelcomeMessage

     # Convert the welcome message from a hashtable to a string

     $msgTxt = echo $msgObj.Item("Annotations.WelcomeMessage")

     # find the index for the string containing my script info, which is at the end of the welcome message,

     # this is significant because the substring function below will extract everything after the index.

     $idx = $msgTxt.IndexOf("myScript version:")

     if ($idx -gt 0) { 

          $label = $msgTxt.Substring($idx)

          Set-Annotation -Entity $vmHostObj -CustomAttribute Notes -Value $label

     }

}

This will overwrite the Notes field for each host, someday I may go back and make it more friendly where it replaces the version leaving the rest of the notes field intact.

0 Kudos
MCioe
Enthusiast
Enthusiast
Jump to solution

I ran into on more difficulty related to this solution.  It seems to me that vCenter was caching results from the Get-VMHostAdvancedConfiguration -name Annotations.WelcomeMessage call.

During my testing I observed that this data did not change in vCenter, until I rebooted the server.

I executed the PowerCLI command on vCenter and retrieved the WelcomeMessage info.  Then, I updated the /etc/vmware/welcome file on the host and when I executed the powercli command on vCenter a second time the old data was returned.  For over the a week, I tried several things including, closing and reopening Powershell, issuing a set command on a different variable to see if I could force vCenter to go to the host, but had no luck until the reboot.  The data was stale for over a week as it took me that long to get around to rebooting the server.

For me, rebooting the server is not the end of the world, because I always reboot it anyway when I do these updates, but I would think VMware should look into this.

0 Kudos
MCioe
Enthusiast
Enthusiast
Jump to solution

One more thing, that I found helpful.  A simple way to see all the parameters available in the Get-VMHostAdvancedConfiguration command, is the following.

     Get-VMHost -name vm_name | Get-VMHostAdvancedConfiguration -name * | format-list > results.txt

You get a simple, complete list that is easy to read.

0 Kudos