Update minigraph parser to support type MIRROR_DSCP (#8819)
* Update minigraph parser to support MIRROR_DSCP Signed-off-by: bingwang <bingwang@microsoft.com>
This commit is contained in:
parent
bc06c6fcb5
commit
1d7e82b96d
@ -596,6 +596,7 @@ def parse_dpg(dpg, hname):
|
|||||||
acl_intfs = []
|
acl_intfs = []
|
||||||
is_mirror = False
|
is_mirror = False
|
||||||
is_mirror_v6 = False
|
is_mirror_v6 = False
|
||||||
|
is_mirror_dscp = False
|
||||||
|
|
||||||
# TODO: Ensure that acl_intfs will only ever contain front-panel interfaces (e.g.,
|
# TODO: Ensure that acl_intfs will only ever contain front-panel interfaces (e.g.,
|
||||||
# maybe we should explicity ignore management and loopback interfaces?) because we
|
# maybe we should explicity ignore management and loopback interfaces?) because we
|
||||||
@ -618,8 +619,10 @@ def parse_dpg(dpg, hname):
|
|||||||
# Give a warning if trying to attach ACL to a LAG member interface, correct way is to attach ACL to the LAG interface
|
# Give a warning if trying to attach ACL to a LAG member interface, correct way is to attach ACL to the LAG interface
|
||||||
if port_alias_map[member] in intfs_inpc:
|
if port_alias_map[member] in intfs_inpc:
|
||||||
print("Warning: ACL " + aclname + " is attached to a LAG member interface " + port_alias_map[member] + ", instead of LAG interface", file=sys.stderr)
|
print("Warning: ACL " + aclname + " is attached to a LAG member interface " + port_alias_map[member] + ", instead of LAG interface", file=sys.stderr)
|
||||||
elif member.lower().startswith('erspan') or member.lower().startswith('egress_erspan'):
|
elif member.lower().startswith('erspan') or member.lower().startswith('egress_erspan') or member.lower().startswith('erspan_dscp'):
|
||||||
if member.lower().startswith('erspanv6') or member.lower().startswith('egress_erspanv6'):
|
if 'dscp' in member.lower():
|
||||||
|
is_mirror_dscp = True
|
||||||
|
elif member.lower().startswith('erspanv6') or member.lower().startswith('egress_erspanv6'):
|
||||||
is_mirror_v6 = True
|
is_mirror_v6 = True
|
||||||
else:
|
else:
|
||||||
is_mirror = True
|
is_mirror = True
|
||||||
@ -639,7 +642,7 @@ def parse_dpg(dpg, hname):
|
|||||||
# are binded then do not classify as Control plane.
|
# are binded then do not classify as Control plane.
|
||||||
# For multi-asic platforms it's possible there is no
|
# For multi-asic platforms it's possible there is no
|
||||||
# interface are binded to everflow in host namespace.
|
# interface are binded to everflow in host namespace.
|
||||||
if acl_intfs or is_mirror_v6 or is_mirror:
|
if acl_intfs or is_mirror_v6 or is_mirror or is_mirror_dscp:
|
||||||
# Remove duplications
|
# Remove duplications
|
||||||
dedup_intfs = []
|
dedup_intfs = []
|
||||||
for intf in acl_intfs:
|
for intf in acl_intfs:
|
||||||
@ -653,6 +656,8 @@ def parse_dpg(dpg, hname):
|
|||||||
acls[aclname]['type'] = 'MIRROR'
|
acls[aclname]['type'] = 'MIRROR'
|
||||||
elif is_mirror_v6:
|
elif is_mirror_v6:
|
||||||
acls[aclname]['type'] = 'MIRRORV6'
|
acls[aclname]['type'] = 'MIRRORV6'
|
||||||
|
elif is_mirror_dscp:
|
||||||
|
acls[aclname]['type'] = 'MIRROR_DSCP'
|
||||||
else:
|
else:
|
||||||
acls[aclname]['type'] = 'L3V6' if 'v6' in aclname.lower() else 'L3'
|
acls[aclname]['type'] = 'L3V6' if 'v6' in aclname.lower() else 'L3'
|
||||||
else:
|
else:
|
||||||
@ -1088,7 +1093,7 @@ def filter_acl_table_bindings(acls, neighbors, port_channels, sub_role):
|
|||||||
# Control Plane ACL has no Interface associated and
|
# Control Plane ACL has no Interface associated and
|
||||||
# Data Plane ACL Interface are attached via minigraph
|
# Data Plane ACL Interface are attached via minigraph
|
||||||
# AclInterface.
|
# AclInterface.
|
||||||
if group_type != 'MIRROR' and group_type != 'MIRRORV6':
|
if group_type != 'MIRROR' and group_type != 'MIRRORV6' and group_type != 'MIRROR_DSCP':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Filters out back-panel ports from the binding list for Everflow (Mirror)
|
# Filters out back-panel ports from the binding list for Everflow (Mirror)
|
||||||
|
@ -189,6 +189,11 @@
|
|||||||
<InAcl>SNMP_ACL</InAcl>
|
<InAcl>SNMP_ACL</InAcl>
|
||||||
<Type>SNMP</Type>
|
<Type>SNMP</Type>
|
||||||
</AclInterface>
|
</AclInterface>
|
||||||
|
<AclInterface>
|
||||||
|
<AttachTo>ERSPAN_DSCP</AttachTo>
|
||||||
|
<InAcl>Everflow_dscp</InAcl>
|
||||||
|
<Type>Everflow_dscp</Type>
|
||||||
|
</AclInterface>
|
||||||
</AclInterfaces>
|
</AclInterfaces>
|
||||||
<DownstreamSummaries/>
|
<DownstreamSummaries/>
|
||||||
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||||
|
@ -382,4 +382,18 @@ class TestCfgGenCaseInsensitive(TestCase):
|
|||||||
expected
|
expected
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_minigraph_mirror_dscp(self):
|
||||||
|
result = minigraph.parse_xml(self.sample_graph, port_config_file=self.port_config)
|
||||||
|
self.assertTrue('EVERFLOW_DSCP' in result['ACL_TABLE'])
|
||||||
|
everflow_dscp_entry = result['ACL_TABLE']['EVERFLOW_DSCP']
|
||||||
|
|
||||||
|
self.assertEqual(everflow_dscp_entry['type'], 'MIRROR_DSCP')
|
||||||
|
self.assertEqual(everflow_dscp_entry['stage'], 'ingress')
|
||||||
|
expected_ports = ['PortChannel01', 'Ethernet12', 'Ethernet8', 'Ethernet0']
|
||||||
|
self.assertEqual(
|
||||||
|
everflow_dscp_entry['ports'].sort(),
|
||||||
|
expected_ports.sort()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user