feat(log-sources): which logs a PVE or PBS node writes
driver / lint (pull_request) Successful in 13s
driver / standard (pull_request) Successful in 14s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m14s
driver / lowest (pull_request) Successful in 34s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 52s
CI / driver (pull_request) Successful in 2m16s
driver / publish (pull_request) Skipped
driver / lint (pull_request) Successful in 13s
driver / standard (pull_request) Successful in 14s
driver / types (pull_request) Successful in 59s
driver / test (3.13) (pull_request) Successful in 1m10s
driver / test (3.12) (pull_request) Successful in 1m14s
driver / lowest (pull_request) Successful in 34s
driver / build (pull_request) Successful in 27s
driver / security (pull_request) Successful in 52s
CI / driver (pull_request) Successful in 2m16s
driver / publish (pull_request) Skipped
Both drivers mix in napalm-device-types' LogSourcesMixin (4.30.0) and carry its command over the exec path, which runs as root either way. Refs NetOrk/netork#2049
This commit is contained in:
1 parent
1f88f50f15
commit
9c16586028
6 files changed
+57
-1
No files matched your search
@@ -0,0 +1,43 @@
|
||||
"""`get_log_sources`: which logs the node writes, and which service writes each.
|
||||
|
||||
pveproxy, pvedaemon, the Ceph daemons and a backup server's proxy write to
|
||||
journald and to files under ``/var/log``. The command and its parse are
|
||||
napalm-device-types'; the driver only carries the command over its exec path,
|
||||
which already runs as root (NetOrk/netork#2049).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from napalm_device_types import LogSourcesMixin
|
||||
|
||||
from napalm_proxmox.backup_driver import ProxmoxBackupDriver
|
||||
from napalm_proxmox.driver import ProxmoxDriver
|
||||
|
||||
WIRE = (
|
||||
"LOGS_BEGIN\n[journald]\npveproxy.service\n"
|
||||
"[open]\n/proc/2101/fd/7 /var/log/pveproxy/access.log\n"
|
||||
"[stat]\n/proc/2101/fd/7 4096 1762250200\n"
|
||||
"[cgroups]\n2101 0::/system.slice/pveproxy.service\n"
|
||||
"[comm]\n2101 pveproxy worker\n"
|
||||
"LOGS_END\n"
|
||||
)
|
||||
|
||||
|
||||
def test_both_drivers_declare_the_contract():
|
||||
assert issubclass(ProxmoxDriver, LogSourcesMixin)
|
||||
assert issubclass(ProxmoxBackupDriver, LogSourcesMixin)
|
||||
|
||||
|
||||
def test_it_reads_as_root_over_the_exec_path(driver):
|
||||
with patch.object(driver, "_exec_ssh_command", return_value=WIRE) as exec_:
|
||||
reading = driver.get_log_sources()
|
||||
|
||||
[command] = [c.args[0] for c in exec_.call_args_list]
|
||||
assert command.startswith("sh -c '")
|
||||
assert reading["attributed"] is True
|
||||
access = [s for s in reading["sources"] if s["kind"] == "file"]
|
||||
assert [(s["path"], s["unit"]) for s in access] == [
|
||||
("/var/log/pveproxy/access.log", "pveproxy")
|
||||
]
|
||||
Reference in new issue
Block a user