From 05b3c5c15767e227055d0159f8cba8c4b63ce92e Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Tue, 15 Mar 2022 21:56:29 +0000 Subject: [PATCH] Small refactor, to allow for more interface types to be added as l2xc targets later --- validator/interface.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/validator/interface.py b/validator/interface.py index d3f73d1..e196c67 100644 --- a/validator/interface.py +++ b/validator/interface.py @@ -160,15 +160,14 @@ def is_l2xc_interface(yaml, ifname): def get_l2xc_target_interfaces(yaml): """ Returns a list of all interfaces that are the target of an L2 CrossConnect """ ret = [] - if not 'interfaces' in yaml: - return ret - for ifname, iface in yaml['interfaces'].items(): - if 'l2xc' in iface: - ret.append(iface['l2xc']) - if 'sub-interfaces' in iface: - for sub_ifname, sub_iface in iface['sub-interfaces'].items(): - if 'l2xc' in sub_iface: - ret.append(sub_iface['l2xc']) + if 'interfaces' in yaml: + for ifname, iface in yaml['interfaces'].items(): + if 'l2xc' in iface: + ret.append(iface['l2xc']) + if 'sub-interfaces' in iface: + for sub_ifname, sub_iface in iface['sub-interfaces'].items(): + if 'l2xc' in sub_iface: + ret.append(sub_iface['l2xc']) return ret