Ios logging (#33151)

* ios_logging: Handle IOS versions that dont put the word host in logging config

This change allows the ansible module to parse and match either variant
being present in running-config.

* ios_logging: enhance logging buffered to handle both size and level

This change allows ios_logging to ensure local (buffered) logging
is configured with both the correct buffer size and logging level,
when both are specified on the task.
pull/34660/head
Steve Glendinning 7 years ago committed by Nathaniel Case
parent 39af276639
commit e802b769e6

@ -169,6 +169,9 @@ def map_obj_to_commands(updates, module):
commands.append('logging on')
elif dest == 'buffered' and size:
if level and level != 'debugging':
commands.append('logging buffered {0} {1}'.format(size, level))
else:
commands.append('logging buffered {0}'.format(size))
else:
@ -228,8 +231,12 @@ def parse_level(line, dest):
if dest == 'host':
level = 'debugging'
else:
if dest == 'buffered':
match = re.search(r'logging buffered (?:\d+ )([a-z]+)', line, re.M)
else:
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
if match:
if match.group(1) in level_group:
level = match.group(1)
@ -260,6 +267,16 @@ def map_config_to_obj(module):
'facility': parse_facility(line, dest),
'level': parse_level(line, dest)
})
else:
ip_match = re.search(r'\d+\.\d+\.\d+\.\d+', match.group(1), re.M)
if ip_match:
dest = 'host'
obj.append({
'dest': dest,
'name': match.group(1),
'facility': parse_facility(line, dest),
'level': parse_level(line, dest)
})
return obj

Loading…
Cancel
Save