Skip to content

Commit

Permalink
Enable system auditd and ip loadshare hash downward compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
kerry-meyer committed Aug 23, 2024
1 parent c792f81 commit 5d8826b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
13 changes: 4 additions & 9 deletions plugins/module_utils/network/sonic/facts/system/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
)
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.sonic import (
to_request,
edit_config
edit_config,
edit_config_catch
)
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.system.system import SystemArgs

Expand Down Expand Up @@ -90,10 +91,7 @@ def get_anycast_addr(self):
def get_load_share_hash_algo(self):
"""Get load share hash algorithm"""
request = [{"path": "data/openconfig-loadshare-mode-ext:loadshare/hash-algorithm/config", "method": GET}]
try:
response = edit_config(self._module, to_request(self._module, request))
except ConnectionError as exc:
self._module.fail_json(msg=str(exc), code=exc.code)
response = edit_config_catch(self._module, to_request(self._module, request))
if ('openconfig-loadshare-mode-ext:config' in response[0][1]):
data = response[0][1]['openconfig-loadshare-mode-ext:config']
else:
Expand All @@ -103,10 +101,7 @@ def get_load_share_hash_algo(self):
def get_auditd_rules(self):
"""Get auditd rules configuration available in chassis"""
request = [{"path": "data/openconfig-system:system/openconfig-system-ext:auditd-system", "method": GET}]
try:
response = edit_config(self._module, to_request(self._module, request))
except ConnectionError as exc:
self._module.fail_json(msg=str(exc), code=exc.code)
response = edit_config_catch(self._module, to_request(self._module, request))
data = {}
if response and response[0]:
if len(response[0]) > 1:
Expand Down
16 changes: 16 additions & 0 deletions plugins/module_utils/network/sonic/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ def edit_config(module, commands, skip_code=None):
# End
return connection.edit_config(commands)

def edit_config_catch(module, commands, skip_code=None):
connection = get_connection(module)

# Start: This is to convert interface name from Eth1/1 to Eth1%2f1
for request in commands:
# This check is to differenciate between requests and commands
if isinstance(request, dict):
url = request.get("path", None)
if url:
request["path"] = update_url(url)
# End
try:
response = connection.edit_config(commands)
except ConnectionError:
response = [[{}, {}]]
return response

def edit_config_reboot(module, commands, skip_code=None):
connection = get_connection(module)
Expand Down
15 changes: 10 additions & 5 deletions tests/regression/roles/sonic_system/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ tests:
ipv4: false
ipv6: false
auto_breakout: ENABLE
load_share_hash_algo: JENKINS_HASH_HI
# Use only on switch models that support this.
#load_share_hash_algo: JENKINS_HASH_HI
audit_rules: BASIC

- name: test_case_02
Expand All @@ -21,7 +22,8 @@ tests:
input:
hostname: SONIC-new
interface_naming: standard_extended
load_share_hash_algo: JENKINS_HASH_LO
# Use only on switch models that support this.
#load_share_hash_algo: JENKINS_HASH_LO
audit_rules: DETAIL

- name: test_case_03
Expand All @@ -40,7 +42,8 @@ tests:
anycast_address:
ipv4: false
auto_breakout: ENABLE
load_share_hash_algo: JENKINS_HASH_LO
# Use only on switch models that support this.
#load_share_hash_algo: JENKINS_HASH_LO
audit_rules: BASIC

- name: test_case_05
Expand All @@ -60,7 +63,8 @@ tests:
ipv4: true
mac_address: 00:09:5B:EC:EE:F2
auto_breakout: ENABLE
load_share_hash_algo: CRC_XOR
# Use only on switch models that support this.
#load_share_hash_algo: CRC_XOR
audit_rules: BASIC

- name: test_case_07
Expand All @@ -83,7 +87,8 @@ tests:
anycast_address:
ipv4: true
auto_breakout: ENABLE
load_share_hash_algo: CRC_32HI
# Use only on switch models that support this.
#load_share_hash_algo: CRC_32HI
audit_rules: BASIC

- name: test_case_09
Expand Down

0 comments on commit 5d8826b

Please sign in to comment.