From 05bf213010f4a09487c1bb67e73e61bd31bb33b7 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Tue, 22 Sep 2026 14:14:52 +0100 Subject: Find bond source profiles through NetworkManager --- scripts/canonical_bond.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'scripts/canonical_bond.py') diff --git a/scripts/canonical_bond.py b/scripts/canonical_bond.py index d7783c8..a097436 100644 --- a/scripts/canonical_bond.py +++ b/scripts/canonical_bond.py @@ -102,12 +102,13 @@ def port_profile(source, kind, identity, priority): def profile_source(identity): - for directory in ("/etc", "/run", "/usr/lib"): - for path in Path(directory, "NetworkManager/system-connections").glob("*"): - if path.is_file(): - text = path.read_text() - if keyfile(text).get("connection", "uuid", fallback="") == identity: - return text + profiles = nmcli("--escape", "no", "-g", "UUID,FILENAME", "connection", "show") + for row in profiles.splitlines(): + uuid_value, _, filename = row.partition(":") + if uuid_value == identity and filename: + path = Path(filename) + if path.is_absolute() and path.is_file(): + return path.read_text() raise ValueError(f"No saved NetworkManager keyfile for {identity}") -- cgit v1.3.1