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
pull/27918/head
Ricardo Carrillo Cruz 7 years ago committed by GitHub
parent 2d2377bccc
commit d1d0cd5406

@ -78,6 +78,7 @@ from ansible.module_utils.eos import eos_argument_spec, check_args
from ansible.module_utils.six import iteritems from ansible.module_utils.six import iteritems
import re import re
import time
def map_obj_to_commands(updates, module): 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(): def main():
""" main entry point for module execution """ main entry point for module execution
""" """
argument_spec = dict( argument_spec = dict(
name=dict(required=True), name=dict(required=True),
interfaces=dict(type='list'), interfaces=dict(type='list'),
delay=dict(default=10, type='int'),
rd=dict(), rd=dict(),
aggregate=dict(), aggregate=dict(),
purge=dict(default=False, type='bool'), purge=dict(default=False, type='bool'),
@ -186,6 +199,9 @@ def main():
result['session_name'] = response.get('session') result['session_name'] = response.get('session')
result['changed'] = True result['changed'] = True
if result['changed']:
check_declarative_intent_params(module)
module.exit_json(**result) module.exit_json(**result)
if __name__ == '__main__': if __name__ == '__main__':

Loading…
Cancel
Save