Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed hpilo_fw.download() to accept 'all' as wildcards #233

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion hpilo_fw.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Downloader / extracter for latest iLO2 / iLO3 / iLO4 firmware
# Downloader / extracter for latest iLO / iLO2 / iLO3 / iLO4 / iLO5 firmware
#
# (c) 2011-2018 Dennis Kaarsemaker <[email protected]>
# see COPYING for license details
Expand Down Expand Up @@ -43,6 +43,35 @@ def download(ilo, path=None, progress = lambda txt: None):
if not path:
path = os.getcwd()
conf = config()

#This block enables mass downloading of "all" firmware versions
#matching the behaviour provided in the cli:
#"all" downloads the latest firmware for each ilo type (per firmware.conf)
#"ilo2 all" downloads all firmwares available for ilo2
#"all all" downloads every firmware file in firmware.conf
if "all" in ilo:
#firstly, handle an 'all' for the ilo type
if ilo.startswith("all"):
majorversions = list(set([x.split(" ")[0] for x in conf.keys()]))
else:
majorversions = [ilo.split(" ")[0]]
#then handle an 'all' for firmware versione
if ilo == "all": #just the latest for each type
targetversions = majorversions
else:
targetversions = []
for majorversion in majorversions:
#include a space in the 'startswith' or the original ilo (no 1) matches everything.
minorversions = [x for x in conf.keys() if (x.startswith(majorversion+" ") or x == majorversion)]
targetversions = targetversions +minorversions

#then loop over the targeted versions
overallsuccess = False
for targetversion in targetversions:
responsecode = download(targetversion, path, progress)
overallsuccess = overallsuccess or responsecode
return overallsuccess

if not os.path.exists(os.path.join(path, conf[ilo]['file'])):
msg = "Downloading %s firmware version %s" % (ilo.split()[0], conf[ilo]['version'])
progress(msg)
Expand Down