Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[swss]: Generate config files for Everflow and IPinIP from minigraph #507

Merged
merged 8 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions device/accton/x86_64-accton_as7512_32x-r0/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/arista/x86_64-arista_7050_qx32/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/arista/x86_64-arista_7060_cx32s/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/dell/x86_64-dell_s6000_s1220-r0/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/dell/x86_64-dell_s6100_c2538-r0/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/dell/x86_64-dell_z9100_c2538-r0/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/ingrasys/x86_64-ingrasys_s9100-r0/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/mellanox/x86_64-mlnx_msn2410-r0/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
5 changes: 5 additions & 0 deletions device/mellanox/x86_64-mlnx_msn2700-r0/minigraph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,11 @@
<a:Reference i:nil="true"/>
<a:Value></a:Value>
</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:DeviceMetadata>
</Devices>
Expand Down
7 changes: 5 additions & 2 deletions dockers/docker-orchagent/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ debs/{{ deb }}{{' '}}
{%- endfor %}

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
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs

ENTRYPOINT ["/bin/bash"]
CMD ["/usr/bin/start.sh"]
ENTRYPOINT ["/bin/bash", "-c"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marian-pritsak has a PR #441 that merges config.sh and start.sh back into a single file. I don't exactly know his reason, but I'll suggest you sync with him to see if he has any concern on using two scripts instead of one.

CMD ["/usr/bin/config.sh && /usr/bin/start.sh"]
6 changes: 6 additions & 0 deletions dockers/docker-orchagent/config.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

@taoyl-ms taoyl-ms Apr 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to support the case that ErspanDestinationIpv4 is not defined in minigraph as well. Current implementation will generate an illegal json therefore crashes docker-orchagent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

sonic-cfggen -m /etc/sonic/minigraph.xml -t /usr/share/sonic/templates/mirror.json.j2 > /etc/swss/config.d/mirror.json
18 changes: 18 additions & 0 deletions dockers/docker-orchagent/ipinip.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"TUNNEL_DECAP_TABLE:IPINIP_TUNNEL" : {
"tunnel_type":"IPINIP",
"src_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}",
"dst_ip":"{{ minigraph_lo_interfaces[0]['addr'] }}",
"dscp_mode":"uniform",
Copy link
Contributor

@sihuihan88 sihuihan88 Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change the dscp_mode to pipe? And validate whether it will work on mlnx platform as well if possible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pipe currently is not supported on Mellanox platforms. Will left it "uniform" for Mellanox platform and pipe for other

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please change broadcom platform to pipe mode. use the asic_type.

{% if minigraph_hwsku in [ 'ACS-MSN2700', 'ACS-MSN2410', 'ACS-MSN2100' ] %}
"ecn_mode":"standard",
{% else %}
"ecn_mode":"copy_from_outer",
{% endif %}
"ttl_mode":"pipe"
},
"OP": "SET"
}
]

18 changes: 18 additions & 0 deletions dockers/docker-orchagent/mirror.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"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",
{% else %}
"gre_type": "0x88be",
{% endif %}
"dscp": "8",
"ttl": "255",
"queue": "1"
},
"OP": "SET"
}
]

2 changes: 1 addition & 1 deletion dockers/docker-orchagent/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ORCHAGENT_ARGS=""

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
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
Expand Down
9 changes: 7 additions & 2 deletions src/sonic-config-engine/minigraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ def parse_meta(meta, hname):
dhcp_servers = []
ntp_servers = []
mgmt_routes = []
erspan_dst = []
device_metas = meta.find(str(QName(ns, "Devices")))
for device in device_metas.findall(str(QName(ns1, "DeviceMetadata"))):
if device.find(str(QName(ns1, "Name"))).text == hname:
Expand All @@ -298,7 +299,9 @@ def parse_meta(meta, hname):
syslog_servers = value_group
elif name == "ForcedMgmtRoutes":
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):
Expand Down Expand Up @@ -391,6 +394,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
dhcp_servers = []
ntp_servers = []
mgmt_routes = []
erspan_dst = []

hwsku_qn = QName(ns, "HwSku")
hostname_qn = QName(ns, "Hostname")
Expand All @@ -412,7 +416,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
elif child.tag == str(QName(ns, "UngDec")):
(u_neighbors, u_devices, _, _, _, _) = parse_png(child, hostname)
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)

Expand Down Expand Up @@ -460,6 +464,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
results['dhcp_servers'] = dhcp_servers
results['ntp_servers'] = ntp_servers
results['forced_mgmt_routes'] = mgmt_routes
results['erspan_dst'] = erspan_dst

return results

Expand Down
14 changes: 14 additions & 0 deletions src/sonic-config-engine/tests/sample_output/ipinip.json
Original file line number Diff line number Diff line change
@@ -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":"uniform",
"ecn_mode":"copy_from_outer",
"ttl_mode":"pipe"
},
"OP": "SET"
}
]

14 changes: 14 additions & 0 deletions src/sonic-config-engine/tests/sample_output/mirror.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"MIRROR_SESSION_TABLE:everflow": {
"src_ip": "10.1.0.32",
"dst_ip": "2.2.2.2",
"gre_type": "0x88be",
"dscp": "8",
"ttl": "255",
"queue": "1"
},
"OP": "SET"
}
]

15 changes: 15 additions & 0 deletions src/sonic-config-engine/tests/t0-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,21 @@
</Device>
</Devices>
</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>
<HwSku>Force10-S6000</HwSku>
</DeviceMiniGraph>
19 changes: 19 additions & 0 deletions src/sonic-config-engine/tests/test_j2files.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ def test_render_teamd(self, pc):
assert pc_name in pc_list
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):
try:
os.remove(self.output_file)
Expand Down