Skip to content

Commit 29c5ea0

Browse files
authored
Merge pull request #1972 from s1mplesimon/develop
Add format optional variable to core drivers to support JUNOS get_config() options
2 parents acb6383 + c2aabca commit 29c5ea0

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

napalm/base/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,11 @@ def get_optics(self) -> Dict[str, models.OpticsDict]:
15991599
raise NotImplementedError
16001600

16011601
def get_config(
1602-
self, retrieve: str = "all", full: bool = False, sanitized: bool = False
1602+
self,
1603+
retrieve: str = "all",
1604+
full: bool = False,
1605+
sanitized: bool = False,
1606+
format: str = "text",
16031607
) -> models.ConfigDict:
16041608
"""
16051609
Return the configuration of a device.
@@ -1609,6 +1613,7 @@ def get_config(
16091613
The rest will be set to "".
16101614
full(bool): Retrieve all the configuration. For instance, on ios, "sh run all".
16111615
sanitized(bool): Remove secret data. Default: ``False``.
1616+
format(string): The configuration format style to be retrieved.
16121617
16131618
Returns:
16141619
The object returned is a dictionary with a key for each configuration store:

napalm/eos/eos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,7 @@ def get_optics(self):
20512051

20522052
return optics_detail
20532053

2054-
def get_config(self, retrieve="all", full=False, sanitized=False):
2054+
def get_config(self, retrieve="all", full=False, sanitized=False, format="text"):
20552055
"""get_config implementation for EOS."""
20562056
get_startup = retrieve == "all" or retrieve == "startup"
20572057
get_running = retrieve == "all" or retrieve == "running"

napalm/ios/ios.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3635,7 +3635,7 @@ def get_network_instances(self, name=""):
36353635
except AttributeError:
36363636
raise ValueError("The vrf %s does not exist" % name)
36373637

3638-
def get_config(self, retrieve="all", full=False, sanitized=False):
3638+
def get_config(self, retrieve="all", full=False, sanitized=False, format="text"):
36393639
"""Implementation of get_config for IOS.
36403640
36413641
Returns the startup or/and running configuration as dictionary.

napalm/iosxr/iosxr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2328,7 +2328,7 @@ def get_users(self):
23282328

23292329
return users
23302330

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

23342334
# IOS-XR only supports "all" on "show run"

napalm/iosxr_netconf/iosxr_netconf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3111,7 +3111,7 @@ def get_users(self):
31113111

31123112
return users
31133113

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

31173117
encoding = self.config_encoding

napalm/junos/junos.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,10 +2448,11 @@ def get_optics(self):
24482448

24492449
return optics_detail
24502450

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

2454-
options = {"format": "text", "database": "candidate"}
2454+
self.format = format
2455+
options = {"format": self.format, "database": "candidate"}
24552456
sanitize_strings = {
24562457
r"^(\s+community\s+)\w+(;.*|\s+{.*)$": r"\1<removed>\2",
24572458
r'^(.*)"\$\d\$\S+"(;.*)$': r"\1<removed>\2",

napalm/nxos/nxos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ def _disable_confirmation(self) -> None:
603603
self._send_command_list(["terminal dont-ask"])
604604

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

0 commit comments

Comments
 (0)