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:
Nilashish Chakraborty 2018-07-26 23:15:25 +05:30 committed by GitHub
commit 18235af363
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 101 additions and 6 deletions

View file

@ -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

View file

@ -47,7 +47,8 @@ class TerminalModule(TerminalBase):
re.compile(br"syntax error"),
re.compile(br"unknown command"),
re.compile(br"user not present"),
re.compile(br"invalid (.+?)at '\^' marker", re.I)
re.compile(br"invalid (.+?)at '\^' marker", re.I),
re.compile(br"baud rate of console should be (\d*) to increase severity level", re.I)
]
def on_become(self, passwd=None):