Fix vyos banner idempotent (#26338)

* fix vyos_banner idempotent

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* fix vyos_banner unit test

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-07-03 13:08:08 +05:30 committed by GitHub
commit 1b427aa419
2 changed files with 9 additions and 8 deletions

View file

@ -94,16 +94,17 @@ def spec_to_commands(updates, module):
want, have = updates
state = module.params['state']
if state == 'absent' or (state == 'absent' and
'text' in have.keys() and have['text']):
commands.append('delete system login banner %s' % module.params['banner'])
if state == 'absent':
if have.get('state') != 'absent' or (have.get('state') != 'absent' and
'text' in have.keys() and have['text']):
commands.append('delete system login banner %s' % module.params['banner'])
elif state == 'present':
if want['text'] and (want['text'] != have.get('text')):
banner_cmd = 'set system login banner %s ' % module.params['banner']
banner_cmd += '"'
banner_cmd += "'"
banner_cmd += want['text'].strip()
banner_cmd += '"'
banner_cmd += "'"
commands.append(banner_cmd)
return commands
@ -120,7 +121,7 @@ def config_to_dict(module):
output = match
if output:
obj['text'] = output
obj['text'] = output[0][1:-1]
obj['state'] = 'present'
return obj