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

IOS-XR: remove unnecessary lines from get_config output #1193

Merged
merged 1 commit into from
May 2, 2020
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
11 changes: 9 additions & 2 deletions napalm/iosxr/iosxr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2235,13 +2235,20 @@ def get_config(self, retrieve="all", full=False):
# IOS-XR only supports "all" on "show run"
run_full = " all" if full else ""

filter_strings = [r"^Building configuration.*$", r"^!! IOS XR Configuration.*$"]
filter_pattern = napalm.base.helpers.generate_regex_or(filter_strings)

if retrieve.lower() in ["running", "all"]:
config["running"] = str(
running = str(
self.device._execute_config_show(f"show running-config{run_full}")
)
running = re.sub(filter_pattern, "", running, flags=re.M)
config["running"] = running
if retrieve.lower() in ["candidate", "all"]:
config["candidate"] = str(
candidate = str(
self.device._execute_config_show("show configuration merge")
)
candidate = re.sub(filter_pattern, "", candidate, flags=re.M)
config["candidate"] = candidate

return config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"running": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response MajorVersion=\"1\" MinorVersion=\"0\"><CLI><Configuration>\nBuilding configuration...\n!! IOS XR Configuration version = 6.2.1.08I\n!! Last configuration change at Wed Aug 17 16:49:00 2016 by vagrant\n!\ntelnet vrf default ipv4 server max-servers 10\nusername vagrant\n group root-lr\n group cisco-support\n secret 5 $1$gZpA$ued8wLDDwikqTVKTEvUe2/\n!\ntpa\n address-family ipv4\n update-source MgmtEth0/RP0/CPU0/0\n !\n!\ninterface MgmtEth0/RP0/CPU0/0\n description testing parallel commits\n ipv4 address dhcp\n!\ninterface GigabitEthernet0/0/0/0\n shutdown\n!\ninterface GigabitEthernet0/0/0/1\n shutdown\n!\ninterface GigabitEthernet0/0/0/2\n shutdown\n!\ninterface GigabitEthernet0/0/0/3\n shutdown\n!\nrouter static\n address-family ipv4 unicast\n 0.0.0.0/0 MgmtEth0/RP0/CPU0/0 10.0.2.2\n !\n!\ngrpc\n port 57777\n!\nxml agent tty\n iteration on size 1\n!\nssh server v2\nssh server vrf default\nend\n\n</Configuration></CLI><ResultSummary ErrorCount=\"0\"/></Response>\n",
"running": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response MajorVersion=\"1\" MinorVersion=\"0\"><CLI><Configuration>\n\n\n!! Last configuration change at Wed Aug 17 16:49:00 2016 by vagrant\n!\ntelnet vrf default ipv4 server max-servers 10\nusername vagrant\n group root-lr\n group cisco-support\n secret 5 $1$gZpA$ued8wLDDwikqTVKTEvUe2/\n!\ntpa\n address-family ipv4\n update-source MgmtEth0/RP0/CPU0/0\n !\n!\ninterface MgmtEth0/RP0/CPU0/0\n description testing parallel commits\n ipv4 address dhcp\n!\ninterface GigabitEthernet0/0/0/0\n shutdown\n!\ninterface GigabitEthernet0/0/0/1\n shutdown\n!\ninterface GigabitEthernet0/0/0/2\n shutdown\n!\ninterface GigabitEthernet0/0/0/3\n shutdown\n!\nrouter static\n address-family ipv4 unicast\n 0.0.0.0/0 MgmtEth0/RP0/CPU0/0 10.0.2.2\n !\n!\ngrpc\n port 57777\n!\nxml agent tty\n iteration on size 1\n!\nssh server v2\nssh server vrf default\nend\n\n</Configuration></CLI><ResultSummary ErrorCount=\"0\"/></Response>\n",
"startup": "",
"candidate": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response MajorVersion=\"1\" MinorVersion=\"0\"><CLI><Configuration>\nBuilding configuration...\n!! IOS XR Configuration version = 6.2.1.08I\n!! Last configuration change at Wed Aug 17 16:49:00 2016 by vagrant\n!\ntelnet vrf default ipv4 server max-servers 10\nusername vagrant\n group root-lr\n group cisco-support\n secret 5 $1$gZpA$ued8wLDDwikqTVKTEvUe2/\n!\ntpa\n address-family ipv4\n update-source MgmtEth0/RP0/CPU0/0\n !\n!\ninterface MgmtEth0/RP0/CPU0/0\n description testing parallel commits\n ipv4 address dhcp\n!\ninterface GigabitEthernet0/0/0/0\n shutdown\n!\ninterface GigabitEthernet0/0/0/1\n shutdown\n!\ninterface GigabitEthernet0/0/0/2\n shutdown\n!\ninterface GigabitEthernet0/0/0/3\n shutdown\n!\nrouter static\n address-family ipv4 unicast\n 0.0.0.0/0 MgmtEth0/RP0/CPU0/0 10.0.2.2\n !\n!\ngrpc\n port 57777\n!\nxml agent tty\n iteration on size 1\n!\nssh server v2\nssh server vrf default\nend\n\n</Configuration></CLI><ResultSummary ErrorCount=\"0\"/></Response>\n"
"candidate": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response MajorVersion=\"1\" MinorVersion=\"0\"><CLI><Configuration>\n\n\n!! Last configuration change at Wed Aug 17 16:49:00 2016 by vagrant\n!\ntelnet vrf default ipv4 server max-servers 10\nusername vagrant\n group root-lr\n group cisco-support\n secret 5 $1$gZpA$ued8wLDDwikqTVKTEvUe2/\n!\ntpa\n address-family ipv4\n update-source MgmtEth0/RP0/CPU0/0\n !\n!\ninterface MgmtEth0/RP0/CPU0/0\n description testing parallel commits\n ipv4 address dhcp\n!\ninterface GigabitEthernet0/0/0/0\n shutdown\n!\ninterface GigabitEthernet0/0/0/1\n shutdown\n!\ninterface GigabitEthernet0/0/0/2\n shutdown\n!\ninterface GigabitEthernet0/0/0/3\n shutdown\n!\nrouter static\n address-family ipv4 unicast\n 0.0.0.0/0 MgmtEth0/RP0/CPU0/0 10.0.2.2\n !\n!\ngrpc\n port 57777\n!\nxml agent tty\n iteration on size 1\n!\nssh server v2\nssh server vrf default\nend\n\n</Configuration></CLI><ResultSummary ErrorCount=\"0\"/></Response>\n"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"running": "",
"startup": "",
"candidate": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response MajorVersion=\"1\" MinorVersion=\"0\"><CLI><Configuration>\nBuilding configuration...\n!! IOS XR Configuration version = 6.2.1.08I\n!! Last configuration change at Wed Aug 17 16:49:00 2016 by vagrant\n!\ntelnet vrf default ipv4 server max-servers 10\nusername vagrant\n group root-lr\n group cisco-support\n secret 5 $1$gZpA$ued8wLDDwikqTVKTEvUe2/\n!\ntpa\n address-family ipv4\n update-source MgmtEth0/RP0/CPU0/0\n !\n!\ninterface MgmtEth0/RP0/CPU0/0\n description testing parallel commits\n ipv4 address dhcp\n!\ninterface GigabitEthernet0/0/0/0\n shutdown\n!\ninterface GigabitEthernet0/0/0/1\n shutdown\n!\ninterface GigabitEthernet0/0/0/2\n shutdown\n!\ninterface GigabitEthernet0/0/0/3\n shutdown\n!\nrouter static\n address-family ipv4 unicast\n 0.0.0.0/0 MgmtEth0/RP0/CPU0/0 10.0.2.2\n !\n!\ngrpc\n port 57777\n!\nxml agent tty\n iteration on size 1\n!\nssh server v2\nssh server vrf default\nend\n\n</Configuration></CLI><ResultSummary ErrorCount=\"0\"/></Response>\n"
"candidate": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response MajorVersion=\"1\" MinorVersion=\"0\"><CLI><Configuration>\n\n\n!! Last configuration change at Wed Aug 17 16:49:00 2016 by vagrant\n!\ntelnet vrf default ipv4 server max-servers 10\nusername vagrant\n group root-lr\n group cisco-support\n secret 5 $1$gZpA$ued8wLDDwikqTVKTEvUe2/\n!\ntpa\n address-family ipv4\n update-source MgmtEth0/RP0/CPU0/0\n !\n!\ninterface MgmtEth0/RP0/CPU0/0\n description testing parallel commits\n ipv4 address dhcp\n!\ninterface GigabitEthernet0/0/0/0\n shutdown\n!\ninterface GigabitEthernet0/0/0/1\n shutdown\n!\ninterface GigabitEthernet0/0/0/2\n shutdown\n!\ninterface GigabitEthernet0/0/0/3\n shutdown\n!\nrouter static\n address-family ipv4 unicast\n 0.0.0.0/0 MgmtEth0/RP0/CPU0/0 10.0.2.2\n !\n!\ngrpc\n port 57777\n!\nxml agent tty\n iteration on size 1\n!\nssh server v2\nssh server vrf default\nend\n\n</Configuration></CLI><ResultSummary ErrorCount=\"0\"/></Response>\n"
}