Update minigraph parser to support MIRROR_DSCP (#8827)
Signed-off-by: bingwang <bingwang@microsoft.com>
This commit is contained in:
parent
54e32c1f30
commit
00695d918d
@ -244,6 +244,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
|
||||||
@ -263,7 +264,9 @@ def parse_dpg(dpg, hname):
|
|||||||
if port_alias_map[member] in intfs_inpc:
|
if port_alias_map[member] in intfs_inpc:
|
||||||
print >> sys.stderr, "Warning: ACL " + aclname + " is attached to a LAG member interface " + port_alias_map[member] + ", instead of LAG interface"
|
print >> sys.stderr, "Warning: ACL " + aclname + " is attached to a LAG member interface " + port_alias_map[member] + ", instead of LAG interface"
|
||||||
elif member.lower().startswith('erspan'):
|
elif member.lower().startswith('erspan'):
|
||||||
if member.lower().startswith('erspanv6'):
|
if 'dscp' in member.lower():
|
||||||
|
is_mirror_dscp = True
|
||||||
|
elif member.lower().startswith('erspanv6'):
|
||||||
is_mirror_v6 = True
|
is_mirror_v6 = True
|
||||||
else:
|
else:
|
||||||
is_mirror = True
|
is_mirror = True
|
||||||
@ -285,6 +288,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:
|
||||||
@ -488,7 +493,7 @@ def filter_acl_mirror_table_bindings(acls, neighbors, port_channels):
|
|||||||
for acl_table, group_params in acls.iteritems():
|
for acl_table, group_params in acls.iteritems():
|
||||||
group_type = group_params.get('type', None)
|
group_type = group_params.get('type', None)
|
||||||
|
|
||||||
if group_type != 'MIRROR' and group_type != 'MIRRORV6':
|
if group_type != 'MIRROR' and group_type != 'MIRRORV6' and group_type != 'MIRROR_DSCP':
|
||||||
continue
|
continue
|
||||||
|
|
||||||
active_ports = [ port for port in group_params.get('ports', []) if port in neighbors.keys() or port in port_channels ]
|
active_ports = [ port for port in group_params.get('ports', []) if port in neighbors.keys() or port in port_channels ]
|
||||||
|
@ -175,6 +175,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"/>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
|
import minigraph
|
||||||
class TestCfgGenCaseInsensitive(TestCase):
|
class TestCfgGenCaseInsensitive(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -125,3 +125,16 @@ class TestCfgGenCaseInsensitive(TestCase):
|
|||||||
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "NTP_SERVER"'
|
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "NTP_SERVER"'
|
||||||
output = self.run_script(argument)
|
output = self.run_script(argument)
|
||||||
self.assertEqual(output.strip(), "{'10.0.10.1': {}, '10.0.10.2': {}}")
|
self.assertEqual(output.strip(), "{'10.0.10.1': {}, '10.0.10.2': {}}")
|
||||||
|
|
||||||
|
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()
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user