Skip to content

Commit

Permalink
corrected new apis
Browse files Browse the repository at this point in the history
  • Loading branch information
divya-balasubramania committed Jun 22, 2023
1 parent b2c60ec commit ffd1627
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _state_replaced(self, want, have, diff):
"""
commands = self.filter_comands_to_change(diff, have)
requests = self.get_delete_interface_requests(commands, have)
requests.extend(self.get_modify_interface_requests(commands, have))
requests.extend(self.get_modify_interface_requests(want, have))
if commands and len(requests) > 0:
commands = update_states(commands, "replaced")
else:
Expand All @@ -194,7 +194,9 @@ def _state_overridden(self, want, have, diff):
"""
commands = []
requests = []
if not diff:

diff1 = get_diff(have, want)
if not diff and not diff1:
return commands, requests

commands = have
Expand All @@ -203,12 +205,10 @@ def _state_overridden(self, want, have, diff):
send_requests(self._module, requests)
else:
commands = []
exist_interfaces_facts = self.get_interfaces_facts()
have_new = exist_interfaces_facts
commands_over = get_diff(want, have)
requests = self.get_modify_interface_requests(commands_over, have_new)
requests = self.get_modify_interface_requests(diff, have)

if commands_over and len(requests) > 0:
if len(requests) > 0:
commands = update_states(commands_over, "overridden")

return commands, requests
Expand Down
18 changes: 13 additions & 5 deletions tests/regression/roles/sonic_interfaces/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ tests:
enabled: true
# Ethernet testcases started...
- name: test_case_17
description: Update interface parameters
description: Update interface parameters descr and mtu
state: merged
input:
- name: "{{ interface1 }}"
Expand All @@ -182,6 +182,14 @@ tests:
mtu: 7500
enabled: true
- name: test_case_18
description: Replace interface mtu parameters
state: replaced
input:
- name: "{{ interface1 }}"
mtu: 3300
- name: "{{ interface3 }}"
mtu: 3300
- name: test_case_19
description: Update interface parameters
state: replaced
input:
Expand All @@ -191,15 +199,15 @@ tests:
- name: "{{ interface3 }}"
description: Ansible Interface2
mtu: 3500
- name: test_case_19
- name: test_case_20
description: Update interface parameters
state: overridden
input:
- name: "{{ interface1 }}"
description: Interface1
mtu: 3500
mtu: 3300
enabled: true
- name: test_case_20
description: Update interface parameters
- name: test_case_21
description: Delete interface parameters
state: deleted
input: []

0 comments on commit ffd1627

Please sign in to comment.