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

nxos_bgp_af correct parents (#26996)

* move config location

* client-to-client is inverse of BOOL_PARAMS
This commit is contained in:
Nathaniel Case 2017-07-20 13:42:26 -04:00 committed by GitHub
parent 1d8854b045
commit 85e7e342b0
3 changed files with 35 additions and 11 deletions

View file

@ -279,7 +279,6 @@ BOOL_PARAMS = [
'additional_paths_receive', 'additional_paths_receive',
'additional_paths_send', 'additional_paths_send',
'advertise_l2vpn_evpn', 'advertise_l2vpn_evpn',
'client_to_client',
'dampening_state', 'dampening_state',
'default_information_originate', 'default_information_originate',
'suppress_inactive', 'suppress_inactive',
@ -420,8 +419,15 @@ def get_value(arg, config, module):
if has_tablemap: if has_tablemap:
value = has_tablemap.group('value') value = has_tablemap.group('value')
elif arg == 'client_to_client':
no_command_re = re.compile(r'^\s+no\s{0}\s*$'.format(command), re.M)
value = True
if no_command_re.search(config):
value = False
elif arg in BOOL_PARAMS: elif arg in BOOL_PARAMS:
command_re = re.compile(r'\s+{0}\s*'.format(command), re.M) command_re = re.compile(r'^\s+{0}\s*$'.format(command), re.M)
value = False value = False
if command_re.search(config): if command_re.search(config):
@ -674,11 +680,9 @@ def state_present(module, existing, proposed, candidate):
if module.params['vrf'] != 'default': if module.params['vrf'] != 'default':
parents.append('vrf {0}'.format(module.params['vrf'])) parents.append('vrf {0}'.format(module.params['vrf']))
if len(commands) == 1: addr_family_command = "address-family {0} {1}".format(module.params['afi'],
candidate.add(commands, parents=parents) module.params['safi'])
elif len(commands) > 1: parents.append(addr_family_command)
parents.append('address-family {0} {1}'.format(module.params['afi'],
module.params['safi']))
if addr_family_command in commands: if addr_family_command in commands:
commands.remove(addr_family_command) commands.remove(addr_family_command)
candidate.add(commands, parents=parents) candidate.add(commands, parents=parents)

View file

@ -0,0 +1,11 @@
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,7 +42,7 @@ class TestNxosBgpAfModule(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 = None
def test_nxos_bgp_af(self): def test_nxos_bgp_af(self):
@ -89,3 +89,12 @@ class TestNxosBgpAfModule(TestNxosModule):
dampening_reuse_time=1900, dampening_max_suppress_time=10)) dampening_reuse_time=1900, dampening_max_suppress_time=10))
result = self.execute_module(failed=True) result = self.execute_module(failed=True)
self.assertEqual(result['msg'], 'dampening_routemap cannot be used with the dampening_half_time param') self.assertEqual(result['msg'], 'dampening_routemap cannot be used with the dampening_half_time param')
def test_nxos_bgp_af_client(self):
set_module_args(dict(asn=65535, afi='ipv4', safi='unicast',
client_to_client=False))
self.execute_module(
changed=True,
commands=['router bgp 65535', 'address-family ipv4 unicast',
'no client-to-client reflection']
)