Skip to content

Commit

Permalink
Addressing review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
santhosh-kt committed May 9, 2024
1 parent 2f86b04 commit 2444ce6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions plugins/module_utils/network/sonic/config/vrrp/vrrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,7 @@ def execute_module(self):
old_config = existing_vrrp_facts
if self._module.check_mode:
result.pop('after', None)
existing_vrrp_facts = remove_empties_from_list(existing_vrrp_facts)
is_overridden = False
for cmd in commands:
if cmd['state'] == "overridden":
is_overridden = True
break
if is_overridden:
if self._module.params['state'] == 'overridden':
new_config = get_new_config(commands, existing_vrrp_facts, TEST_KEYS_overridden_diff)
else:
new_config = get_new_config(commands, existing_vrrp_facts, TEST_KEYS_diff)
Expand Down Expand Up @@ -234,7 +228,6 @@ def _state_replaced(self, want, have):
"""
commands, requests = [], []
mod_commands = []
diff = get_diff(want, have, TEST_KEYS)
self.sort_lists_in_config(want)
self.sort_lists_in_config(have)
new_have = deepcopy(have)
Expand All @@ -244,6 +237,7 @@ def _state_replaced(self, want, have):
remove_matching_defaults(new_want, default_entry)
new_have = remove_empties_from_list(new_have)
new_want = remove_empties_from_list(new_want)
diff = get_diff(new_want, new_have, TEST_KEYS)
replaced_config = get_replaced_config(new_want, new_have, TEST_KEYS_for_replaced)
if replaced_config:
is_delete_all = (replaced_config == new_have)
Expand All @@ -259,6 +253,7 @@ def _state_replaced(self, want, have):
if len(mod_requests) > 0:
requests.extend(mod_requests)
commands.extend(update_states(mod_commands, "replaced"))

return commands, requests

def _state_overridden(self, want, have):
Expand Down
6 changes: 3 additions & 3 deletions plugins/module_utils/network/sonic/facts/vrrp/vrrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def get_vrrp(self):
intf_name = interface.get('name')
openconfig = None
if "Eth" in intf_name or 'PortChannel' in intf_name:
sub_interface = interface.get('subinterfaces')
sub_intf_list = sub_interface.get('subinterface')
sub_interface = interface.get('subinterfaces', {})
sub_intf_list = sub_interface.get('subinterface', {})
for sub_intf in sub_intf_list:
if sub_intf.get('index') != 0:
intf_name = intf_name + "." + str(sub_intf.get('index'))
Expand Down Expand Up @@ -169,7 +169,7 @@ def get_vrrp_from_ip_dict(self, vrrp_group, afi):
vrrp_dict = {}
track_interface = group.get('openconfig-interfaces-ext:vrrp-track')
track_intf_group = []
config = group.get("config")
config = group.get("config", [])
for cfg in config:
if cfg != 'virtual-address':
vrrp_dict[vrrp_attributes[cfg]] = config[cfg]
Expand Down

0 comments on commit 2444ce6

Please sign in to comment.