Skip to content

Commit 7339e4a

Browse files
authored
Use report_quirk to for consistent reporting of device quirks (#2083)
Changed 'log.error' to 'report_quirk' for Aruba, ASAv, CL NVUE, CL, EOS, IOSv, IOSvL2, Junos, and Linux Closes #1792
1 parent cc9ecf6 commit 7339e4a

File tree

10 files changed

+109
-83
lines changed

10 files changed

+109
-83
lines changed

netsim/defaults/hints.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ report:
1919
package-, system-, user- or current directory. You can also specify a report in a
2020
defaults.outputs.report setting.
2121
22-
quirks:
23-
junos_lb: >
22+
junos:
23+
single_lb: >
2424
Junos devices cannot have more than one loopback interface per routing instance
2525
2626
vlan:

netsim/devices/arubacx.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
from box import Box
99

10-
from . import _Quirks,need_ansible_collection
10+
from . import _Quirks,need_ansible_collection,report_quirk
1111
from ..augment import devices
1212
from ..utils import log
1313

@@ -18,35 +18,44 @@ def device_quirks(self, node: Box, topology: Box) -> None:
1818
mods = node.get('module',[])
1919
# Checks for OSPF Process ID (index based)
2020
if 'ospf' in mods and 'vrf' in mods:
21-
ospfidx = 2
22-
for vrf in node.get('vrfs', {}).keys():
23-
if ospfidx > 63:
24-
log.error(
25-
f'Too many VRFs with OSPF in ({node.name}).\n',
26-
log.IncorrectType,
27-
'quirks')
28-
return
29-
node.vrfs[vrf]['ospfidx'] = ospfidx
30-
ospfidx = ospfidx + 1
21+
ospfidx = 2
22+
for vrf in node.get('vrfs', {}).keys():
23+
if ospfidx > 63:
24+
report_quirk(
25+
text=f'Too many VRFs with OSPF in ({node.name})',
26+
node=node,
27+
category=log.IncorrectValue)
28+
break
29+
node.vrfs[vrf]['ospfidx'] = ospfidx
30+
ospfidx = ospfidx + 1
31+
3132
# Remove OSPF default originate route-type (not supported, yet)
3233
if 'ospf' in mods:
3334
if 'default' in node.get('ospf', {}) and 'type' in node.ospf.default:
3435
del node.ospf.default['type']
35-
log.info(f'OSPF default-information originate (on node {node.name}) does not support metric-type attribute (on default routing table)',
36-
'quirks')
36+
report_quirk(
37+
text=f'OSPF default-information originate (used in global routing table on node {node.name}) does not support metric-type attribute',
38+
node=node,
39+
quirk='ospf_default_type',
40+
category=Warning)
41+
3742
if 'ospf' in mods and 'vrf' in mods:
3843
for vname,vdata in node.get('vrfs', {}).items():
3944
if 'default' in vdata.get('ospf', {}) and 'type' in vdata.ospf.default:
4045
del vdata.ospf.default['type']
41-
log.info(f'OSPF default-information originate (on node {node.name}) does not support metric-type attribute (on vrf {vname})',
42-
'quirks')
46+
report_quirk(
47+
text=f'OSPF default-information originate (used in VRF {vname} on node {node.name}) does not support metric-type attribute',
48+
node=node,
49+
quirk='ospf_default_type',
50+
category=Warning)
4351

4452
# MPLS can be used only with 'external' provider
4553
if 'mpls' in mods and node.get('provider','') != 'external':
46-
log.error(
47-
f'ArubaCX MPLS data plane works only on physical devices (using the external provider)',
48-
log.IncorrectType,
49-
'quirks')
54+
report_quirk(
55+
text=f'MPLS data plane used on node {node.name} works only on physical devices',
56+
more_hints='Use a physical switch with the external provider',
57+
node=node,
58+
category=log.IncorrectType)
5059

5160
# LAG + VSX quirks
5261
## on VSX, you **must** configure the switch role as primary or secondary.

netsim/devices/asav.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,22 @@
33
#
44
from box import Box
55

6-
from . import _Quirks
6+
from . import _Quirks,report_quirk
77
from ..utils import log
88

99
def check_isis_p2p_interfaces(node: Box, topology: Box) -> None:
1010
for intf in node.interfaces:
1111
if not 'isis' in intf:
1212
continue
13+
if intf.get('isis.network_type',None) != "point-to-point":
14+
continue
15+
1316
for neighbor in intf.neighbors:
14-
remote_node = neighbor.node
15-
remote_interfaces = topology.nodes[remote_node].interfaces
16-
for rintf in remote_interfaces:
17-
if rintf.ifname == neighbor.ifname:
18-
if intf.get('isis.network_type',None) == "point-to-point":
19-
log.error(
20-
f'Cisco ASA does not support P2P IS-IS links.'
21-
f'Problematic Interface: {remote_node} {neighbor.ifname}',
22-
log.IncorrectType,
23-
'quirks',
24-
)
17+
report_quirk(
18+
text=f'Cisco ASA does not support P2P IS-IS links',
19+
node=node,
20+
more_data=[ f'Node {node.name} {intf.ifname} connected to {neighbor.node} {neighbor.ifname}' ],
21+
category=log.IncorrectType)
2522

2623
class ASA(_Quirks):
2724

netsim/devices/cumulus.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,31 @@
33
#
44
from box import Box
55

6-
from . import _Quirks
6+
from . import _Quirks,report_quirk
77
from ..utils import log
88
from ..augment import devices
99

1010
def check_ospf_vrf_default(node: Box) -> None:
1111
for vname,vdata in node.get('vrfs',{}).items():
1212
if vdata.get('ospf.default',None):
13-
log.error(
14-
f"VRF OSPF default route is not working on Cumulus Linux (node {node.name}, vrf {vname})",
15-
category=log.IncorrectType,
16-
module='quirks')
13+
report_quirk(
14+
text=f"VRF OSPF default route is not working (node {node.name}, vrf {vname})",
15+
node=node,
16+
quirk='ospf_default',
17+
category=log.IncorrectType)
1718

1819
class Cumulus(_Quirks):
1920

2021
@classmethod
2122
def device_quirks(self, node: Box, topology: Box) -> None:
23+
if devices.get_provider(node,topology) == 'clab':
24+
report_quirk(
25+
text=f"We do not test Cumulus containers ({node.name}). They might not work correctly",
26+
node=node,
27+
category=Warning,
28+
quirk="unsupported_container",
29+
more_hints=[ "See https://netlab.tools/caveats/#caveats-cumulus for more details "])
30+
2231
mods = node.get('module',[])
2332
if 'ospf' in mods and 'vrfs' in node:
2433
check_ospf_vrf_default(node)

netsim/devices/cumulus_nvue.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ def nvue_check_stp_features(node: Box, topology: Box) -> None:
4444
"""
4545
def nvue_check_ospfv3(node: Box) -> None:
4646
if node.get('ospf.af.ipv6',False):
47-
log.error(f"Node '{node.name}' uses OSPFv3 which cannot be configured through Cumulus NVUE; use a regular 'cumulus' node instead",
48-
category=log.FatalError,
49-
module='ospf',
50-
hint='ospfv3')
47+
report_quirk(
48+
text=f"Node '{node.name}' uses OSPFv3 which cannot be configured through Cumulus NVUE",
49+
more_hints=[ "Use a regular 'cumulus' node instead" ],
50+
node=node,
51+
category=log.IncorrectType)
5152

5253
"""
5354
Checks for mixed trunk interfaces with native routed vlan. That doesn't work because the parent interface gets added
@@ -153,8 +154,9 @@ def device_quirks(self, node: Box, topology: Box) -> None:
153154
nvue_check_native_routed_on_mixed_trunk(node,topology)
154155

155156
if devices.get_provider(node,topology) == 'clab':
156-
log.error(
157-
f"Cumulus VX 5.x container used for node {node.name} is not supported and might not work correctly",
157+
report_quirk(
158+
text=f"Cumulus VX 5.x container used for node {node.name} is not supported and might not work correctly",
159+
node=node,
158160
category=Warning,
159-
module='cumulus_nvue',
161+
quirk="unsupported_container",
160162
more_hints=[ "See https://netlab.tools/caveats/#caveats-cumulus-nvue for more details "])

netsim/devices/eos.py

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def check_mlps_vlan_bundle(node: Box) -> None:
1717
if not vdata.get('evpn.bundle',False): # Check only VLANs within a bundle
1818
continue
1919
if vdata.get('mode','') != 'bridge': # They must be in pure bridging mode
20-
log.error(
21-
f'Arista EOS supports only bridge VLANs in an EVPN/MPLS VLAN bundle ({vname} on {node.name})',
22-
log.IncorrectType,
23-
'quirks')
20+
report_quirk(
21+
text=f'Arista EOS supports only bridge VLANs in an EVPN/MPLS VLAN bundle ({vname} on {node.name})',
22+
node=node,
23+
category=log.IncorrectType)
2424
ifname = f'Vlan{vdata.id}' # Now remove the VLAN interface
2525
node.interfaces = [ intf for intf in node.interfaces if intf.ifname != ifname ]
2626

@@ -32,11 +32,12 @@ def check_mpls_clab(node: Box, topology: Box) -> None:
3232
ceos_version = ''
3333

3434
if ceos_version < '4.32.1F':
35-
log.error(
36-
f'Arista cEOS ({node.name}) versions earlier than 4.32.1F do not support MPLS data plane',
35+
report_quirk(
36+
text=f'Arista cEOS ({node.name}) versions earlier than 4.32.1F do not support MPLS data plane',
3737
more_hints = 'To use MPLS with older EOS versions, use vEOS VM with libvirt provider',
38-
category=Warning,
39-
module='quirks')
38+
node=node,
39+
quirk='mpls_data_plane',
40+
category=Warning)
4041

4142
def check_shared_mac(node: Box, topology: Box) -> None:
4243
if devices.get_provider(node,topology) != 'clab':
@@ -49,10 +50,11 @@ def check_shared_mac(node: Box, topology: Box) -> None:
4950
if intf.get('vlan',None): # Anycast works on VLAN cEOS interfaces
5051
continue
5152

52-
log.error(
53-
f'Anycast gateway (VARP) on non-VLAN interfaces does not work on Arista cEOS ({node.name}).\n.. Use vEOS VM with libvirt provider',
54-
log.IncorrectType,
55-
'quirks')
53+
report_quirk(
54+
text=f'Anycast gateway (VARP) on non-VLAN interfaces does not work on Arista cEOS ({node.name})',
55+
more_hints="Use vEOS VM with libvirt provider",
56+
node=node,
57+
category=log.IncorrectType)
5658
return
5759

5860
def check_dhcp_clients(node: Box, topology: Box) -> None:
@@ -62,10 +64,11 @@ def check_dhcp_clients(node: Box, topology: Box) -> None:
6264
for intf in node.interfaces:
6365
if not intf.get('dhcp.client',False):
6466
continue
65-
log.error(
66-
f"Arista cEOS containers (node {node.name}) cannot run DHCP clients.",
67-
category=log.IncorrectType,
68-
module='quirks')
67+
report_quirk(
68+
text=f"Arista cEOS containers (node {node.name}) cannot run DHCP clients",
69+
more_hints="Use vEOS VM with libvirt provider",
70+
node=node,
71+
category=log.IncorrectType)
6972

7073
def configure_ceos_attributes(node: Box, topology: Box) -> None:
7174
serialnumber = node.eos.get('serialnumber',None)
@@ -74,20 +77,21 @@ def configure_ceos_attributes(node: Box, topology: Box) -> None:
7477
return
7578

7679
if 'clab' not in node or node.clab.kind != "ceos":
77-
log.error(
80+
report_quirk(
7881
f"eos.serialnumber and eos.systemmacaddr can only be set for Arista cEOS containers (node {node.name}).",
79-
category=Warning,
8082
more_hints=['Use libvirt.uuid to influence serial number on EOS virtual machines'],
81-
module='quirks')
83+
node=node,
84+
category=Warning,
85+
quirk='serialnumber')
8286
return
8387

8488
mnt_config = '/mnt/flash/ceos-config'
8589
for ct in node.get('clab.binds',[]):
8690
if mnt_config in ct:
87-
log.error(
88-
f"{mnt_config} file is already mapped, unable to configure eos.serialnumber (node {node.name}).",
89-
category=log.Skipped,
90-
module='quirks')
91+
report_quirk(
92+
text=f"{mnt_config} file is already mapped, unable to configure eos.serialnumber (node {node.name}).",
93+
node=node,
94+
category=Warning)
9195
return
9296

9397
data.append_to_list(node.clab,'binds',f'clab_files/{node.name}/ceos-config:{mnt_config}')

netsim/devices/iosv.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ def check_vrrp_bvi(node: Box, topology: Box) -> None:
1717
if intf.get('type',None) != 'svi': # Not a BVI interface, move on
1818
continue
1919

20-
log.error(
21-
f'Cisco IOSv cannot run VRRP on BVI interfaces.',
22-
log.IncorrectType,
23-
'quirks')
20+
report_quirk(
21+
text=f'Cisco IOSv cannot run VRRP on BVI interfaces.',
22+
node=node,
23+
category=log.IncorrectType,
24+
quirk='vrrp_bvi')
2425
return
2526

2627
'''

netsim/devices/iosvl2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
def check_reserved_vlans(node: Box, topology: Box) -> None:
1414
for vname,vdata in node.get('vlans',{}).items():
1515
if vdata.id in range(1002,1006):
16-
log.error(
17-
f'Cannot use VLAN ID {vdata.id} (VLAN {vname}) on Cisco IOSvL2 or IOLL2 for historic reasons',
16+
report_quirk(
17+
text=f'Cannot use VLAN ID {vdata.id} (VLAN {vname}) on Cisco IOSvL2 or IOLL2 for historic reasons',
18+
node=node,
1819
category=log.IncorrectValue,
20+
quirk='vlan.reserved',
1921
module='quirks')
2022

2123
'''

netsim/devices/junos.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,13 @@ def check_multiple_loopbacks(node: Box, topology: Box) -> None:
9292
for vname,vcnt in vrf_count.items():
9393
if vcnt <= 1:
9494
continue
95-
log.error(
96-
f'Node {node.name} (device {node.device}) has {vcnt} loopbacks in vrf {vname}',
95+
report_quirk(
96+
text=f'Node {node.name} (device {node.device}) has {vcnt} loopbacks in vrf {vname}',
97+
node=node,
9798
category=log.IncorrectValue,
98-
module='quirks',
99-
hint='junos_lb')
99+
quirk='multi_loopback',
100+
hint='single_lb',
101+
module='junos')
100102

101103
def check_evpn_ebgp(node: Box, topology: Box) -> None:
102104
for ngb in node.get('bgp.neighbors',[]):

netsim/devices/linux.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
from box import Box
55

6-
from . import _Quirks
6+
from . import _Quirks,report_quirk
77
from ._common import check_indirect_static_routes
88
from ..utils import log
99
from ..augment import devices
@@ -39,9 +39,9 @@ def device_quirks(self, node: Box, topology: Box) -> None:
3939
return
4040

4141
if 'dhcp' in node.get('module',[]):
42-
log.error(
43-
f"netlab does not support DHCP functionality in Linux containers",
42+
report_quirk(
43+
text=f"netlab does not support DHCP functionality in Linux containers (node {node.name})",
44+
node=node,
4445
more_hints=[ "Use 'cumulus' for DHCP client or 'dnsmasq' for DHCP server" ],
4546
category=log.IncorrectType,
46-
module='quirks')
47-
47+
quirk='clab_dhcp_client')

0 commit comments

Comments
 (0)