Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------
* IOSXE
* Modified ShowIpOspfInterface:
* Optimized parser by having it call additional commands once rather than call them for every instance, interface, etc...
* Modified ShowIpOspfNeighborDetail
* Optimized parser by having it call additional commands once rather than call them for every instance, interface, etc...
102 changes: 55 additions & 47 deletions src/genie/libs/parser/iosxe/show_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1933,6 +1933,18 @@ def cli(self, interface=None, output=None):
# TE Opaque LSA: Source of link information OSPF
p31_1 = re.compile(r'^TE +Opaque +LSA: +(?P<te_opaque_lsa>[\S\s]+)$')

# Parse additional commands that are needed
cmd = 'show running-config | section router ospf'
ospf_out = self.device.execute(cmd)
cmd = 'show running-config | i virtual-link'
vl_out = self.device.execute(cmd)
cmd = 'show running-config | i sham-link'
sl_out = self.device.execute(cmd)
cmd = 'show ip ospf virtual-links'
ospfvl_out = self.device.execute(cmd)
cmd = 'show ip ospf sham-links'
ospfsl_out = self.device.execute(cmd)

for line in out.splitlines():
line = line.strip()

Expand Down Expand Up @@ -2004,10 +2016,7 @@ def cli(self, interface=None, output=None):
vl_transit_area_id = None

# Execute command to get virtual-link address
cmd = 'show ip ospf virtual-links | i {interface}'.format(interface=interface)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in ospfvl_out.splitlines():
line = line.rstrip()
# Virtual Link OSPF_VL0 to router 10.100.5.5 is down
p = re.search('Virtual +Link +(?P<intf>(\S+)) +to +router'
Expand All @@ -2020,10 +2029,7 @@ def cli(self, interface=None, output=None):

# Execute command to get virtual-link transit_area_id
if vl_addr is not None:
cmd = 'show running-config | i virtual-link | i {addr}'.format(addr=vl_addr)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in vl_out.splitlines():
line = line.rstrip()
# area 1 virtual-link 10.100.5.5
q = re.search('area +(?P<q_area>(\d+)) +virtual-link'
Expand All @@ -2045,10 +2051,7 @@ def cli(self, interface=None, output=None):
sl_remote_id = None

# Execute command to get sham-link remote_id
cmd = 'show ip ospf sham-links | i {interface}'.format(interface=interface)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in ospfsl_out.splitlines():
line = line.rstrip()
# Sham Link OSPF_SL1 to address 10.151.22.22 is up
p = re.search('Sham +Link +(?P<intf>(\S+)) +to +address'
Expand All @@ -2060,10 +2063,8 @@ def cli(self, interface=None, output=None):

# Execute command to get sham-link local_id
if sl_remote_id is not None:
cmd = 'show running-config | i sham-link | i {remote}'.format(remote=sl_remote_id)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in sl_out.splitlines():
line = line.rstrip()
# area 1 sham-link 10.229.11.11 10.151.22.22 cost 111 ttl-security hops 3
q = re.search('area +(?P<q_area>(\d+)) +sham-link'
Expand All @@ -2083,10 +2084,8 @@ def cli(self, interface=None, output=None):
intf_name = '{} {}'.format(sl_local_id, sl_remote_id)

# Get VRF information based on OSPF instance
cmd = 'show running-config | section router ospf {}'.format(instance)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in ospf_out.splitlines():
line = line.rstrip()

# Skip the show command line so as to not match
Expand Down Expand Up @@ -4306,6 +4305,20 @@ def cli(self, neighbor='', output=None):
' +(?P<num2>(\d+)) +msec$')

p13 = re.compile(r'^SR +adj +label +(?P<sr_adj_label>\d+)$')

# Parse additional commands that are needed
cmd = 'show running-config | section router ospf'
ospf_out = self.device.execute(cmd)
cmd = 'show running-config | i virtual-link'
vl_out = self.device.execute(cmd)
cmd = 'show running-config | i sham-link'
sl_out = self.device.execute(cmd)
cmd = 'show ip ospf virtual-links'
ospfvl_out = self.device.execute(cmd)
cmd = 'show ip ospf sham-links'
ospfsl_out = self.device.execute(cmd)
cmd = 'show ip ospf interface'
ospfint_out = self.device.execute(cmd)

for line in out.splitlines():
line = line.strip()
Expand All @@ -4331,26 +4344,33 @@ def cli(self, neighbor='', output=None):
router_id = None
bfd_state = m.groupdict().get('bfd_state', None)
# Get OSPF process ID from 'show ip ospf interface'
cmd = 'show ip ospf interface {}'.format(interface)
out = self.device.execute(cmd)
flag = False

for line in out.splitlines():
for line in ospfint_out.splitlines():
line = line.rstrip()

p = re.search('^(?P<interface>(\S+)) +is( +administratively)?'
' +(?P<enable>(unknown|up|down)), +line +protocol'
' +is +(?P<line_protocol>(up|down))'
'(?: +\(\S+\))?$', line)

# Process ID 2, Router ID 10.229.11.11, Network Type SHAM_LINK, Cost: 111
p = re.search('Process +ID +(?P<instance>(\S+)), +Router +ID'
' +(?P<router_id>(\S+)) +(.*)', line)
if p:
instance = str(p.groupdict()['instance'])
router_id = str(p.groupdict()['router_id'])
break
p_interface = str(p.groupdict()['interface'])
if (p_interface == interface):
flag = True

if (flag == True):
# Process ID 2, Router ID 10.229.11.11, Network Type SHAM_LINK, Cost: 111
p = re.search('Process +ID +(?P<instance>(\S+)), +Router +ID +(?P<router_id>(\S+)) +(.*)', line)
if p:
flag = False
instance = str(p.groupdict()['instance'])
router_id = str(p.groupdict()['router_id'])
break

# Get VRF information using the ospf instance
if instance is not None:
cmd = 'show running-config | section router ospf {}'.format(instance)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in ospf_out.splitlines():
line = line.rstrip()

# Skip the show command line so as to not match
Expand Down Expand Up @@ -4395,10 +4415,7 @@ def cli(self, neighbor='', output=None):
vl_transit_area_id = None

# Execute command to get virtual-link address
cmd = 'show ip ospf virtual-links | i {interface}'.format(interface=interface)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in ospfvl_out.splitlines():
line = line.rstrip()
# Virtual Link OSPF_VL0 to router 10.100.5.5 is down
p = re.search('Virtual +Link +(?P<intf>(\S+)) +to +router'
Expand All @@ -4411,10 +4428,7 @@ def cli(self, neighbor='', output=None):

# Execute command to get virtual-link transit_area_id
if vl_addr is not None and router_id is not None:
cmd = 'show running-config | i virtual-link | i {addr}'.format(addr=vl_addr)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in vl_out.splitlines():
line = line.rstrip()
# area 1 virtual-link 10.100.5.5
q = re.search('area +(?P<q_area>(\d+)) +virtual-link'
Expand All @@ -4436,10 +4450,7 @@ def cli(self, neighbor='', output=None):
sl_remote_id = None

# Execute command to get sham-link remote_id
cmd = 'show ip ospf sham-links | i {interface}'.format(interface=interface)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in ospfsl_out.splitlines():
line = line.rstrip()
# Sham Link OSPF_SL1 to address 10.151.22.22 is up
p = re.search('Sham +Link +(?P<intf>(\S+)) +to +address'
Expand All @@ -4451,10 +4462,7 @@ def cli(self, neighbor='', output=None):

# Execute command to get sham-link local_id
if sl_remote_id is not None:
cmd = 'show running-config | i sham-link | i {remote}'.format(remote=sl_remote_id)
out = self.device.execute(cmd)

for line in out.splitlines():
for line in sl_out.splitlines():
line = line.rstrip()
# area 1 sham-link 10.229.11.11 10.151.22.22 cost 111 ttl-security hops 3
q = re.search('area +(?P<q_area>(\d+)) +sham-link'
Expand Down