mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Fix baud rate and nxos_logging default case idempotency bug (#43295)
* Fix baud rate and idempotency bug * Fix Shippable errors * Combine commands calls * Fix Shippable errors II
This commit is contained in:
parent
1ab411229a
commit
18235af363
3 changed files with 101 additions and 6 deletions
|
@ -114,8 +114,7 @@ commands:
|
|||
|
||||
import re
|
||||
|
||||
|
||||
from ansible.module_utils.network.nxos.nxos import get_config, load_config
|
||||
from ansible.module_utils.network.nxos.nxos import get_config, load_config, run_commands
|
||||
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
@ -123,7 +122,7 @@ from ansible.module_utils.basic import AnsibleModule
|
|||
DEST_GROUP = ['console', 'logfile', 'module', 'monitor', 'server']
|
||||
|
||||
|
||||
def map_obj_to_commands(updates, module):
|
||||
def map_obj_to_commands(updates):
|
||||
commands = list()
|
||||
want, have = updates
|
||||
|
||||
|
@ -286,6 +285,29 @@ def map_config_to_obj(module):
|
|||
'dest_level': parse_dest_level(line, dest, parse_name(line, dest)),
|
||||
'facility_level': parse_facility_level(line, facility)})
|
||||
|
||||
cmd = [{'command': 'show logging | section enabled | section console', 'output': 'text'},
|
||||
{'command': 'show logging | section enabled | section monitor', 'output': 'text'}]
|
||||
|
||||
default_data = run_commands(module, cmd)
|
||||
|
||||
for line in default_data:
|
||||
flag = False
|
||||
match = re.search(r'Logging (\w+):(?:\s+) (?:\w+) (?:\W)Severity: (\w+)', str(line), re.M)
|
||||
if match:
|
||||
if match.group(1) == 'console' and match.group(2) == 'critical':
|
||||
dest_level = '2'
|
||||
flag = True
|
||||
elif match.group(1) == 'monitor' and match.group(2) == 'notifications':
|
||||
dest_level = '5'
|
||||
flag = True
|
||||
if flag:
|
||||
obj.append({'dest': match.group(1),
|
||||
'remote_server': None,
|
||||
'name': None,
|
||||
'facility': None,
|
||||
'dest_level': dest_level,
|
||||
'facility_level': None})
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue