Firmware updates over Redfish, per vendor
CI / agent (push) Successful in 3s
CI / site (push) Successful in 2s
CI / go (push) Successful in 39s

A firmware repository on the region (firmware_dir, served under
/firmware/<id>/<file>, cached by rack controllers for BMCs to pull),
each machine's firmware inventory (FirmwareInventory, classified into
bios/bmc/nic/raid/cpld/psu/drive), and update jobs (kind "firmware")
that the region drives with short rack commands: fw-start hands the
package over, fw-poll watches the task (tolerating a BMC that restarts),
fw-finish releases what was claimed, fw-inventory verifies the version.
Running updates resume after a region restart; they cannot be cancelled
once the BMC has the package.

Standard methods (multipart, SimpleUpdate pull, HttpPushUri) with known
Content-Length, plus vendor plans from their documentation or their own
tools: Dell MultipartUpload (OnReset), HPE SimpleUpdate with .fwpkg
extracted at import, Lenovo /mfwupdate with HttpPushUriTargetsBusy,
Supermicro /upload with targets and preserve options, GIGABYTE/AMI/
ASRock Rack /upload with OemParameters ImageType, OpenBMC
update-multipart, xFusion upload to /tmp/web then SimpleUpdate, KAYTUS
upload then OEM SimpleUpdate with fixed tasks, Fujitsu iRMC OEM actions;
Cisco CIMC is refused clearly (SCP only). fw_params and fw_method on
the BMC record override a plan.

CLI rollcall firmware list|import|rm|show|update, API, a Firmware tab
and a repository card in the UI. The lab Redfish emulator gains an
UpdateService (BMC applies at once, BIOS at the next reset).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-29 19:22:01 +01:00
1 parent 703b8f1b7b
commit b01d8e2b4d
17 files changed
+2663 -18

No files matched your search

+124 -6
View File
@@ -11,9 +11,19 @@ idrac / ilo / generic drivers see what real hardware shows:
Config: the pve-vbmc config.json; a bmcs entry may carry "redfish": "idrac"|"ilo"|"generic".
Basic auth with the same user/password as the IPMI side. Self-signed TLS.
Firmware (UpdateService), for testing rollcall's firmware jobs: idrac takes
multipart uploads and SimpleUpdate, ilo only SimpleUpdate (it downloads the
ImageURI itself), generic multipart. A "package" is any file with a line
"version=X"; a name with bios/rom/flash in it is the BIOS, anything else the
BMC. The BMC version changes when its task completes; the BIOS one at the next
reset of the VM, as on real servers. Versions are kept in
/var/lib/pve-vbmc/fw-<vmid>.json.
"""
import argparse
import base64
import email
import email.policy
import ipaddress
import json
import logging
@@ -35,11 +45,16 @@ log = logging.getLogger("pve-redfish")
PROFILES = {
"idrac": {"vendor": "Dell", "manufacturer": "Dell Inc.", "model": "PowerEdge R760 (pve)", "id": "System.Embedded.1",
"resets": ["On", "ForceOff", "ForceRestart", "GracefulRestart", "GracefulShutdown", "PushPowerButton", "Nmi", "PowerCycle"],
"actioninfo": False, "etag": True},
"actioninfo": False, "etag": True, "fw": {"multipart": "/redfish/v1/UpdateService/MultipartUpload", "simple": True,
"ids": {"bmc": "Installed-25227", "bios": "Installed-159"},
"names": {"bmc": "Integrated Dell Remote Access Controller", "bios": "BIOS"}}},
"ilo": {"vendor": "HPE", "manufacturer": "HPE", "model": "ProLiant DL380 Gen11 (pve)", "id": "1",
"resets": ["On", "ForceOff", "ForceRestart", "Nmi", "PushPowerButton"], "actioninfo": False, "etag": False},
"resets": ["On", "ForceOff", "ForceRestart", "Nmi", "PushPowerButton"], "actioninfo": False, "etag": False,
"fw": {"multipart": "", "simple": True, "ids": {"bmc": "1", "bios": "2"}, "names": {"bmc": "iLO 6", "bios": "System ROM"}}},
"generic": {"vendor": "", "manufacturer": "QEMU", "model": "Standard PC (pve)", "id": "1",
"resets": ["On", "ForceOff", "GracefulShutdown", "ForceRestart"], "actioninfo": True, "etag": False},
"resets": ["On", "ForceOff", "GracefulShutdown", "ForceRestart"], "actioninfo": True, "etag": False,
"fw": {"multipart": "/redfish/v1/UpdateService/update-multipart", "simple": False, "ids": {"bmc": "bmc", "bios": "bios"},
"names": {"bmc": "BMC firmware", "bios": "BIOS"}}},
}
@@ -82,7 +97,67 @@ class Pve:
return order
def make_handler(pve, prof, user, password):
class Firmware:
"""Installed versions, staged BIOS and update tasks of one emulated BMC."""
def __init__(self, vmid, prof):
self.path = f"/var/lib/pve-vbmc/fw-{vmid}.json"
self.prof = prof["fw"]
self.lock = threading.Lock()
self.tasks = {}
try:
self.v = json.load(open(self.path))
except (OSError, ValueError):
self.v = {"bmc": "1.0.0", "bios": "1.0.0", "staged_bios": ""}
def save(self):
os.makedirs(os.path.dirname(self.path), exist_ok=True)
json.dump(self.v, open(self.path, "w"))
def inventory(self):
return [{"@odata.id": f"/redfish/v1/UpdateService/FirmwareInventory/{self.prof['ids'][c]}-{self.v[c]}", "Id": f"{self.prof['ids'][c]}-{self.v[c]}",
"Name": self.prof["names"][c], "Version": self.v[c], "Updateable": True} for c in ("bmc", "bios")]
def start(self, name, data):
"""Begin flashing; returns the task id."""
comp = "bios" if any(w in name.lower() for w in ("bios", "rom", "flash")) else "bmc"
ver = ""
for line in data.decode(errors="replace").splitlines():
if line.startswith("version="):
ver = line.split("=", 1)[1].strip()
with self.lock:
tid = str(len(self.tasks) + 1)
self.tasks[tid] = {"state": "Running", "pct": 0, "msg": f"flashing {comp} {ver}"}
threading.Thread(target=self.flash, args=(tid, comp, ver), daemon=True).start()
log.info("firmware task %s: %s -> %s (%s)", tid, comp, ver or "?", name)
return tid
def flash(self, tid, comp, ver):
for pct in (10, 30, 60, 90):
time.sleep(4)
self.tasks[tid]["pct"] = pct
t = self.tasks[tid]
if not ver:
t.update(state="Exception", msg="the image is not valid for this system")
return
with self.lock:
if comp == "bmc":
self.v["bmc"] = ver
t.update(state="Completed", pct=100, msg=f"BMC firmware {ver} installed")
else:
self.v["staged_bios"] = ver
t.update(state="Completed", pct=100, msg=f"BIOS {ver} staged; it applies at the next reboot")
self.save()
def reset(self):
with self.lock:
if self.v.get("staged_bios"):
log.info("reset: BIOS %s applied", self.v["staged_bios"])
self.v["bios"], self.v["staged_bios"] = self.v["staged_bios"], ""
self.save()
def make_handler(pve, prof, user, password, fw):
sysid = prof["id"]
syspath = f"/redfish/v1/Systems/{sysid}"
state = {"override": "None", "enabled": "Disabled", "etag": 1}
@@ -150,6 +225,24 @@ def make_handler(pve, prof, user, password):
return self.send(200, self.system(), hdr)
if p == syspath + "/ResetActionInfo":
return self.send(200, {"Parameters": [{"Name": "ResetType", "Required": True, "AllowableValues": prof["resets"]}]})
if p == "/redfish/v1/UpdateService":
us = {"@odata.id": p, "ServiceEnabled": True, "FirmwareInventory": {"@odata.id": p + "/FirmwareInventory"}}
if fw.prof["multipart"]:
us["MultipartHttpPushUri"] = fw.prof["multipart"]
if fw.prof["simple"]:
us["Actions"] = {"#UpdateService.SimpleUpdate": {"target": p + "/Actions/UpdateService.SimpleUpdate",
"TransferProtocol@Redfish.AllowableValues": ["HTTP", "HTTPS"]}}
return self.send(200, us)
if p == "/redfish/v1/UpdateService/FirmwareInventory":
return self.send(200, {"Members": [{"@odata.id": e["@odata.id"]} for e in fw.inventory()]})
if p.startswith("/redfish/v1/UpdateService/FirmwareInventory/"):
for e in fw.inventory():
if e["@odata.id"] == p:
return self.send(200, e)
if p.startswith("/redfish/v1/TaskService/Tasks/"):
t = fw.tasks.get(p.rsplit("/", 1)[1])
if t:
return self.send(200, {"@odata.id": p, "TaskState": t["state"], "PercentComplete": t["pct"], "Messages": [{"Message": t["msg"]}]})
self.error(404, "not found")
def do_PATCH(self):
@@ -170,10 +263,33 @@ def make_handler(pve, prof, user, password):
state["etag"] += 1
self.send(204)
def task(self, tid):
loc = f"/redfish/v1/TaskService/Tasks/{tid}"
self.send(202, {"@odata.id": loc, "@odata.type": "#Task.v1_4_0.Task", "TaskState": "Running"}, {"Location": loc})
def do_POST(self):
if not self.authed():
return
if self.path.rstrip("/") != syspath + "/Actions/ComputerSystem.Reset":
p = self.path.split("?")[0].rstrip("/")
if fw.prof["multipart"] and p == fw.prof["multipart"]:
n = int(self.headers.get("Content-Length") or 0)
if n <= 0:
return self.error(411, "Content-Length required")
raw = self.rfile.read(n)
msg = email.message_from_bytes(b"Content-Type: " + self.headers["Content-Type"].encode() + b"\r\n\r\n" + raw, policy=email.policy.default)
for part in msg.iter_parts():
if part.get_param("name", header="content-disposition") == "UpdateFile":
return self.task(fw.start(part.get_filename() or "image", part.get_payload(decode=True)))
return self.error(400, "no UpdateFile part")
if fw.prof["simple"] and p == "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate":
uri = self.body().get("ImageURI", "")
try:
r = requests.get(uri, timeout=60)
r.raise_for_status()
except requests.RequestException as e:
return self.error(400, f"cannot download {uri}: {e}")
return self.task(fw.start(uri.rsplit("/", 1)[-1], r.content))
if p != syspath + "/Actions/ComputerSystem.Reset":
return self.error(404, "not found")
t = self.body().get("ResetType", "")
if t not in prof["resets"]:
@@ -190,6 +306,8 @@ def make_handler(pve, prof, user, password):
pve.post("status/shutdown", forceStop=1, timeout=60)
elif t in ("ForceRestart", "GracefulRestart", "PowerCycle"):
pve.post("status/reset" if on else "status/start")
if t in ("On", "ForceRestart", "GracefulRestart", "PowerCycle", "PushPowerButton"):
fw.reset() # a staged BIOS applies when the host starts again
self.send(204)
return H
@@ -223,7 +341,7 @@ def main():
addr = entry["address"]
user = entry.get("user", cfg.get("user", "admin"))
password = entry.get("password", cfg.get("password", "password"))
handler = make_handler(Pve(cfg, args.vmid), prof, user, password)
handler = make_handler(Pve(cfg, args.vmid), prof, user, password, Firmware(args.vmid, prof))
ip = ipaddress.ip_address(addr)
cls = Server6 if ip.version == 6 else ThreadingHTTPServer
srv = cls((addr, int(entry.get("redfish_port", 443))), handler)