File napalm-gh-pr1796-xmlgetparent.patch of Package python-napalm
From adb91dffa829127319903fee985a02d127fe13fc Mon Sep 17 00:00:00 2001
From: Chris Moore <cmoore79@depaul.edu>
Date: Fri, 11 Nov 2022 15:46:47 -0600
Subject: [PATCH] fix call to lxml.etree._ElementTree.getparent
lxml.etree._ElementTree.get_parent() doesn't exist - it's getparent() - https://lxml.de/apidoc/lxml.etree.html#lxml.etree.ElementBase.getparent
This enables fetching junos command output as XML through `<command> | display xml`
---
napalm/junos/junos.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/napalm/junos/junos.py b/napalm/junos/junos.py
index 8d56b0fbc..81c83a6c4 100644
--- a/napalm/junos/junos.py
+++ b/napalm/junos/junos.py
@@ -1136,7 +1136,7 @@ def _process_pipe(cmd, txt):
)
raw_txt = self.device.cli(safe_command, warning=False, format=encoding)
if isinstance(raw_txt, etree._Element):
- raw_txt = etree.tostring(raw_txt.get_parent()).decode()
+ raw_txt = etree.tostring(raw_txt.getparent()).decode()
cli_output[str(command)] = raw_txt
else:
cli_output[str(command)] = str(_process_pipe(command, raw_txt))