From ed8a5af3dc627aacd4bdae53bda509a9e47d5492 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Thu, 10 Aug 2017 08:55:43 -0400 Subject: [PATCH] nxos_bgp: Fix idempotence for event-history (#27329) * Fix idempotence for event-history * `event-history detail` defaults to `False`, the rest to `size_small` --- lib/ansible/modules/network/nxos/nxos_bgp.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_bgp.py b/lib/ansible/modules/network/nxos/nxos_bgp.py index 3ea66095e6..71ef7632d4 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp.py @@ -360,9 +360,9 @@ PARAM_TO_DEFAULT_KEYMAP = { 'suppress_fib_pending': True, 'fast_external_fallover': True, 'enforce_first_as': True, - 'event_history_periodic': True, 'event_history_cli': True, - 'event_history_events': True + 'event_history_events': True, + 'event_history_periodic': True, } PARAM_TO_COMMAND_KEYMAP = { 'asn': 'router bgp', @@ -412,14 +412,16 @@ def get_value(arg, config): if command.split()[0] == 'event-history': command_re = re.compile(r'\s+{0}\s*'.format(command), re.M) + has_size = re.search(r'^\s+{0} size\s(?P.*)$'.format(command), config, re.M) - size_re = re.compile(r'(?:{0} size\s)(?P.*)'.format(command), re.M) - value = False + if command == 'event-history detail': + value = False + else: + value = 'size_small' if command_re.search(config): - search = size_re.search(config) - if search: - value = search.group('value') + if has_size: + value = 'size_%s' % has_size.group('value') else: value = True @@ -431,10 +433,10 @@ def get_value(arg, config): value = False elif arg in BOOL_PARAMS: - command_re = re.compile(r'\s+{0}\s*'.format(command), re.M) + has_command = re.search(r'^\s+{0}\s*$'.format(command), config, re.M) value = False - if command_re.search(config): + if has_command: value = True else: command_val_re = re.compile(r'(?:{0}\s)(?P.*)'.format(command), re.M)