Fixes nxos_l2_interfaces module traceback if allowed vlans are not preconfigured (#67457)

* fixes 67455

* fix review
pull/67693/head
Sumit Jaiswal 4 years ago committed by GitHub
parent 0d72d2d4d2
commit f292f21d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -267,7 +267,7 @@ class L2_interfaces(ConfigBase):
def set_commands(self, w, have, replace=False):
commands = []
vlan_tobe_added = []
obj_in_have = flatten_dict(search_obj_in_list(w['name'], have, 'name'))
if not obj_in_have:
commands = self.add_commands(w)
@ -277,13 +277,19 @@ class L2_interfaces(ConfigBase):
if "allowed_vlans" in diff.keys() and diff["allowed_vlans"]:
vlan_tobe_added = diff["allowed_vlans"].split(',')
vlan_list = vlan_tobe_added[:]
have_vlans = obj_in_have["allowed_vlans"].split(',')
if obj_in_have.get("allowed_vlans"):
have_vlans = obj_in_have["allowed_vlans"].split(',')
else:
have_vlans = []
for w_vlans in vlan_list:
if w_vlans in have_vlans:
vlan_tobe_added.pop(vlan_tobe_added.index(w_vlans))
if vlan_tobe_added:
diff.update({"allowed_vlans": ','.join(vlan_tobe_added)})
commands = self.add_commands(diff, True)
if have_vlans:
commands = self.add_commands(diff, True)
else:
commands = self.add_commands(diff)
return commands
commands = self.add_commands(diff)
return commands

Loading…
Cancel
Save