Unattended upgrade of HP mgmt agents – Part 2

It’s been a year since I blogged about my script to perform an unattended upgrade of the HP management agents 8.1.1 on ESX 3.5 U3. After HP upgraded their management agents to version 8.2.0 some things changed. The installation procedure is now a 2 step process. First there’s a PreInstall_Setup.sh script which modifies some startup scripts on your host and will perform a reboot if an IPMI device is found. After the reboot you have to install the management agents as usual. 

The script below is for installing the HP management agents version 8.3.0 for ESX 3.5 U4 and ESX3.5 U5. It probably can also be used for version 8.2.0., but I haven’t tested this. If you require an older version of the HP management agents, use my previous script. You might think I’m getting a bit old school still running ESX3.5 but hold on. I also have a version 3.0 of this script for installing HP management agents version 8.3.1 on ESX4.0 and ESX4.0U1, but it still needs a little work. I’ll publish this very soon, so keep an eye on this site for the next few days.

The extra reboot needed before the actual installation makes an unattended installation a bit more challenging. But don’t be afraid we won’t let this hold us back from automating it. I’ll show you how I modified my unattend script to get the job done again. 

First I inserted a little piece of code to warn you about the necessary host reboot and let you choose if you want to continue. 

# +-----------------------------------------------------+
# | Warn about the reboot                               |
# +-----------------------------------------------------+

SETCOLOR_YELLOW="echo -en \\033[1;33m"
SETCOLOR_RED="echo -en \\033[0;31m"
SETCOLOR_WHITE="echo -en \\033[0;39m"

$SETCOLOR_YELLOW
echo "This update requires a reboot! "
echo -n "Do you wish to continue (y/n) "
	read answer
	if [ "$answer" != "y" ]; then
		echo "Action cancelled by user"
		$SETCOLOR_WHITE
		exit
	fi
$SETCOLOR_WHITE

Next thing to check is if the host is in maintenance mode. Just to make sure the host isn’t rebooted with running virtual machines on it.

# +-----------------------------------------------------+
# | Check if host is in Maintenance mode                |
# +-----------------------------------------------------+

if [ `vimsh -n -e hostsvc/runtimeinfo | grep -i "inMaintenanceMode = false" | wc -l` == 1 ]; then
	$SETCOLOR_RED
	echo -e "\nHost must be in Maintenance Mode, exiting...\n\n"
	$SETCOLOR_WHITE
	exit
fi

Everything looks ok, so let’s download the required files and uninstall the old management agents. There’s nothing changed in this code from the previous version.

# +-----------------------------------------------------+
# | Download files                                      |
# +-----------------------------------------------------+

/usr/sbin/esxcfg-firewall --allowOutgoing

lwp-download http://repository.mydomain.com/hpagents/$HPPACKAGE /tmp/$HPPACKAGE
lwp-download http://repository.mydomain.com/hpagents/$HBAPACKAGE /tmp/$HBAPACKAGE
lwp-download http://repository.mydomain.com/hpagents/$HPCONFIG /tmp/$HPCONFIG
lwp-download http://repository.mydomain.com/hpagents/$HPSMHCONFIG /tmp/$HPSMHCONFIG

/usr/sbin/esxcfg-firewall --blockOutgoing

# +-----------------------------------------------------+
# | Unpack archives                                     |
# +-----------------------------------------------------+

cd /tmp
tar -zxvf $HPPACKAGE
mkdir /tmp/hbaapi
tar -C /tmp/hbaapi -zxvf $HBAPACKAGE
cp /tmp/$HPSMHCONFIG /tmp/hpmgmt/$HPVERSION/smhpd.xml

# +-----------------------------------------------------+
# | Uninstall old packages                              |
# +-----------------------------------------------------+

cd /tmp/hpmgmt/$HPVERSION
echo -e 'y\ny' | ./installvm${HPVERSION}.sh --uninstall
cd /tmp/hbaapi
./Remove.sh

We can only install the new agents after the PreInstall_Setup.sh script has run and the system is rebooted. Therefore we have to put the actual installation code of the new management agents inside the /etc/rc.d/rc.local script, which is automatically run every time the host starts up. But before we make any changes to this file we create a backup, which we will restore after the installation is done.

# +-----------------------------------------------------+
# | Modify rc.local to start installxxx.sh script       |
# +-----------------------------------------------------+

# Backup original rc.local file
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak

# Modify rc.local to start hpagent setup after the reboot
cat >> /etc/rc.d/rc.local < /root/hpmgmt-install.log 2>&1

# Restore original rc.local file
mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local
EOF

The only thing left is installing the HBAAPI libraries and run the PreInstall_Setup.sh script. The HBAAPI libraries can be downloaded from the following sites: 

Emulex
http://www.emulex.com/downloads/emulex/cnas-and-hbas/drivers/vmware.html

QLogic
http://driverdownloads.qlogic.com/QLogicDriverDownloads_UI/SearchByOs.aspx?ProductCategory=39&OsCategory=6&Os=167&OsCategoryName=VMware&ProductCategoryName=Fibre Channel Adapters&OSName=VMware ESX / ESXi 

# +-----------------------------------------------------+
# | Install HBAAPI libraries and start PreInstall script|       |
# +-----------------------------------------------------+

cd /tmp/hbaapi
./Install.sh

cd /tmp/hpmgmt/$HPVERSION
echo -e 'y' | ./PreInstall_Setup.sh

#Force reboot if PreInstall script detects no IPMI device on this system
shutdown -r now "System shutdown as preinstall operation for agents installation"

As far as I could see, nothing changed in the hpmgmt.conf and smhpd.xml files, so you can reuse them. If you’re new to this read my previous post on how to acquire these files. 

And finally the complete script:

#!/bin/sh
# +-----------------------------------------------------+
# | HP Insight Manager Agents unattend install Script   |
# |                                                     |
# | Version : 2.0                                       |
# | Author  : Arnim van Lieshout                        |
# +-----------------------------------------------------+

# version 2.0
# ==========
# This script only supports HP management agents 8.3.0
#
# If you require version 8.1.1 download version 1.0 of this script from:
# http://www.van-lieshout.com/2009/03/unattended-upgrade-of-hp-management-agents/

# +-----------------------------------------------------+
# | Setting some variables                              |
# +-----------------------------------------------------+

HPPACKAGE=hpmgmt-8.3.0-vmware3x.tgz
HBAPACKAGE=qlapi_vmw-v4.00build23.tgz
HPVERSION=830
HPCONFIG=hpmgmt${HPVERSION}.conf
HPSMHCONFIG=smhpd${HPVERSION}.xml

# +-----------------------------------------------------+
# | Warn about the reboot                               |
# +-----------------------------------------------------+

SETCOLOR_YELLOW="echo -en \\033[1;33m"
SETCOLOR_RED="echo -en \\033[0;31m"
SETCOLOR_WHITE="echo -en \\033[0;39m"

$SETCOLOR_YELLOW
echo "This update requires a reboot! "
echo -n "Do you wish to continue (y/n) "
	read answer
	if [ "$answer" != "y" ]; then
		echo "Action cancelled by user"
		$SETCOLOR_WHITE
		exit
	fi
$SETCOLOR_WHITE

# +-----------------------------------------------------+
# | Check if host is in Maintenance mode                |
# +-----------------------------------------------------+

if [ `vimsh -n -e hostsvc/runtimeinfo | grep -i "inMaintenanceMode = false" | wc -l` == 1 ]; then
	$SETCOLOR_RED
	echo -e "\nHost must be in Maintenance Mode, exiting...\n\n"
	$SETCOLOR_WHITE
	exit
fi

# +-----------------------------------------------------+
# | Download files                                      |
# +-----------------------------------------------------+

/usr/sbin/esxcfg-firewall --allowOutgoing

lwp-download http://repository.mydomain.com/hpagents/$HPPACKAGE /tmp/$HPPACKAGE
lwp-download http://repository.mydomain.com/hpagents/$HBAPACKAGE /tmp/$HBAPACKAGE
lwp-download http://repository.mydomain.com/hpagents/$HPCONFIG /tmp/$HPCONFIG
lwp-download http://repository.mydomain.com/hpagents/$HPSMHCONFIG /tmp/$HPSMHCONFIG

/usr/sbin/esxcfg-firewall --blockOutgoing

# +-----------------------------------------------------+
# | Unpack archives                                     |
# +-----------------------------------------------------+

cd /tmp
tar -zxvf $HPPACKAGE
mkdir /tmp/hbaapi
tar -C /tmp/hbaapi -zxvf $HBAPACKAGE
cp /tmp/$HPSMHCONFIG /tmp/hpmgmt/$HPVERSION/smhpd.xml

# +-----------------------------------------------------+
# | Uninstall old packages                              |
# +-----------------------------------------------------+

cd /tmp/hpmgmt/$HPVERSION
echo -e 'y\ny' | ./installvm${HPVERSION}.sh --uninstall
cd /tmp/hbaapi
./Remove.sh

# +-----------------------------------------------------+
# | Modify rc.local to start installxxx.sh script       |
# +-----------------------------------------------------+

# Backup original rc.local file
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak

# Modify rc.local to start hpagent setup after the reboot
cat >> /etc/rc.d/rc.local < /root/hpmgmt-install.log 2>&1

# Restore original rc.local file
mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local
EOF

# +-----------------------------------------------------+
# | Install HBAAPI libraries and start PreInstall script|       |
# +-----------------------------------------------------+

cd /tmp/hbaapi
./Install.sh

cd /tmp/hpmgmt/$HPVERSION
echo -e 'y' | ./PreInstall_Setup.sh

#Force reboot if PreInstall script detects no IPMI device on this system
shutdown -r now "System shutdown as preinstall operation for agents installation"

You can also download a copy of the script here.

Always test this in a test environment first before using it in production. I don’t take any responsibilities for things that might happen to your ESX servers due to using this script.

Related posts:

  1. Unattended upgrade of HP management agents Tweet After upgrading to ESX 3.5 to update3, I found out that the HP management agents needed to be upgraded to version 8.1.1, since this version supports ESX3.5 update3. So...
  2. VMware ESX(i) 3.5 Update4 released Tweet VMware has released ESX(i) 3.5 update4. Do not forget to read the release notes here or you can go to the download page here While going through the release notes...
  3. Monitor ESX datastores using Hostmonitor Tweet A lot of customers I worked with use Advanced Hostmonitor from KS-Soft to monitor their Windows environment. So is the customer I  am currently working at. Advanced Hostmonitor is...
  4. How to force a login on a QLogic HBA Tweet When running some storage test on an ESX 3.5 environment lately, I ran into a problem where a dead storage path disappeared after a rescan. While this was as...

1 Comment on “Unattended upgrade of HP mgmt agents – Part 2”

  1. #1 Unattended upgrade of HP management agents - Part 3 | Arnim van Lieshout
    on Mar 18th, 2010 at 10:01 am

    [...] upgrade of HP mgmt agents – Part 3 Mar 18th, 2010 by Arnim van Lieshout. In my post Unattended upgrade of HP mgmt agents – Part 2 you could read about my script for an unattended installation of the HP Management agents on [...]

Leave a Comment