Skip to content

Commit

Permalink
Rudimentary support for json format juniper get_config
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SenorRodriguez authored Oct 22, 2024
1 parent d0d2a3e commit 776bfb1
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 776bfb1

Please sign in to comment.