Skip to content

Commit

Permalink
Merge 499f95d into 9731790
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceaulinic committed May 1, 2020
2 parents 9731790 + 499f95d commit cd7643b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions napalm/iosxr/iosxr.py
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
@@ -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"
}
@@ -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"
}

0 comments on commit cd7643b

Please sign in to comment.