Backport PR to fix ios_interfaces where non-existing virtual/loopback interfaces was not getting configured (#64259)

* fix bug 63761 (#63901)


(cherry picked from commit be1bcc7450)

* changelog
pull/64756/head
Sumit Jaiswal 6 years ago committed by Matt Clay
parent 153f8341a5
commit 73f42d22ff

@ -0,0 +1,4 @@
---
bugfixes:
- "To fix ios_interfaces where non-existing virtual/loopback interfaces was not getting configured"
- "(https://github.com/ansible/ansible/pull/63901)"

@ -140,10 +140,11 @@ class Interfaces(ConfigBase):
elif interface['name'] in each['name']:
break
else:
# configuring non-existing interface
commands.extend(self._set_config(interface, dict()))
continue
have_dict = filter_dict_having_none_value(interface, each)
want = dict()
commands.extend(self._clear_config(want, have_dict))
commands.extend(self._clear_config(dict(), have_dict))
commands.extend(self._set_config(interface, each))
# Remove the duplicate interface call
commands = remove_duplicate_interface(commands)
@ -163,10 +164,12 @@ class Interfaces(ConfigBase):
for each in have:
for interface in want:
count = 0
if each['name'] == interface['name']:
break
elif interface['name'] in each['name']:
break
count += 1
else:
# We didn't find a matching desired state, which means we can
# pretend we recieved an empty desired state.
@ -174,9 +177,17 @@ class Interfaces(ConfigBase):
commands.extend(self._clear_config(interface, each))
continue
have_dict = filter_dict_having_none_value(interface, each)
want = dict()
commands.extend(self._clear_config(want, have_dict))
commands.extend(self._clear_config(dict(), have_dict))
commands.extend(self._set_config(interface, each))
# as the pre-existing interface are now configured by
# above set_config call, deleting the respective
# interface entry from the want list
del want[count]
# Iterating through want list which now only have new interfaces to be
# configured
for each in want:
commands.extend(self._set_config(each, dict()))
# Remove the duplicate interface call
commands = remove_duplicate_interface(commands)
@ -198,6 +209,8 @@ class Interfaces(ConfigBase):
if each['name'] == interface['name']:
break
else:
# configuring non-existing interface
commands.extend(self._set_config(interface, dict()))
continue
commands.extend(self._set_config(interface, each))

Loading…
Cancel
Save