mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes to ios_logging (#41029)
* Logging size may not show up in config * This is much simpler * Avoid repetition in tests * Both options of buffered are optional
This commit is contained in:
parent
13c7d149bb
commit
92a95368fe
2 changed files with 16 additions and 43 deletions
|
@ -225,18 +225,12 @@ def parse_size(line, dest):
|
||||||
size = None
|
size = None
|
||||||
|
|
||||||
if dest == 'buffered':
|
if dest == 'buffered':
|
||||||
match = re.search(r'logging buffered (\S+)', line, re.M)
|
match = re.search(r'logging buffered(?: (\d+))?(?: [a-z]+)?', line, re.M)
|
||||||
if match:
|
if match:
|
||||||
try:
|
if match.group(1) is not None:
|
||||||
int_size = int(match.group(1))
|
size = match.group(1)
|
||||||
except ValueError:
|
|
||||||
int_size = None
|
|
||||||
|
|
||||||
if int_size:
|
|
||||||
if isinstance(int_size, int):
|
|
||||||
size = str(match.group(1))
|
|
||||||
else:
|
else:
|
||||||
size = str(4096)
|
size = "4096"
|
||||||
|
|
||||||
return size
|
return size
|
||||||
|
|
||||||
|
@ -261,17 +255,14 @@ def parse_level(line, dest):
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if dest == 'buffered':
|
if dest == 'buffered':
|
||||||
match = re.search(r'logging buffered (?:\d+ )([a-z]+)', line, re.M)
|
match = re.search(r'logging buffered(?: \d+)?(?: ([a-z]+))?', line, re.M)
|
||||||
else:
|
else:
|
||||||
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
|
match = re.search(r'logging {0} (\S+)'.format(dest), line, re.M)
|
||||||
|
|
||||||
if match:
|
if match and match.group(1) in level_group:
|
||||||
if match.group(1) in level_group:
|
|
||||||
level = match.group(1)
|
level = match.group(1)
|
||||||
else:
|
else:
|
||||||
level = 'debugging'
|
level = 'debugging'
|
||||||
else:
|
|
||||||
level = 'debugging'
|
|
||||||
|
|
||||||
return level
|
return level
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
# ensure logging configs are empty
|
# ensure logging configs are empty
|
||||||
- name: Remove host logging
|
- name: Remove host logging
|
||||||
ios_logging:
|
ios_logging: &remove_host
|
||||||
dest: host
|
dest: host
|
||||||
name: 172.16.0.1
|
name: 172.16.0.1
|
||||||
state: absent
|
state: absent
|
||||||
|
@ -45,16 +45,12 @@
|
||||||
provider: "{{ cli }}"
|
provider: "{{ cli }}"
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: &unchanged
|
||||||
that:
|
that:
|
||||||
- 'result.changed == false'
|
- 'result.changed == false'
|
||||||
|
|
||||||
- name: Delete/disable host logging
|
- name: Delete/disable host logging
|
||||||
ios_logging:
|
ios_logging: *remove_host
|
||||||
dest: host
|
|
||||||
name: 172.16.0.1
|
|
||||||
state: absent
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -63,16 +59,10 @@
|
||||||
- '"no logging host 172.16.0.1" in result.commands'
|
- '"no logging host 172.16.0.1" in result.commands'
|
||||||
|
|
||||||
- name: Delete/disable host logging (idempotent)
|
- name: Delete/disable host logging (idempotent)
|
||||||
ios_logging:
|
ios_logging: *remove_host
|
||||||
dest: host
|
|
||||||
name: 172.16.0.1
|
|
||||||
state: absent
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *unchanged
|
||||||
that:
|
|
||||||
- 'result.changed == false'
|
|
||||||
|
|
||||||
- name: Console logging with level warnings
|
- name: Console logging with level warnings
|
||||||
ios_logging:
|
ios_logging:
|
||||||
|
@ -115,7 +105,7 @@
|
||||||
- '"logging console notifications" in result.commands'
|
- '"logging console notifications" in result.commands'
|
||||||
|
|
||||||
- name: Set both logging destination and facility
|
- name: Set both logging destination and facility
|
||||||
ios_logging:
|
ios_logging: &set_both
|
||||||
dest: buffered
|
dest: buffered
|
||||||
facility: uucp
|
facility: uucp
|
||||||
level: alerts
|
level: alerts
|
||||||
|
@ -131,18 +121,10 @@
|
||||||
- '"logging facility uucp" in result.commands'
|
- '"logging facility uucp" in result.commands'
|
||||||
|
|
||||||
- name: Set both logging destination and facility (idempotent)
|
- name: Set both logging destination and facility (idempotent)
|
||||||
ios_logging:
|
ios_logging: *set_both
|
||||||
dest: buffered
|
|
||||||
facility: uucp
|
|
||||||
level: alerts
|
|
||||||
size: 4096
|
|
||||||
state: present
|
|
||||||
provider: "{{ cli }}"
|
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert: *unchanged
|
||||||
that:
|
|
||||||
- 'result.changed == false'
|
|
||||||
|
|
||||||
- name: remove logging as collection tearDown
|
- name: remove logging as collection tearDown
|
||||||
ios_logging:
|
ios_logging:
|
||||||
|
|
Loading…
Reference in a new issue