Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
This commit is contained in:
parent
5493ea590c
commit
2f996fc6e2
4 changed files with 35 additions and 2 deletions
|
@ -208,7 +208,13 @@ def get_candidate(module):
|
||||||
|
|
||||||
|
|
||||||
def format_commands(commands):
|
def format_commands(commands):
|
||||||
return [line for line in commands if len(line.strip()) > 0]
|
"""
|
||||||
|
This function format the input commands and removes the prepend white spaces
|
||||||
|
for command lines having 'set' or 'delete' and it skips empty lines.
|
||||||
|
:param commands:
|
||||||
|
:return: list of commands
|
||||||
|
"""
|
||||||
|
return [line.strip() if line.split()[0] in ('set', 'delete') else line for line in commands if len(line.strip()) > 0]
|
||||||
|
|
||||||
|
|
||||||
def diff_config(commands, config):
|
def diff_config(commands, config):
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
set service lldp
|
||||||
|
set protocols static
|
||||||
|
|
|
@ -25,6 +25,30 @@
|
||||||
that:
|
that:
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
|
|
||||||
|
- name: Configuring when commands starts with whitespaces
|
||||||
|
vyos_config:
|
||||||
|
src: "{{ role_path }}/tests/cli/config.cfg"
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
- '"set service lldp" in result.commands'
|
||||||
|
- '"set protocols static" in result.commands'
|
||||||
|
|
||||||
|
- name: Delete description
|
||||||
|
vyos_config:
|
||||||
|
lines:
|
||||||
|
- delete service lldp
|
||||||
|
- delete protocols static
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.changed == true"
|
||||||
|
- '"delete service lldp" in result.commands'
|
||||||
|
- '"delete protocols static" in result.commands'
|
||||||
|
|
||||||
- name: teardown
|
- name: teardown
|
||||||
vyos_config:
|
vyos_config:
|
||||||
lines: set system host-name {{ inventory_hostname_short }}
|
lines: set system host-name {{ inventory_hostname_short }}
|
||||||
|
|
Loading…
Reference in a new issue