1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Generalize nxos_bgp event-history detection (#28890)

* More general handling of event-history

* Update unit tests
This commit is contained in:
Nathaniel Case 2017-09-06 17:37:44 -04:00 committed by GitHub
parent b98220f63d
commit f84ff216b6
3 changed files with 5 additions and 20 deletions

View file

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

View file

@ -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

View file

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