Generalize nxos_bgp event-history detection (#28890)

* More general handling of event-history

* Update unit tests
pull/29065/merge
Nathaniel Case 7 years ago committed by GitHub
parent b98220f63d
commit f84ff216b6

@ -412,7 +412,6 @@ def get_value(arg, config):
command = PARAM_TO_COMMAND_KEYMAP.get(arg)
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<value>.*)$'.format(command), config, re.M)
if command == 'event-history detail':
@ -420,11 +419,8 @@ def get_value(arg, config):
else:
value = 'size_small'
if command_re.search(config):
if has_size:
value = 'size_%s' % has_size.group('value')
else:
value = True
elif arg in ['enforce_first_as', 'fast_external_fallover']:
no_command_re = re.compile(r'no\s+{0}\s*'.format(command), re.M)
@ -687,7 +683,7 @@ def main():
if candidate:
candidate = candidate.items_text()
load_config(module, candidate)
warnings.extend(load_config(module, candidate))
result['changed'] = True
result['commands'] = candidate
else:

@ -1,11 +0,0 @@
feature bgp
router bgp 65535
router-id 192.168.1.1
event-history cli size medium
event-history detail
vrf test2
address-family ipv4 unicast
timers bgp 1 10
neighbor 3.3.3.5
address-family ipv4 unicast

@ -42,8 +42,8 @@ class TestNxosBgpModule(TestNxosModule):
self.mock_get_config.stop()
def load_fixtures(self, commands=None, device=''):
self.get_config.return_value = load_fixture('', 'nxos_bgp_config.cfg')
self.load_config.return_value = None
self.get_config.return_value = load_fixture('nxos_bgp', 'config.cfg')
self.load_config.return_value = []
def test_nxos_bgp(self):
set_module_args(dict(asn=65535, router_id='1.1.1.1'))

Loading…
Cancel
Save