[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
This commit is contained in:
parent
4fe9416a14
commit
c7ea3470ed
@ -1064,6 +1064,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -1064,6 +1064,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -1064,6 +1064,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -1064,6 +1064,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -759,6 +759,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -1064,6 +1064,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -136,6 +136,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -510,6 +510,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -1064,6 +1064,11 @@
|
|||||||
<a:Reference i:nil="true"/>
|
<a:Reference i:nil="true"/>
|
||||||
<a:Value></a:Value>
|
<a:Value></a:Value>
|
||||||
</a:DeviceProperty>
|
</a:DeviceProperty>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
</a:Properties>
|
</a:Properties>
|
||||||
</a:DeviceMetadata>
|
</a:DeviceMetadata>
|
||||||
</Devices>
|
</Devices>
|
||||||
|
@ -23,6 +23,9 @@ debs/{{ deb }}{{' '}}
|
|||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
COPY start.sh /usr/bin/start.sh
|
COPY start.sh /usr/bin/start.sh
|
||||||
|
COPY config.sh /usr/bin/config.sh
|
||||||
|
COPY ipinip.json.j2 /usr/share/sonic/templates/ipinip.json.j2
|
||||||
|
COPY mirror.json.j2 /usr/share/sonic/templates/mirror.json.j2
|
||||||
|
|
||||||
## Clean up
|
## Clean up
|
||||||
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
|
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
|
||||||
|
6
dockers/docker-orchagent/config.sh
Executable file
6
dockers/docker-orchagent/config.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
mkdir -p /etc/swss/config.d/
|
||||||
|
|
||||||
|
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/ipinip.json.j2 > /etc/swss/config.d/ipinip.json
|
||||||
|
sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json
|
19
dockers/docker-orchagent/ipinip.json.j2
Normal file
19
dockers/docker-orchagent/ipinip.json.j2
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
|
||||||
|
"tunnel_type":"IPINIP",
|
||||||
|
"src_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}",
|
||||||
|
"dst_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}",
|
||||||
|
{% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %}
|
||||||
|
"dscp_mode":"uniform",
|
||||||
|
"ecn_mode":"standard",
|
||||||
|
{% else %}
|
||||||
|
"dscp_mode":"pipe",
|
||||||
|
"ecn_mode":"copy_from_outer",
|
||||||
|
{% endif %}
|
||||||
|
"ttl_mode":"pipe"
|
||||||
|
},
|
||||||
|
"OP": "SET"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
21
dockers/docker-orchagent/mirror.json.j2
Normal file
21
dockers/docker-orchagent/mirror.json.j2
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
[
|
||||||
|
{% if erspan_dst %}
|
||||||
|
{
|
||||||
|
"MIRROR_SESSION_TABLE:everflow": {
|
||||||
|
"src_ip": "{{ minigraph_lo_interfaces[0]['addr'] }}",
|
||||||
|
"dst_ip": "{{ erspan_dst[0] }}",
|
||||||
|
{% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %}
|
||||||
|
"gre_type": "0x6558",
|
||||||
|
"queue": "1",
|
||||||
|
{% else %}
|
||||||
|
"gre_type": "0x88be",
|
||||||
|
"queue": "0",
|
||||||
|
{% endif %}
|
||||||
|
"dscp": "8",
|
||||||
|
"ttl": "255"
|
||||||
|
},
|
||||||
|
"OP": "SET"
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
]
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
. config.sh
|
||||||
|
|
||||||
export platform=`sonic-cfggen -m /etc/sonic/minigraph.xml -v platform`
|
export platform=`sonic-cfggen -m /etc/sonic/minigraph.xml -v platform`
|
||||||
|
|
||||||
function start_app {
|
function start_app {
|
||||||
@ -45,7 +47,7 @@ ORCHAGENT_ARGS=""
|
|||||||
|
|
||||||
PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini"
|
PORTSYNCD_ARGS="-p /usr/share/sonic/hwsku/port_config.ini"
|
||||||
|
|
||||||
SWSSCONFIG_ARGS="00-copp.config.json "
|
SWSSCONFIG_ARGS="00-copp.config.json ipinip.json mirror.json "
|
||||||
|
|
||||||
if [ "$HWSKU" == "Force10-S6000" ]; then
|
if [ "$HWSKU" == "Force10-S6000" ]; then
|
||||||
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
||||||
|
@ -282,6 +282,7 @@ def parse_meta(meta, hname):
|
|||||||
dhcp_servers = []
|
dhcp_servers = []
|
||||||
ntp_servers = []
|
ntp_servers = []
|
||||||
mgmt_routes = []
|
mgmt_routes = []
|
||||||
|
erspan_dst = []
|
||||||
device_metas = meta.find(str(QName(ns, "Devices")))
|
device_metas = meta.find(str(QName(ns, "Devices")))
|
||||||
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
|
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
|
||||||
if device.find(str(QName(ns1, "Name"))).text == hname:
|
if device.find(str(QName(ns1, "Name"))).text == hname:
|
||||||
@ -298,7 +299,9 @@ def parse_meta(meta, hname):
|
|||||||
syslog_servers = value_group
|
syslog_servers = value_group
|
||||||
elif name == "ForcedMgmtRoutes":
|
elif name == "ForcedMgmtRoutes":
|
||||||
mgmt_routes = value_group
|
mgmt_routes = value_group
|
||||||
return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes
|
elif name == "ErspanDestinationIpv4":
|
||||||
|
erspan_dst = value_group
|
||||||
|
return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst
|
||||||
|
|
||||||
|
|
||||||
def get_console_info(devices, dev, port):
|
def get_console_info(devices, dev, port):
|
||||||
@ -391,6 +394,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
|||||||
dhcp_servers = []
|
dhcp_servers = []
|
||||||
ntp_servers = []
|
ntp_servers = []
|
||||||
mgmt_routes = []
|
mgmt_routes = []
|
||||||
|
erspan_dst = []
|
||||||
|
|
||||||
hwsku_qn = QName(ns, "HwSku")
|
hwsku_qn = QName(ns, "HwSku")
|
||||||
hostname_qn = QName(ns, "Hostname")
|
hostname_qn = QName(ns, "Hostname")
|
||||||
@ -412,7 +416,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
|||||||
elif child.tag == str(QName(ns, "UngDec")):
|
elif child.tag == str(QName(ns, "UngDec")):
|
||||||
(u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname)
|
(u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname)
|
||||||
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
elif child.tag == str(QName(ns, "MetadataDeclaration")):
|
||||||
(syslog_servers, dhcp_servers, ntp_servers, mgmt_routes) = parse_meta(child, hostname)
|
(syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst) = parse_meta(child, hostname)
|
||||||
|
|
||||||
Tree = lambda: defaultdict(Tree)
|
Tree = lambda: defaultdict(Tree)
|
||||||
|
|
||||||
@ -460,6 +464,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
|
|||||||
results['dhcp_servers'] = dhcp_servers
|
results['dhcp_servers'] = dhcp_servers
|
||||||
results['ntp_servers'] = ntp_servers
|
results['ntp_servers'] = ntp_servers
|
||||||
results['forced_mgmt_routes'] = mgmt_routes
|
results['forced_mgmt_routes'] = mgmt_routes
|
||||||
|
results['erspan_dst'] = erspan_dst
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
14
src/sonic-config-engine/tests/sample_output/ipinip.json
Normal file
14
src/sonic-config-engine/tests/sample_output/ipinip.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
|
||||||
|
"tunnel_type":"IPINIP",
|
||||||
|
"src_ip":"10.1.0.32",
|
||||||
|
"dst_ip":"10.1.0.32",
|
||||||
|
"dscp_mode":"pipe",
|
||||||
|
"ecn_mode":"copy_from_outer",
|
||||||
|
"ttl_mode":"pipe"
|
||||||
|
},
|
||||||
|
"OP": "SET"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
14
src/sonic-config-engine/tests/sample_output/mirror.json
Normal file
14
src/sonic-config-engine/tests/sample_output/mirror.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"MIRROR_SESSION_TABLE:everflow": {
|
||||||
|
"src_ip": "10.1.0.32",
|
||||||
|
"dst_ip": "2.2.2.2",
|
||||||
|
"gre_type": "0x88be",
|
||||||
|
"queue": "0",
|
||||||
|
"dscp": "8",
|
||||||
|
"ttl": "255"
|
||||||
|
},
|
||||||
|
"OP": "SET"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -317,6 +317,21 @@
|
|||||||
</Device>
|
</Device>
|
||||||
</Devices>
|
</Devices>
|
||||||
</PngDec>
|
</PngDec>
|
||||||
|
<MetadataDeclaration>
|
||||||
|
<Devices xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||||
|
<a:DeviceMetadata>
|
||||||
|
<a:Name>switch-t0</a:Name>
|
||||||
|
<a:Properties>
|
||||||
|
<a:DeviceProperty>
|
||||||
|
<a:Name>ErspanDestinationIpv4</a:Name>
|
||||||
|
<a:Reference i:nil="true"/>
|
||||||
|
<a:Value>2.2.2.2</a:Value>
|
||||||
|
</a:DeviceProperty>
|
||||||
|
</a:Properties>
|
||||||
|
</a:DeviceMetadata>
|
||||||
|
</Devices>
|
||||||
|
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||||
|
</MetadataDeclaration>
|
||||||
<Hostname>switch-t0</Hostname>
|
<Hostname>switch-t0</Hostname>
|
||||||
<HwSku>Force10-S6000</HwSku>
|
<HwSku>Force10-S6000</HwSku>
|
||||||
</DeviceMiniGraph>
|
</DeviceMiniGraph>
|
||||||
|
@ -46,6 +46,25 @@ class TestJ2Files(TestCase):
|
|||||||
assert pc_name in pc_list
|
assert pc_name in pc_list
|
||||||
test_render_teamd(self, pc_name)
|
test_render_teamd(self, pc_name)
|
||||||
|
|
||||||
|
def test_ipinip(self):
|
||||||
|
ipinip_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'ipinip.json.j2')
|
||||||
|
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + ipinip_file + ' > ' + self.output_file
|
||||||
|
self.run_script(argument)
|
||||||
|
|
||||||
|
sample_output_file = os.path.join(self.test_dir, 'sample_output', 'ipinip.json')
|
||||||
|
|
||||||
|
assert filecmp.cmp(sample_output_file, self.output_file)
|
||||||
|
|
||||||
|
def test_everflow(self):
|
||||||
|
everflow_file = os.path.join(self.test_dir, '..', '..', '..', 'dockers', 'docker-orchagent', 'mirror.json.j2')
|
||||||
|
argument = '-m ' + self.t0_minigraph + ' -p ' + self.t0_port_config + ' -t ' + everflow_file + ' > ' + self.output_file
|
||||||
|
self.run_script(argument)
|
||||||
|
|
||||||
|
sample_output_file = os.path.join(self.test_dir, 'sample_output', 'mirror.json')
|
||||||
|
|
||||||
|
assert filecmp.cmp(sample_output_file, self.output_file)
|
||||||
|
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
||||||
os.remove(self.output_file)
|
os.remove(self.output_file)
|
||||||
|
Reference in New Issue
Block a user