fix bug 63761 (#63901)

This commit is contained in:
Sumit Jaiswal 2019-10-31 18:09:03 +05:30 committed by GitHub
parent 548fa65ac6
commit be1bcc7450
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -140,10 +140,11 @@ class Interfaces(ConfigBase):
elif interface['name'] in each['name']: elif interface['name'] in each['name']:
break break
else: else:
# configuring non-existing interface
commands.extend(self._set_config(interface, dict()))
continue continue
have_dict = filter_dict_having_none_value(interface, each) have_dict = filter_dict_having_none_value(interface, each)
want = dict() commands.extend(self._clear_config(dict(), have_dict))
commands.extend(self._clear_config(want, have_dict))
commands.extend(self._set_config(interface, each)) commands.extend(self._set_config(interface, each))
# Remove the duplicate interface call # Remove the duplicate interface call
commands = remove_duplicate_interface(commands) commands = remove_duplicate_interface(commands)
@ -163,10 +164,12 @@ class Interfaces(ConfigBase):
for each in have: for each in have:
for interface in want: for interface in want:
count = 0
if each['name'] == interface['name']: if each['name'] == interface['name']:
break break
elif interface['name'] in each['name']: elif interface['name'] in each['name']:
break break
count += 1
else: else:
# We didn't find a matching desired state, which means we can # We didn't find a matching desired state, which means we can
# pretend we recieved an empty desired state. # pretend we recieved an empty desired state.
@ -174,9 +177,17 @@ class Interfaces(ConfigBase):
commands.extend(self._clear_config(interface, each)) commands.extend(self._clear_config(interface, each))
continue continue
have_dict = filter_dict_having_none_value(interface, each) have_dict = filter_dict_having_none_value(interface, each)
want = dict() commands.extend(self._clear_config(dict(), have_dict))
commands.extend(self._clear_config(want, have_dict))
commands.extend(self._set_config(interface, each)) 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 # Remove the duplicate interface call
commands = remove_duplicate_interface(commands) commands = remove_duplicate_interface(commands)
@ -198,6 +209,8 @@ class Interfaces(ConfigBase):
if each['name'] == interface['name']: if each['name'] == interface['name']:
break break
else: else:
# configuring non-existing interface
commands.extend(self._set_config(interface, dict()))
continue continue
commands.extend(self._set_config(interface, each)) commands.extend(self._set_config(interface, each))