summaryrefslogtreecommitdiffstatshomepage
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/canonical_bond.py13
1 files changed, 7 insertions, 6 deletions
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}")