Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e300c740e | ||
|
|
0598a183df |
No files matched your search
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.19.0] - 2026-11-28
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `install_cpu_microcode()` on both drivers (napalm-device-types' `CpuMicrocodeMixin`, 4.53.0,
|
||||||
|
NetOrk/netork#2838): the CPU vendor's microcode on a node that runs on its own CPU. A Proxmox
|
||||||
|
install enables no `non-free-firmware`, where Debian keeps `intel-microcode` and
|
||||||
|
`amd64-microcode`: it is added to Debian's own sources (never to Proxmox's or another
|
||||||
|
vendor's), the index is loaded with `apt-get update` over the exec path -- waited for, unlike
|
||||||
|
the API's refresh task -- and the package installed. Refused on a node that runs virtualized
|
||||||
|
(a PBS in a VM): its host loads the microcode. The microcode loads at the next boot.
|
||||||
|
- The hardening reading carries `virtualization` and `cpu_vendor` (napalm-device-types 4.53.0).
|
||||||
|
|
||||||
## [0.18.0] - 2026-11-28
|
## [0.18.0] - 2026-11-28
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ device = driver(
|
|||||||
| `get_services_need_restart` | the services that still run code an update replaced on disk, as root over SSH (napalm-device-types' `ServicesRestartMixin`): `needrestart` in list-only mode where it is installed, else the processes whose `/proc/<pid>/maps` maps deleted code. A running VM's QEMU is a process (`processes`), an LXC container's processes are left out (the container updates itself). Only as root: another SSH login gets no reading, rather than a clean one |
|
| `get_services_need_restart` | the services that still run code an update replaced on disk, as root over SSH (napalm-device-types' `ServicesRestartMixin`): `needrestart` in list-only mode where it is installed, else the processes whose `/proc/<pid>/maps` maps deleted code. A running VM's QEMU is a process (`processes`), an LXC container's processes are left out (the container updates itself). Only as root: another SSH login gets no reading, rather than a clean one |
|
||||||
| `get_pve_firewall` | the PVE firewall as the operator wrote it, read only (NetOrk/netork#2654): the datacenter's `options`, `rules`, security `groups` (name → rules), `ipsets` (name → `[{cidr, nomatch, comment}]`) and `aliases` (name → cidr), this node's `options` and `rules`, and every guest's on this node (`vmid`, `type`, `name`, `options`, `rules`, and `nics`: `[{name, firewall}]` from `netN … firewall=1`). Each rule keeps PVE's fields and its `origin` (`cluster`, `group`, `node`, `guest`). A part PVE refuses is `null`, never empty |
|
| `get_pve_firewall` | the PVE firewall as the operator wrote it, read only (NetOrk/netork#2654): the datacenter's `options`, `rules`, security `groups` (name → rules), `ipsets` (name → `[{cidr, nomatch, comment}]`) and `aliases` (name → cidr), this node's `options` and `rules`, and every guest's on this node (`vmid`, `type`, `name`, `options`, `rules`, and `nics`: `[{name, firewall}]` from `netN … firewall=1`). Each rule keeps PVE's fields and its `origin` (`cluster`, `group`, `node`, `guest`). A part PVE refuses is `null`, never empty |
|
||||||
| `get_host_firewall` | what the node has loaded, as for any Linux host (napalm-device-types' `HostFirewallMixin`): `nft list ruleset` (PVE 9's proxmox-firewall) or `iptables-save` (pve-firewall), as root over SSH |
|
| `get_host_firewall` | what the node has loaded, as for any Linux host (napalm-device-types' `HostFirewallMixin`): `nft list ruleset` (PVE 9's proxmox-firewall) or `iptables-save` (pve-firewall), as root over SSH |
|
||||||
| `get_hardening` | how the node is hardened (napalm-device-types' `HardeningMixin`, NetOrk/netork#2776): security modules, SELinux and AppArmor, crypto policy, FIPS mode, CPU vulnerabilities, kernel command line, as root over SSH. On the backup server too |
|
| `get_hardening` | how the node is hardened (napalm-device-types' `HardeningMixin`, NetOrk/netork#2776): security modules, SELinux and AppArmor, crypto policy, FIPS mode, CPU vulnerabilities, kernel command line, whether the node runs virtualized and its CPU vendor, as root over SSH. On the backup server too |
|
||||||
|
| `install_cpu_microcode` | the CPU vendor's microcode (`intel-microcode`, `amd64-microcode`; napalm-device-types' `CpuMicrocodeMixin`, NetOrk/netork#2838): Debian's `non-free-firmware` added to Debian's own sources where missing, `apt-get update` over SSH (waited for, unlike the API's refresh task), then the install. Refused on a node that runs virtualized. Loads at the next boot. On the backup server too |
|
||||||
|
|
||||||
**Not implemented** (raise `NotImplementedError`):
|
**Not implemented** (raise `NotImplementedError`):
|
||||||
`get_bgp_config`, `get_bgp_neighbors`, `get_bgp_neighbors_detail`,
|
`get_bgp_config`, `get_bgp_neighbors`, `get_bgp_neighbors_detail`,
|
||||||
@@ -256,7 +257,7 @@ tests/
|
|||||||
├── test_time_sync.py # get_time_sync / configure_time_sync on both drivers
|
├── test_time_sync.py # get_time_sync / configure_time_sync on both drivers
|
||||||
├── test_certificates.py # get_certificates on both drivers
|
├── test_certificates.py # get_certificates on both drivers
|
||||||
├── test_firewall.py # get_pve_firewall and get_host_firewall
|
├── test_firewall.py # get_pve_firewall and get_host_firewall
|
||||||
├── test_hardening.py # get_hardening on both drivers
|
├── test_hardening.py # get_hardening and install_cpu_microcode on both drivers
|
||||||
├── test_utils.py # Unit tests for napalm_proxmox.utils
|
├── test_utils.py # Unit tests for napalm_proxmox.utils
|
||||||
├── fixtures/pbs_api.json # What a Proxmox Backup Server 4.2 answered (sanitised)
|
├── fixtures/pbs_api.json # What a Proxmox Backup Server 4.2 answered (sanitised)
|
||||||
├── pbs_fake.py # A proxmoxer stand-in answering from that recording
|
├── pbs_fake.py # A proxmoxer stand-in answering from that recording
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ from typing import Any
|
|||||||
from napalm_device_types import (
|
from napalm_device_types import (
|
||||||
AptProxyMixin,
|
AptProxyMixin,
|
||||||
BackupServerDriver,
|
BackupServerDriver,
|
||||||
|
CpuMicrocodeMixin,
|
||||||
EnsurePackageMixin,
|
EnsurePackageMixin,
|
||||||
FingerprintRule,
|
FingerprintRule,
|
||||||
HardeningMixin,
|
HardeningMixin,
|
||||||
@@ -77,6 +78,7 @@ class ProxmoxBackupDriver(
|
|||||||
HostStatusMixin,
|
HostStatusMixin,
|
||||||
LicenseMixin,
|
LicenseMixin,
|
||||||
ProxmoxZabbixAgentMixin,
|
ProxmoxZabbixAgentMixin,
|
||||||
|
CpuMicrocodeMixin,
|
||||||
EnsurePackageMixin,
|
EnsurePackageMixin,
|
||||||
AptProxyMixin,
|
AptProxyMixin,
|
||||||
OpenSshServerMixin,
|
OpenSshServerMixin,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ from typing import Any
|
|||||||
from napalm.base.exceptions import ConnectionException
|
from napalm.base.exceptions import ConnectionException
|
||||||
from napalm_device_types import (
|
from napalm_device_types import (
|
||||||
AptProxyMixin,
|
AptProxyMixin,
|
||||||
|
CpuMicrocodeMixin,
|
||||||
EnsurePackageMixin,
|
EnsurePackageMixin,
|
||||||
FingerprintRule,
|
FingerprintRule,
|
||||||
HardeningMixin,
|
HardeningMixin,
|
||||||
@@ -121,6 +122,7 @@ class ProxmoxDriver(
|
|||||||
LicenseMixin,
|
LicenseMixin,
|
||||||
SnmpAgentMixin,
|
SnmpAgentMixin,
|
||||||
ProxmoxZabbixAgentMixin,
|
ProxmoxZabbixAgentMixin,
|
||||||
|
CpuMicrocodeMixin,
|
||||||
EnsurePackageMixin,
|
EnsurePackageMixin,
|
||||||
AptProxyMixin,
|
AptProxyMixin,
|
||||||
OpenSshServerMixin,
|
OpenSshServerMixin,
|
||||||
|
|||||||
@@ -261,6 +261,14 @@ class ProxmoxHostMixin:
|
|||||||
def _write_apt_file(self, path: str, content: str) -> FixStepOutcomeDict:
|
def _write_apt_file(self, path: str, content: str) -> FixStepOutcomeDict:
|
||||||
return self._write_root_file(path, content)
|
return self._write_root_file(path, content)
|
||||||
|
|
||||||
|
def _reload_package_index(self) -> FixStepOutcomeDict:
|
||||||
|
"""``CpuMicrocodeMixin``'s index load (NetOrk/netork#2838): ``apt-get update`` on the
|
||||||
|
exec path, done when it returns. ``refresh_available_updates`` only starts the API's
|
||||||
|
task, and the install that follows would race it."""
|
||||||
|
return self._step(
|
||||||
|
"DEBIAN_FRONTEND=noninteractive apt-get update", "package index loaded again"
|
||||||
|
)
|
||||||
|
|
||||||
def _allow_sources(
|
def _allow_sources(
|
||||||
self, allowed: list[str], port: int, proto: str, purpose: str
|
self, allowed: list[str], port: int, proto: str, purpose: str
|
||||||
) -> FixStepOutcomeDict:
|
) -> FixStepOutcomeDict:
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "napalm-proxmox"
|
name = "napalm-proxmox"
|
||||||
version = "0.18.0"
|
version = "0.19.0"
|
||||||
description = "NAPALM drivers for Proxmox VE (classic Linux networking, SDN, OVS) and Proxmox Backup Server"
|
description = "NAPALM drivers for Proxmox VE (classic Linux networking, SDN, OVS) and Proxmox Backup Server"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
@@ -21,7 +21,7 @@ classifiers = [
|
|||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"napalm>=5.0.0",
|
"napalm>=5.0.0",
|
||||||
"napalm_device_types>=4.48.0", # HardeningMixin; ServicesRestartMixin with LXC left out
|
"napalm_device_types>=4.53.0", # CpuMicrocodeMixin; virtualization in the hardening
|
||||||
"paramiko>=5.0.0", # CVE-2026-44405; imported directly for the node's SSH session (_base.py)
|
"paramiko>=5.0.0", # CVE-2026-44405; imported directly for the node's SSH session (_base.py)
|
||||||
"proxmoxer>=2.0.0",
|
"proxmoxer>=2.0.0",
|
||||||
"netaddr>=0.9.0",
|
"netaddr>=0.9.0",
|
||||||
|
|||||||
@@ -69,3 +69,69 @@ def test_output_without_a_report_raises(driver):
|
|||||||
with patch.object(driver, "_exec_ssh_command", return_value=""):
|
with patch.object(driver, "_exec_ssh_command", return_value=""):
|
||||||
with pytest.raises(ValueError):
|
with pytest.raises(ValueError):
|
||||||
driver.get_hardening()
|
driver.get_hardening()
|
||||||
|
|
||||||
|
|
||||||
|
class TestCpuMicrocode:
|
||||||
|
"""``install_cpu_microcode`` (napalm-device-types ``CpuMicrocodeMixin``, NetOrk/netork#2838):
|
||||||
|
a node runs on its own CPU, and Proxmox's own install enables no ``non-free-firmware``."""
|
||||||
|
|
||||||
|
SOURCES = "/etc/apt/sources.list.d/debian.sources"
|
||||||
|
TEXT = (
|
||||||
|
"Types: deb\nURIs: http://deb.debian.org/debian/\nSuites: trixie trixie-updates\n"
|
||||||
|
"Components: main contrib\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
def _node(self, drv, *, virtualization="none"):
|
||||||
|
import base64
|
||||||
|
|
||||||
|
ran: list[str] = []
|
||||||
|
file_lines = "".join(f"|{line}\n" for line in self.TEXT.split("\n"))
|
||||||
|
report = (
|
||||||
|
"ARELEASE_BEGIN\n@@os\n|ID=debian\n|VERSION_CODENAME=trixie\n"
|
||||||
|
f"@@file {self.SOURCES}\n{file_lines}ARELEASE_END\n"
|
||||||
|
)
|
||||||
|
|
||||||
|
def exec_(command):
|
||||||
|
ran.append(command)
|
||||||
|
if command.startswith("base64 "):
|
||||||
|
return base64.b64encode(self.TEXT.encode()).decode()
|
||||||
|
if "ARELEASE_" in command:
|
||||||
|
return report
|
||||||
|
return "done\n__PVE_RC=0"
|
||||||
|
|
||||||
|
drv.get_hardening = lambda: {
|
||||||
|
"os_ids": ["debian"],
|
||||||
|
"virtualization": virtualization,
|
||||||
|
"cpu_vendor": "GenuineIntel",
|
||||||
|
}
|
||||||
|
drv.get_packages = lambda: []
|
||||||
|
drv.refresh_available_updates = lambda: pytest.fail("the API refresh does not wait")
|
||||||
|
drv._exec_ssh_command = exec_
|
||||||
|
return ran
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("cls", [ProxmoxDriver, ProxmoxBackupDriver])
|
||||||
|
def test_both_drivers_carry_it(self, cls):
|
||||||
|
assert callable(getattr(cls, "install_cpu_microcode", None))
|
||||||
|
|
||||||
|
def test_the_component_then_apt_get_update_then_the_package(self, driver):
|
||||||
|
ran = self._node(driver)
|
||||||
|
|
||||||
|
result = driver.install_cpu_microcode()
|
||||||
|
|
||||||
|
assert result["success"] is True, result["output"]
|
||||||
|
assert result["sources_changed"] is True
|
||||||
|
written = next(c for c in ran if "install -m 644" in c)
|
||||||
|
assert self.SOURCES in written
|
||||||
|
update = next(i for i, c in enumerate(ran) if "apt-get update" in c)
|
||||||
|
install = next(i for i, c in enumerate(ran) if "apt-get install -y intel-microcode" in c)
|
||||||
|
assert ran.index(written) < update < install
|
||||||
|
|
||||||
|
def test_a_virtual_backup_server_installs_nothing(self):
|
||||||
|
drv = ProxmoxBackupDriver("192.0.2.80", "root", "", optional_args={"token_name": "a!b"})
|
||||||
|
ran = self._node(drv, virtualization="kvm")
|
||||||
|
|
||||||
|
result = drv.install_cpu_microcode()
|
||||||
|
|
||||||
|
assert result["success"] is False
|
||||||
|
assert "its host does" in result["output"]
|
||||||
|
assert ran == []
|
||||||
Reference in new issue
Block a user