[chassis] Fix uninitialized variable in minigraph parsing (#8917)

Why I did it
Local variable may not be created in minigraph parsing, causing crash

How I did it
Moved variable creation earlier
This commit is contained in:
thomas.cappleman@metaswitch.com 2021-12-07 19:33:17 +00:00 committed by GitHub
parent 46bcda359c
commit 7ebe44a2a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -966,6 +966,7 @@ def parse_asic_meta(meta, hname):
def parse_deviceinfo(meta, hwsku): def parse_deviceinfo(meta, hwsku):
port_speeds = {} port_speeds = {}
port_descriptions = {} port_descriptions = {}
sys_ports = {}
for device_info in meta.findall(str(QName(ns, "DeviceInfo"))): for device_info in meta.findall(str(QName(ns, "DeviceInfo"))):
dev_sku = device_info.find(str(QName(ns, "HwSku"))).text dev_sku = device_info.find(str(QName(ns, "HwSku"))).text
if dev_sku == hwsku: if dev_sku == hwsku:
@ -980,7 +981,6 @@ def parse_deviceinfo(meta, hwsku):
port_speeds[port_alias_map.get(alias, alias)] = speed port_speeds[port_alias_map.get(alias, alias)] = speed
sysports = device_info.find(str(QName(ns, "SystemPorts"))) sysports = device_info.find(str(QName(ns, "SystemPorts")))
sys_ports = {}
if sysports is not None: if sysports is not None:
for sysport in sysports.findall(str(QName(ns, "SystemPort"))): for sysport in sysports.findall(str(QName(ns, "SystemPort"))):
portname = sysport.find(str(QName(ns, "Name"))).text portname = sysport.find(str(QName(ns, "Name"))).text