Skip to content

Commit c7ea347

Browse files
oleksandrivantsivtaoyl-ms
authored andcommitted
[swss]: Generate config files for Everflow and IPinIP from minigraph (#507)
[swss]: Generate config files for Everflow and IPinIP from minigraph - Add Everflow DST IP to minigraph file - Extend minigraph.py to support Everflow - Add templates file for Everflow and IPinIP configuration - Add config.sh for swss docker to generate config files
1 parent 4fe9416 commit c7ea347

File tree

19 files changed

+166
-3
lines changed

19 files changed

+166
-3
lines changed

device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,11 @@
10641064
<a:Reference i:nil="true"/>
10651065
<a:Value></a:Value>
10661066
</a:DeviceProperty>
1067+
<a:DeviceProperty>
1068+
<a:Name>ErspanDestinationIpv4</a:Name>
1069+
<a:Reference i:nil="true"/>
1070+
<a:Value>2.2.2.2</a:Value>
1071+
</a:DeviceProperty>
10671072
</a:Properties>
10681073
</a:DeviceMetadata>
10691074
</Devices>

device/arista/x86_64-arista_7050_qx32/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,11 @@
10641064
<a:Reference i:nil="true"/>
10651065
<a:Value></a:Value>
10661066
</a:DeviceProperty>
1067+
<a:DeviceProperty>
1068+
<a:Name>ErspanDestinationIpv4</a:Name>
1069+
<a:Reference i:nil="true"/>
1070+
<a:Value>2.2.2.2</a:Value>
1071+
</a:DeviceProperty>
10671072
</a:Properties>
10681073
</a:DeviceMetadata>
10691074
</Devices>

device/arista/x86_64-arista_7060_cx32s/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,11 @@
10641064
<a:Reference i:nil="true"/>
10651065
<a:Value></a:Value>
10661066
</a:DeviceProperty>
1067+
<a:DeviceProperty>
1068+
<a:Name>ErspanDestinationIpv4</a:Name>
1069+
<a:Reference i:nil="true"/>
1070+
<a:Value>2.2.2.2</a:Value>
1071+
</a:DeviceProperty>
10671072
</a:Properties>
10681073
</a:DeviceMetadata>
10691074
</Devices>

device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,11 @@
10641064
<a:Reference i:nil="true"/>
10651065
<a:Value></a:Value>
10661066
</a:DeviceProperty>
1067+
<a:DeviceProperty>
1068+
<a:Name>ErspanDestinationIpv4</a:Name>
1069+
<a:Reference i:nil="true"/>
1070+
<a:Value>2.2.2.2</a:Value>
1071+
</a:DeviceProperty>
10671072
</a:Properties>
10681073
</a:DeviceMetadata>
10691074
</Devices>

device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,11 @@
759759
<a:Reference i:nil="true"/>
760760
<a:Value></a:Value>
761761
</a:DeviceProperty>
762+
<a:DeviceProperty>
763+
<a:Name>ErspanDestinationIpv4</a:Name>
764+
<a:Reference i:nil="true"/>
765+
<a:Value>2.2.2.2</a:Value>
766+
</a:DeviceProperty>
762767
</a:Properties>
763768
</a:DeviceMetadata>
764769
</Devices>

device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,11 @@
10641064
<a:Reference i:nil="true"/>
10651065
<a:Value></a:Value>
10661066
</a:DeviceProperty>
1067+
<a:DeviceProperty>
1068+
<a:Name>ErspanDestinationIpv4</a:Name>
1069+
<a:Reference i:nil="true"/>
1070+
<a:Value>2.2.2.2</a:Value>
1071+
</a:DeviceProperty>
10671072
</a:Properties>
10681073
</a:DeviceMetadata>
10691074
</Devices>

device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
<a:Reference i:nil="true"/>
137137
<a:Value></a:Value>
138138
</a:DeviceProperty>
139+
<a:DeviceProperty>
140+
<a:Name>ErspanDestinationIpv4</a:Name>
141+
<a:Reference i:nil="true"/>
142+
<a:Value>2.2.2.2</a:Value>
143+
</a:DeviceProperty>
139144
</a:Properties>
140145
</a:DeviceMetadata>
141146
</Devices>

device/mellanox/x86_64-mlnx_msn2410-r0/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,11 @@
510510
<a:Reference i:nil="true"/>
511511
<a:Value></a:Value>
512512
</a:DeviceProperty>
513+
<a:DeviceProperty>
514+
<a:Name>ErspanDestinationIpv4</a:Name>
515+
<a:Reference i:nil="true"/>
516+
<a:Value>2.2.2.2</a:Value>
517+
</a:DeviceProperty>
513518
</a:Properties>
514519
</a:DeviceMetadata>
515520
</Devices>

device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml

+5
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,11 @@
10641064
<a:Reference i:nil="true"/>
10651065
<a:Value></a:Value>
10661066
</a:DeviceProperty>
1067+
<a:DeviceProperty>
1068+
<a:Name>ErspanDestinationIpv4</a:Name>
1069+
<a:Reference i:nil="true"/>
1070+
<a:Value>2.2.2.2</a:Value>
1071+
</a:DeviceProperty>
10671072
</a:Properties>
10681073
</a:DeviceMetadata>
10691074
</Devices>

dockers/docker-orchagent/Dockerfile.j2

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ debs/{{ deb }}{{' '}}
2323
{%- endfor %}
2424

2525
COPY start.sh /usr/bin/start.sh
26+
COPY config.sh /usr/bin/config.sh
27+
COPY ipinip.json.j2 /usr/share/sonic/templates/ipinip.json.j2
28+
COPY mirror.json.j2 /usr/share/sonic/templates/mirror.json.j2
2629

2730
## Clean up
2831
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y

dockers/docker-orchagent/config.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -e
2+
3+
mkdir -p /etc/swss/config.d/
4+
5+
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json
6+
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
4+
"tunnel_type":"IPINIP",
5+
"src_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}",
6+
"dst_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}",
7+
{% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %}
8+
"dscp_mode":"uniform",
9+
"ecn_mode":"standard",
10+
{% else %}
11+
"dscp_mode":"pipe",
12+
"ecn_mode":"copy_from_outer",
13+
{% endif %}
14+
"ttl_mode":"pipe"
15+
},
16+
"OP": "SET"
17+
}
18+
]
19+
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[
2+
{% if erspan_dst %}
3+
{
4+
"MIRROR_SESSION_TABLE:everflow": {
5+
"src_ip": "{{ minigraph_lo_interfaces[0]['addr'] }}",
6+
"dst_ip": "{{ erspan_dst[0] }}",
7+
{% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %}
8+
"gre_type": "0x6558",
9+
"queue": "1",
10+
{% else %}
11+
"gre_type": "0x88be",
12+
"queue": "0",
13+
{% endif %}
14+
"dscp": "8",
15+
"ttl": "255"
16+
},
17+
"OP": "SET"
18+
}
19+
{% endif %}
20+
]
21+

dockers/docker-orchagent/start.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22

3+
. config.sh
4+
35
export platform=`sonic-cfggen -m /etc/sonic/minigraph.xml -v platform`
46

57
function start_app {
@@ -45,7 +47,7 @@ ORCHAGENT_ARGS=""
4547

4648
PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini"
4749

48-
SWSSCONFIG_ARGS="00-copp.config.json "
50+
SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json "
4951

5052
if [ "$HWSKU" == "Force10-S6000" ]; then
5153
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"

src/sonic-config-engine/minigraph.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ def parse_meta(meta, hname):
282282
dhcp_servers = []
283283
ntp_servers = []
284284
mgmt_routes = []
285+
erspan_dst = []
285286
device_metas = meta.find(str(QName(ns, "Devices")))
286287
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
287288
if device.find(str(QName(ns1, "Name"))).text == hname:
@@ -298,7 +299,9 @@ def parse_meta(meta, hname):
298299
syslog_servers = value_group
299300
elif name == "ForcedMgmtRoutes":
300301
mgmt_routes = value_group
301-
return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes
302+
elif name == "ErspanDestinationIpv4":
303+
erspan_dst = value_group
304+
return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst
302305

303306

304307
def get_console_info(devices, dev, port):
@@ -391,6 +394,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
391394
dhcp_servers = []
392395
ntp_servers = []
393396
mgmt_routes = []
397+
erspan_dst = []
394398

395399
hwsku_qn = QName(ns, "HwSku")
396400
hostname_qn = QName(ns, "Hostname")
@@ -412,7 +416,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
412416
elif child.tag == str(QName(ns, "UngDec")):
413417
(u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname)
414418
elif child.tag == str(QName(ns, "MetadataDeclaration")):
415-
(syslog_servers, dhcp_servers, ntp_servers, mgmt_routes) = parse_meta(child, hostname)
419+
(syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst) = parse_meta(child, hostname)
416420

417421
Tree = lambda: defaultdict(Tree)
418422

@@ -460,6 +464,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
460464
results['dhcp_servers'] = dhcp_servers
461465
results['ntp_servers'] = ntp_servers
462466
results['forced_mgmt_routes'] = mgmt_routes
467+
results['erspan_dst'] = erspan_dst
463468

464469
return results
465470

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
4+
"tunnel_type":"IPINIP",
5+
"src_ip":"10.1.0.32",
6+
"dst_ip":"10.1.0.32",
7+
"dscp_mode":"pipe",
8+
"ecn_mode":"copy_from_outer",
9+
"ttl_mode":"pipe"
10+
},
11+
"OP": "SET"
12+
}
13+
]
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"MIRROR_SESSION_TABLE:everflow": {
4+
"src_ip": "10.1.0.32",
5+
"dst_ip": "2.2.2.2",
6+
"gre_type": "0x88be",
7+
"queue": "0",
8+
"dscp": "8",
9+
"ttl": "255"
10+
},
11+
"OP": "SET"
12+
}
13+
]
14+

src/sonic-config-engine/tests/t0-sample-graph.xml

+15
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@
317317
</Device>
318318
</Devices>
319319
</PngDec>
320+
<MetadataDeclaration>
321+
<Devices xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
322+
<a:DeviceMetadata>
323+
<a:Name>switch-t0</a:Name>
324+
<a:Properties>
325+
<a:DeviceProperty>
326+
<a:Name>ErspanDestinationIpv4</a:Name>
327+
<a:Reference i:nil="true"/>
328+
<a:Value>2.2.2.2</a:Value>
329+
</a:DeviceProperty>
330+
</a:Properties>
331+
</a:DeviceMetadata>
332+
</Devices>
333+
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
334+
</MetadataDeclaration>
320335
<Hostname>switch-t0</Hostname>
321336
<HwSku>Force10-S6000</HwSku>
322337
</DeviceMiniGraph>

src/sonic-config-engine/tests/test_j2files.py

+19
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,25 @@ def test_render_teamd(self, pc):
4646
assert pc_name in pc_list
4747
test_render_teamd(self, pc_name)
4848

49+
def test_ipinip(self):
50+
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
51+
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ipinip_file + ' > ' + self.output_file
52+
self.run_script(argument)
53+
54+
sample_output_file = os.path.join(self.test_dir, 'sample_output', 'ipinip.json')
55+
56+
assert filecmp.cmp(sample_output_file, self.output_file)
57+
58+
def test_everflow(self):
59+
everflow_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'mirror.json.j2')
60+
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + everflow_file + ' > ' + self.output_file
61+
self.run_script(argument)
62+
63+
sample_output_file = os.path.join(self.test_dir, 'sample_output', 'mirror.json')
64+
65+
assert filecmp.cmp(sample_output_file, self.output_file)
66+
67+
4968
def tearDown(self):
5069
try:
5170
os.remove(self.output_file)

0 commit comments

Comments
 (0)