Fixes nxos_l2_interfaces module traceback if allowed vlans are not preconfigured (#67457)
* fixes 67455 * fix review
This commit is contained in:
parent
0d72d2d4d2
commit
f292f21d86
1 changed files with 9 additions and 3 deletions
|
@ -267,7 +267,7 @@ class L2_interfaces(ConfigBase):
|
||||||
|
|
||||||
def set_commands(self, w, have, replace=False):
|
def set_commands(self, w, have, replace=False):
|
||||||
commands = []
|
commands = []
|
||||||
vlan_tobe_added = []
|
|
||||||
obj_in_have = flatten_dict(search_obj_in_list(w['name'], have, 'name'))
|
obj_in_have = flatten_dict(search_obj_in_list(w['name'], have, 'name'))
|
||||||
if not obj_in_have:
|
if not obj_in_have:
|
||||||
commands = self.add_commands(w)
|
commands = self.add_commands(w)
|
||||||
|
@ -277,13 +277,19 @@ class L2_interfaces(ConfigBase):
|
||||||
if "allowed_vlans" in diff.keys() and diff["allowed_vlans"]:
|
if "allowed_vlans" in diff.keys() and diff["allowed_vlans"]:
|
||||||
vlan_tobe_added = diff["allowed_vlans"].split(',')
|
vlan_tobe_added = diff["allowed_vlans"].split(',')
|
||||||
vlan_list = vlan_tobe_added[:]
|
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:
|
for w_vlans in vlan_list:
|
||||||
if w_vlans in have_vlans:
|
if w_vlans in have_vlans:
|
||||||
vlan_tobe_added.pop(vlan_tobe_added.index(w_vlans))
|
vlan_tobe_added.pop(vlan_tobe_added.index(w_vlans))
|
||||||
if vlan_tobe_added:
|
if vlan_tobe_added:
|
||||||
diff.update({"allowed_vlans": ','.join(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
|
return commands
|
||||||
commands = self.add_commands(diff)
|
commands = self.add_commands(diff)
|
||||||
return commands
|
return commands
|
||||||
|
|
Loading…
Reference in a new issue