From 776bfb10909202eceba161dff969957d1084c30f Mon Sep 17 00:00:00 2001 From: SenorRodriguez Date: Tue, 22 Oct 2024 12:13:21 +0200 Subject: [PATCH] Rudimentary support for json format juniper get_config If no format attribute is specified get_config returns config as a plain text, but in json is specified, it returns a dict. Probably it still needs further polishing. e.g I cast it to a str, but maybe i could stay as dict. It's my first pull request ever, Sorry if I messed something up. --- napalm/junos/junos.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/napalm/junos/junos.py b/napalm/junos/junos.py index 4c8eb9f82..9c52b456c 100644 --- a/napalm/junos/junos.py +++ b/napalm/junos/junos.py @@ -2459,12 +2459,17 @@ def get_config(self, retrieve="all", full=False, sanitized=False, format="text") } if retrieve in ("candidate", "all"): config = self.device.rpc.get_config(filter_xml=None, options=options) - rv["candidate"] = str(config.text) + if options["format"] == "text": + rv["candidate"] = str(config.text) + else: + return str(config["configuration"]) if retrieve in ("running", "all"): options["database"] = "committed" config = self.device.rpc.get_config(filter_xml=None, options=options) - rv["running"] = str(config.text) - + if options["format"] == "text": + rv["candidate"] = str(config.text) + else: + return str(config["configuration"]) if sanitized: return napalm.base.helpers.sanitize_configs(rv, sanitize_strings)