Skip to content

Commit

Permalink
Merge pull request #1972 from s1mplesimon/develop
Browse files Browse the repository at this point in the history
Add format optional variable to core drivers to support JUNOS get_config() options
  • Loading branch information
mirceaulinic authored Apr 10, 2024
2 parents acb6383 + c2aabca commit 29c5ea0
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 8 deletions.
7 changes: 6 additions & 1 deletion napalm/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,11 @@ def get_optics(self) -> Dict[str, models.OpticsDict]:
raise NotImplementedError

def get_config(
self, retrieve: str = "all", full: bool = False, sanitized: bool = False
self,
retrieve: str = "all",
full: bool = False,
sanitized: bool = False,
format: str = "text",
) -> models.ConfigDict:
"""
Return the configuration of a device.
Expand All @@ -1609,6 +1613,7 @@ def get_config(
The rest will be set to "".
full(bool): Retrieve all the configuration. For instance, on ios, "sh run all".
sanitized(bool): Remove secret data. Default: ``False``.
format(string): The configuration format style to be retrieved.
Returns:
The object returned is a dictionary with a key for each configuration store:
Expand Down
2 changes: 1 addition & 1 deletion napalm/eos/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,7 +2051,7 @@ def get_optics(self):

return optics_detail

def get_config(self, retrieve="all", full=False, sanitized=False):
def get_config(self, retrieve="all", full=False, sanitized=False, format="text"):
"""get_config implementation for EOS."""
get_startup = retrieve == "all" or retrieve == "startup"
get_running = retrieve == "all" or retrieve == "running"
Expand Down
2 changes: 1 addition & 1 deletion napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -3635,7 +3635,7 @@ def get_network_instances(self, name=""):
except AttributeError:
raise ValueError("The vrf %s does not exist" % name)

def get_config(self, retrieve="all", full=False, sanitized=False):
def get_config(self, retrieve="all", full=False, sanitized=False, format="text"):
"""Implementation of get_config for IOS.
Returns the startup or/and running configuration as dictionary.
Expand Down
2 changes: 1 addition & 1 deletion napalm/iosxr/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2328,7 +2328,7 @@ def get_users(self):

return users

def get_config(self, retrieve="all", full=False, sanitized=False):
def get_config(self, retrieve="all", full=False, sanitized=False, format="text"):
config = {"startup": "", "running": "", "candidate": ""} # default values

# IOS-XR only supports "all" on "show run"
Expand Down
2 changes: 1 addition & 1 deletion napalm/iosxr_netconf/iosxr_netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,7 @@ def get_users(self):

return users

def get_config(self, retrieve="all", full=False, sanitized=False):
def get_config(self, retrieve="all", full=False, sanitized=False, format="text"):
"""Return device configuration."""

encoding = self.config_encoding
Expand Down
5 changes: 3 additions & 2 deletions napalm/junos/junos.py
Original file line number Diff line number Diff line change
Expand Up @@ -2448,10 +2448,11 @@ def get_optics(self):

return optics_detail

def get_config(self, retrieve="all", full=False, sanitized=False):
def get_config(self, retrieve="all", full=False, sanitized=False, format="text"):
rv = {"startup": "", "running": "", "candidate": ""}

options = {"format": "text", "database": "candidate"}
self.format = format
options = {"format": self.format, "database": "candidate"}
sanitize_strings = {
r"^(\s+community\s+)\w+(;.*|\s+{.*)$": r"\1<removed>\2",
r'^(.*)"\$\d\$\S+"(;.*)$': r"\1<removed>\2",
Expand Down
2 changes: 1 addition & 1 deletion napalm/nxos/nxos.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def _disable_confirmation(self) -> None:
self._send_command_list(["terminal dont-ask"])

def get_config(
self, retrieve: str = "all", full: bool = False, sanitized: bool = False
self, retrieve: str = "all", full: bool = False, sanitized: bool = False, format: str = "text"
) -> models.ConfigDict:
# NX-OS adds some extra, unneeded lines that should be filtered.
filter_strings = [
Expand Down

0 comments on commit 29c5ea0

Please sign in to comment.