Skip to content

Commit c5f363f

Browse files
committed
lldp-syncd: handle unsupported LLDP subtypes without traceback
1 parent a501930 commit c5f363f

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

src/lldp_syncd/daemon.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -302,21 +302,22 @@ def parse_chassis(self, chassis_attributes):
302302
try:
303303
if 'id' in chassis_attributes and 'id' not in chassis_attributes['id']:
304304
attributes = chassis_attributes
305-
id_attributes = chassis_attributes.get('id', {})
305+
id_attributes = chassis_attributes.get('id') or {}
306306
else:
307307
(sys_name, attributes) = list(chassis_attributes.items())[0]
308-
id_attributes = attributes.get('id', {})
308+
id_attributes = attributes.get('id') or {}
309309

310310
id_type = id_attributes.get('type')
311311

312312
if id_type not in self.ChassisIdSubtypeMap.__members__:
313-
logger.error(
314-
"Unsupported LLDP chassis ID subtype: %s",
315-
id_type,
316-
)
313+
logger.warning(
314+
"lldp-syncd: unsupported chassis id subtype: %s",
315+
id_type,
316+
)
317317
else:
318-
chassis_id_subtype = str(self.ChassisIdSubtypeMap[id_type].value)
319-
chassis_id = id_attributes.get('value', '')
318+
chassis_id_subtype = str(self.ChassisIdSubtypeMap[id_type].value)
319+
chassis_id = id_attributes.get('value', '')
320+
320321

321322
descr = attributes.get('descr', '')
322323
mgmt_ip = attributes.get('mgmt-ip', '')
@@ -334,23 +335,23 @@ def parse_chassis(self, chassis_attributes):
334335
)
335336

336337
def parse_port(self, port_attributes):
337-
port_identifiers = port_attributes.get('id', {})
338+
port_identifiers = port_attributes.get('id') or {}
338339

339-
subtype = None
340-
value = None
340+
subtype = None
341+
value = None
341342

342-
id_type = port_identifiers.get('type')
343+
id_type = port_identifiers.get('type')
343344

344-
if id_type not in self.PortIdSubtypeMap.__members__:
345-
logger.error(
346-
"Unsupported LLDP port ID subtype: %s",
345+
if id_type not in self.PortIdSubtypeMap.__members__:
346+
logger.warning(
347+
"lldp-syncd: unsupported port id subtype: %s",
347348
id_type,
348349
)
349-
else:
350+
else:
350351
subtype = str(self.PortIdSubtypeMap[id_type].value)
351352
value = port_identifiers.get('value', '')
352353

353-
return (
354+
return (
354355
subtype,
355356
value,
356357
port_attributes.get('descr', ''),

0 commit comments

Comments
 (0)