Skip to content

Commit

Permalink
[minigraph]: Ignore mirror session portion in minigraph (sonic-net#3410)
Browse files Browse the repository at this point in the history
This piece of information is currently not used. Revert this
pull request in the future to add back the default mirror
session information into the configuration database.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
stcheng authored and yxieca committed Sep 9, 2019
1 parent 541208f commit 614475f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 29 deletions.
28 changes: 15 additions & 13 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,19 +624,21 @@ def parse_xml(filename, platform=None, port_config_file=None):
results['TACPLUS_SERVER'] = dict((item, {'priority': '1', 'tcp_port': '49'}) for item in tacacs_servers)

results['ACL_TABLE'] = acls
mirror_sessions = {}
if erspan_dst:
lo_addr = '0.0.0.0'
for lo in lo_intfs:
lo_network = ipaddress.IPNetwork(lo[1])
if lo_network.version == 4:
lo_addr = str(lo_network.ip)
break
count = 0
for dst in erspan_dst:
mirror_sessions['everflow{}'.format(count)] = {"dst_ip": dst, "src_ip": lo_addr}
count += 1
results['MIRROR_SESSION'] = mirror_sessions

# Do not configure the minigraph's mirror session, which is currently unused
# mirror_sessions = {}
# if erspan_dst:
# lo_addr = '0.0.0.0'
# for lo in lo_intfs:
# lo_network = ipaddress.IPNetwork(lo[1])
# if lo_network.version == 4:
# lo_addr = str(lo_network.ip)
# break
# count = 0
# for dst in erspan_dst:
# mirror_sessions['everflow{}'.format(count)] = {"dst_ip": dst, "src_ip": lo_addr}
# count += 1
# results['MIRROR_SESSION'] = mirror_sessions

return results

Expand Down
18 changes: 10 additions & 8 deletions src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ def test_minigraph_acl(self):
"'SSH_ACL': {'services': ['SSH'], 'type': 'CTRLPLANE', 'policy_desc': 'SSH_ACL'}, "
"'EVERFLOWV6': {'type': 'MIRRORV6', 'policy_desc': 'EVERFLOWV6', 'ports': ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04', 'Ethernet24', 'Ethernet40', 'Ethernet20', 'Ethernet44', 'Ethernet48', 'Ethernet28', 'Ethernet96', 'Ethernet92', 'Ethernet76', 'Ethernet72', 'Ethernet52', 'Ethernet80', 'Ethernet56', 'Ethernet32', 'Ethernet16', 'Ethernet36', 'Ethernet12', 'Ethernet60', 'Ethernet8', 'Ethernet4', 'Ethernet0', 'Ethernet64', 'Ethernet68', 'Ethernet84', 'Ethernet88', 'Ethernet108', 'Ethernet104', 'Ethernet100']}}")

def test_minigraph_everflow(self):
argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v MIRROR_SESSION'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '2.2.2.2'}}")
# everflow portion is not used
# def test_minigraph_everflow(self):
# argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v MIRROR_SESSION'
# output = self.run_script(argument)
# self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '2.2.2.2'}}")

def test_minigraph_mgmt_ports(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v MGMT_PORT'
Expand Down Expand Up @@ -219,10 +220,11 @@ def test_minigraph_extra_ethernet_interfaces(self):
"'Ethernet20': {'alias': 'fortyGigE0/20', 'pfc_asym': 'off', 'lanes': '45,46,47,48', 'description': 'fortyGigE0/20', 'mtu': '9100'}, "
"'Ethernet24': {'alias': 'fortyGigE0/24', 'pfc_asym': 'off', 'lanes': '5,6,7,8', 'description': 'fortyGigE0/24', 'mtu': '9100'}}")

def test_metadata_everflow(self):
argument = '-m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '" -v "MIRROR_SESSION"'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '10.0.100.1'}}")
# everflow portion is not used
# def test_metadata_everflow(self):
# argument = '-m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '" -v "MIRROR_SESSION"'
# output = self.run_script(argument)
# self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '10.0.100.1'}}")

def test_metadata_tacacs(self):
argument = '-m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '" -v "TACPLUS_SERVER"'
Expand Down
18 changes: 10 additions & 8 deletions src/sonic-config-engine/tests/test_minigraph_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ def test_render_template(self):
output = self.run_script(argument)
self.assertEqual(output.strip(), 'value1\nvalue2')

def test_minigraph_everflow(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v MIRROR_SESSION'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '10.0.100.1'}}")
# everflow portion is not used
# def test_minigraph_everflow(self):
# argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v MIRROR_SESSION'
# output = self.run_script(argument)
# self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '10.0.100.1'}}")

def test_minigraph_interfaces(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v \'INTERFACE.keys()\''
Expand Down Expand Up @@ -104,10 +105,11 @@ def test_minigraph_neighbor_metadata(self):
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'switch-01t1': {'lo_addr': '10.1.0.186/32', 'mgmt_addr': '10.7.0.196/26', 'hwsku': 'Force10-S6000', 'type': 'LeafRouter', 'deployment_id': '2'}}")

def test_metadata_everflow(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "MIRROR_SESSION"'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '10.0.100.1'}}")
# everflow portion is not used
# def test_metadata_everflow(self):
# argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "MIRROR_SESSION"'
# output = self.run_script(argument)
# self.assertEqual(output.strip(), "{'everflow0': {'src_ip': '10.1.0.32', 'dst_ip': '10.0.100.1'}}")

def test_metadata_tacacs(self):
argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "TACPLUS_SERVER"'
Expand Down

0 comments on commit 614475f

Please sign in to comment.