Add delay and check configuration when interfaces is set on eos_vrf (#27884)

* Add delay and check configuration is right when interfaces is set on eos_vrf

Per the spec we put up for declarative intent modules, we need to check declarative
intent params (in the case of eos_vrf it's 'interfaces') after a delay and non-declarative
params have been set.
If that doesn't meet desired state after delay, we fail the task.

* Check declarative intent param only if config changed

* Fix pep8 issue

* Change default of delay param to 10

* Revert bogus change on eos_vlan
This commit is contained in:
Ricardo Carrillo Cruz 2017-08-08 20:23:45 +02:00 committed by GitHub
parent 2d2377bccc
commit d1d0cd5406

View file

@ -78,6 +78,7 @@ from ansible.module_utils.eos import eos_argument_spec, check_args
from ansible.module_utils.six import iteritems
import re
import time
def map_obj_to_commands(updates, module):
@ -147,12 +148,24 @@ def map_params_to_obj(module):
}
def check_declarative_intent_params(module):
if module.params['interfaces']:
time.sleep(module.params['delay'])
have = map_config_to_obj(module)
vrf = module.params['name']
for i in module.params['interfaces']:
if i not in have['interfaces']:
module.fail_json(msg="Interface %s not configured on vrf %s" % (i, vrf))
def main():
""" main entry point for module execution
"""
argument_spec = dict(
name=dict(required=True),
interfaces=dict(type='list'),
delay=dict(default=10, type='int'),
rd=dict(),
aggregate=dict(),
purge=dict(default=False, type='bool'),
@ -186,6 +199,9 @@ def main():
result['session_name'] = response.get('session')
result['changed'] = True
if result['changed']:
check_declarative_intent_params(module)
module.exit_json(**result)
if __name__ == '__main__':