Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add format optional variable to core drivers to support JUNOS get_config() options #1972

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2063,7 +2063,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 @@ -3613,7 +3613,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 @@ -2318,7 +2318,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 @@ -2435,10 +2435,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 @@ -583,7 +583,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
Loading