feat(pbs): Proxmox Backup Server as entry point proxmox_backup (#52)
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m5s
driver / test (3.13) (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m10s
driver / lowest (pull_request) Successful in 31s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m0s
CI / driver (pull_request) Successful in 2m20s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 14s
driver / standard (pull_request) Successful in 16s
driver / types (pull_request) Successful in 1m5s
driver / test (3.13) (pull_request) Successful in 1m4s
driver / test (3.12) (pull_request) Successful in 1m10s
driver / lowest (pull_request) Successful in 31s
driver / build (pull_request) Successful in 30s
driver / security (pull_request) Successful in 1m0s
CI / driver (pull_request) Successful in 2m20s
driver / publish (pull_request) Skipped
A second driver in this package, ProxmoxBackupDriver. Its API and web UI are on 8007, not on PVE's 8006, and its node is always localhost; open() proves the login with GET /version, so a bad token fails there. Roles: BackupServerDriver (napalm-device-types 4.25.0) first, then StorageDriver for the disks and ZFS pools the server manages. It reads datastores, the backup groups of every namespace with their newest snapshot, a group's snapshots, the GC, verify, prune, sync and tape jobs with how their last run ended, and the remotes without their secrets; it starts garbage collection and jobs, verifies, protects and deletes snapshots, and follows the tasks. As a host it reports facts, interfaces, CPU and memory, disks, pools, its pbs-subscription and the same packages, updates, host readers and sshd hardening as a PVE node. A privilege-separated token without an ACL entry gets an empty list from PBS, not a refusal, so every read checks /access/permissions and raises PermissionError. A removable datastore that is not mounted is reported as unmounted and left out of the group listing. The fixture is what a PBS 4.2 answered, sanitised; groups, snapshots and jobs it did not have yet follow the API schema.
This commit is contained in:
1 parent
0b5f82cc02
commit
2b2cd9b867
12 files changed
+3781
-12
No files matched your search
@@ -0,0 +1,105 @@
|
||||
"""NAPALM driver for Proxmox Backup Server (entry point ``proxmox_backup``).
|
||||
|
||||
A PBS is a Debian host with one node, always ``localhost`` in its API, and no
|
||||
cluster. Its API and web UI listen on **8007**, not on PVE's 8006. The
|
||||
connection, the SSH session and the node helpers are the ones the PVE driver
|
||||
uses (``napalm_proxmox._base``).
|
||||
|
||||
Roles: a backup server first (datastores, backup groups, jobs, remotes), and
|
||||
storage second for the disks and ZFS pools it manages itself.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from napalm_device_types import (
|
||||
AptProxyMixin,
|
||||
BackupServerDriver,
|
||||
EnsurePackageMixin,
|
||||
FingerprintRule,
|
||||
HostStatusMixin,
|
||||
KernelFactsMixin,
|
||||
LicenseMixin,
|
||||
ListeningSocketsMixin,
|
||||
OpenSshServerMixin,
|
||||
PortSpec,
|
||||
ServicePackagesMixin,
|
||||
StorageDriver,
|
||||
SystemdServicesMixin,
|
||||
SystemIdentityMixin,
|
||||
)
|
||||
|
||||
try:
|
||||
from proxmoxer import ProxmoxAPI
|
||||
except ImportError as exc: # pragma: no cover - proxmoxer is a dependency
|
||||
raise ImportError("proxmoxer is required: pip install proxmoxer") from exc
|
||||
|
||||
from napalm_proxmox._base import ProxmoxBase
|
||||
from napalm_proxmox.host_mixin import ProxmoxHostMixin
|
||||
from napalm_proxmox.pbs_backups import ProxmoxBackupServerMixin
|
||||
from napalm_proxmox.pbs_host import ProxmoxPbsHostMixin
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
#: The node name the PBS API answers to; a PBS has exactly one.
|
||||
PBS_NODE = "localhost"
|
||||
|
||||
|
||||
class ProxmoxBackupDriver(
|
||||
ProxmoxBase,
|
||||
ProxmoxBackupServerMixin,
|
||||
ProxmoxPbsHostMixin,
|
||||
ProxmoxHostMixin,
|
||||
BackupServerDriver,
|
||||
StorageDriver,
|
||||
KernelFactsMixin,
|
||||
ServicePackagesMixin,
|
||||
ListeningSocketsMixin,
|
||||
SystemIdentityMixin,
|
||||
SystemdServicesMixin,
|
||||
HostStatusMixin,
|
||||
LicenseMixin,
|
||||
EnsurePackageMixin,
|
||||
AptProxyMixin,
|
||||
OpenSshServerMixin,
|
||||
):
|
||||
"""NAPALM driver for Proxmox Backup Server."""
|
||||
|
||||
SERVICE = "PBS"
|
||||
VENDOR = "Proxmox"
|
||||
DRIVER_NAME = "proxmox_backup"
|
||||
# netOrk reaches the server through the REST API and does not log in over
|
||||
# SSH itself; the driver's own SSH session (_node_ssh) runs the shell.
|
||||
USES_SSH = False
|
||||
#: A PBS upgrades like a PVE node: a plain ``apt-get upgrade`` holds back
|
||||
#: what needs new or removed packages.
|
||||
FULL_UPGRADE = True
|
||||
PORT_SPECS = [
|
||||
PortSpec("https", 8007, weight=8.0),
|
||||
]
|
||||
SSH_FINGERPRINT = [
|
||||
FingerprintRule("debian", weight=3.0),
|
||||
]
|
||||
HTTP_FINGERPRINT = [
|
||||
FingerprintRule("proxmox backup server", weight=9.0, mandatory=True),
|
||||
FingerprintRule("proxmox", weight=5.0),
|
||||
FingerprintRule("pbs", weight=2.0),
|
||||
]
|
||||
platform = "proxmox_backup"
|
||||
PACKAGE_SOURCE = "pbs"
|
||||
SUBSCRIPTION_LICENSE = "pbs-subscription"
|
||||
|
||||
def _proxmox_api(self, **kwargs: Any) -> Any:
|
||||
return ProxmoxAPI(**kwargs)
|
||||
|
||||
def _resolve_node(self) -> str:
|
||||
"""The node is always ``localhost``; ``GET /version`` proves the login.
|
||||
|
||||
proxmoxer logs in lazily with a token, so without a request here a bad
|
||||
token would only fail at the first getter.
|
||||
"""
|
||||
self._api.version.get()
|
||||
self._node_name = PBS_NODE
|
||||
return self._node_name
|
||||
Reference in new issue
Block a user