Dealing with iLO firmware updates

One of the key features of python_hpilo is that it makes iLO firmware updates painless. It can download the firmware for you, or you can feed it the .bin or .scexe files HP ships.

From the CLI

The method to call is update_rib_firmware(). To tell it which firmware version to install, you can specify a version or a filename. To install the latest version, you can use latest as version. Information about available version numbers can be found in firmware.conf.

Some example commands:

hpilo_cli example-server.int.kaarsemaker.net update_rib_firmware version=1.28
hpilo_cli example-server.int.kaarsemaker.net update_rib_firmware version=latest
hpilo_cli example-server.int.kaarsemaker.net update_rib_firmware filename=CP007684.scexe
hpilo_cli example-server.int.kaarsemaker.net update_rib_firmware filename=ilo2_225.bin

If you just want to download the firmware, you can make hpilo_cli do that too:

hpilo_cli download_rib_firmware all        # Download latest firmware for all iLO types
hpilo_cli download_rib_firmware ilo4       # Download latest iLO 4 firmware
hpilo_cli download_rib_firmware ilo4 1.50  # Download a specific firmware version
hpilo_cli download_rib_firmware ilo4 all   # Download all firmware versions for iLO 4

Using the API

As the CLI is merely a thin wrapper around the API, using the API is as expected:

ilo = hpilo.Ilo(hostname, login, password)
ilo.update_rib_firmware(version='latest')

But since firmware updates may take a while, the iLO can provide progress messages, which your code may in turn show to your users. To receive these progress message, pass a callable to the update_rib_firmware() function. It will be called with single-line messages about the progress of the firmware download, upload and flash processes. This example shows them to the user, constantly overwriting the previous message:

def print_progress(text):
    sys.stdout.write('\r\033[K' + text)
    sys.stdout.flush()

ilo = hpilo.Ilo(hostname, login, password)
ilo.update_rib_firmware(version='latest', progress=print_progress)
print("")

Of course the firmware downloader can be used from the API as well:

import hpilo_fw
hpilo_fw.download('ilo4', path='/var/cache/ilo_fw/', progress=print_progress)
hpilo_fw.download('ilo3 1.28', path='/var/cache/ilo_fw', progress=print_progress)