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

Final code-drop for interface-description and interface-status enhancements #1207

Merged
merged 3 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions dockers/docker-orchagent/ports.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
"PORT_TABLE:{{ port }}": {
"speed": "{{ PORT[port]['speed'] }}"
"description": "{{ PORT[port]['description'] }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

missing comma 😱

},
"OP": "SET"
}{% if not loop.last %},{% endif %}
Expand Down
16 changes: 12 additions & 4 deletions src/sonic-config-engine/minigraph.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,20 @@ def parse_meta(meta, hname):
return syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst, deployment_id

def parse_deviceinfo(meta, hwsku):
ethernet_interfaces = {}
port_speeds = {}
port_descriptions = {}
for device_info in meta.findall(str(QName(ns, "DeviceInfo"))):
dev_sku = device_info.find(str(QName(ns, "HwSku"))).text
if dev_sku == hwsku:
interfaces = device_info.find(str(QName(ns, "EthernetInterfaces")))
for interface in interfaces.findall(str(QName(ns1, "EthernetInterface"))):
alias = interface.find(str(QName(ns, "InterfaceName"))).text
speed = interface.find(str(QName(ns, "Speed"))).text
ethernet_interfaces[port_alias_map.get(alias, alias)] = speed
return ethernet_interfaces
desc = interface.find(str(QName(ns, "Description")))
if desc != None:
port_descriptions[port_alias_map.get(alias, alias)] = desc.text
port_speeds[port_alias_map.get(alias, alias)] = speed
return port_speeds, port_descriptions

def parse_xml(filename, platform=None, port_config_file=None):
root = ET.parse(filename).getroot()
Expand All @@ -330,6 +334,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
devices = None
hostname = None
port_speeds = {}
port_descriptions = {}
syslog_servers = []
dhcp_servers = []
ntp_servers = []
Expand Down Expand Up @@ -360,7 +365,7 @@ def parse_xml(filename, platform=None, port_config_file=None):
elif child.tag == str(QName(ns, "MetadataDeclaration")):
(syslog_servers, dhcp_servers, ntp_servers, mgmt_routes, erspan_dst, deployment_id) = parse_meta(child, hostname)
elif child.tag == str(QName(ns, "DeviceInfos")):
port_speeds = parse_deviceinfo(child, hwsku)
(port_speeds, port_descriptions) = parse_deviceinfo(child, hwsku)

results = {}
results['DEVICE_METADATA'] = {'localhost': {
Expand Down Expand Up @@ -395,6 +400,9 @@ def parse_xml(filename, platform=None, port_config_file=None):

for port_name in port_speeds:
ports.setdefault(port_name, {})['speed'] = port_speeds[port_name]
for port_name in port_descriptions:
ports.setdefault(port_name, {})['description'] = port_descriptions[port_name]

results['PORT'] = ports
results['PORTCHANNEL'] = pcs
results['VLAN'] = vlans
Expand Down
1 change: 1 addition & 0 deletions src/sonic-config-engine/tests/simple-sample-graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
<PortName>0</PortName>
<Priority>0</Priority>
<Speed>40000</Speed>
<Description>Interface description</Description>
</a:EthernetInterface>
<a:EthernetInterface>
<ElementType>DeviceInterface</ElementType>
Expand Down
2 changes: 1 addition & 1 deletion src/sonic-config-engine/tests/test_cfggen.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ def test_minigraph_deployment_id(self):
def test_minigraph_ethernet_interfaces(self):
argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORT[\'Ethernet8\']"'
output = self.run_script(argument)
self.assertEqual(output.strip(), "{'alias': 'fortyGigE0/8', 'lanes': '37,38,39,40', 'speed': '40000'}")
self.assertEqual(output.strip(), "{'alias': 'fortyGigE0/8', 'lanes': '37,38,39,40', 'description': 'Interface description', 'speed': '40000'}")
2 changes: 1 addition & 1 deletion src/sonic-utilities