Skip to content

Commit

Permalink
Updating overridden exception case
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-kt committed Jul 16, 2023
1 parent 532bd12 commit 28c4d40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _state_overridden(self, want, have):
diff = get_diff(l3_interfaces_to_delete, new_want, TEST_KEYS)

if diff:
delete_interfaces_requests = self.get_delete_all_requests(diff)
delete_interfaces_requests = self.get_delete_all_requests(have)
ret_requests.extend(delete_interfaces_requests)
commands.extend(update_states(diff, "deleted"))
interfaces_to_create_requests = self.get_create_l3_interfaces_requests(want, have, want)
Expand Down Expand Up @@ -247,7 +247,7 @@ def update_object(self, want):
def get_interface_object_for_overridden(self, have):
objects = list()
for obj in have:
if 'name' in obj:
if 'name' in obj and obj['name'] != "Management0":
ipv4_addresses = obj['ipv4']['addresses']
ipv6_addresses = obj['ipv6']['addresses']
anycast_addresses = obj['ipv4']['anycast_addresses']
Expand Down Expand Up @@ -393,8 +393,9 @@ def get_delete_l3_interfaces_requests(self, want, have):
def get_delete_all_completely_requests(self, configs):
delete_requests = list()
for l3 in configs:
if l3['ipv4'] or l3['ipv6']:
delete_requests.append(l3)
if l3['name'] != "Management0":
if l3['ipv4'] or l3['ipv6']:
delete_requests.append(l3)
return self.get_delete_all_requests(delete_requests)

def get_delete_all_requests(self, configs):
Expand All @@ -408,6 +409,8 @@ def get_delete_all_requests(self, configs):
name = l3.get('name')
ipv4_addrs = []
ipv4_anycast = []
if name == "Management0":
continue
if l3.get('ipv4'):
if l3['ipv4'].get('addresses'):
ipv4_addrs = l3['ipv4']['addresses']
Expand Down
2 changes: 2 additions & 0 deletions tests/regression/roles/sonic_l3_interfaces/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ tests:
addresses:
- address: 152.1.1.1/32
- address: 153.1.1.1/32
secondary: true
- name: vlan 100
ipv4:
anycast_addresses:
Expand All @@ -281,6 +282,7 @@ tests:
description: Delete all interfaces config
state: deleted
input:
- name: vlan 100
- name: vlan 101
- name: vlan 102
- name: vlan 501
Expand Down

0 comments on commit 28c4d40

Please sign in to comment.