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:
parent
1d8854b045
commit
85e7e342b0
3 changed files with 35 additions and 11 deletions
|
@ -279,7 +279,6 @@ BOOL_PARAMS = [
|
|||
'additional_paths_receive',
|
||||
'additional_paths_send',
|
||||
'advertise_l2vpn_evpn',
|
||||
'client_to_client',
|
||||
'dampening_state',
|
||||
'default_information_originate',
|
||||
'suppress_inactive',
|
||||
|
@ -420,8 +419,15 @@ def get_value(arg, config, module):
|
|||
if has_tablemap:
|
||||
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:
|
||||
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
|
||||
|
||||
if command_re.search(config):
|
||||
|
@ -674,14 +680,12 @@ def state_present(module, existing, proposed, candidate):
|
|||
if module.params['vrf'] != 'default':
|
||||
parents.append('vrf {0}'.format(module.params['vrf']))
|
||||
|
||||
if len(commands) == 1:
|
||||
candidate.add(commands, parents=parents)
|
||||
elif len(commands) > 1:
|
||||
parents.append('address-family {0} {1}'.format(module.params['afi'],
|
||||
module.params['safi']))
|
||||
if addr_family_command in commands:
|
||||
commands.remove(addr_family_command)
|
||||
candidate.add(commands, parents=parents)
|
||||
addr_family_command = "address-family {0} {1}".format(module.params['afi'],
|
||||
module.params['safi'])
|
||||
parents.append(addr_family_command)
|
||||
if addr_family_command in commands:
|
||||
commands.remove(addr_family_command)
|
||||
candidate.add(commands, parents=parents)
|
||||
|
||||
|
||||
def state_absent(module, candidate):
|
||||
|
|
11
test/units/modules/network/nxos/fixtures/nxos_bgp/config.cfg
Normal file
11
test/units/modules/network/nxos/fixtures/nxos_bgp/config.cfg
Normal 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
|
|
@ -42,7 +42,7 @@ class TestNxosBgpAfModule(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.get_config.return_value = load_fixture('nxos_bgp', 'config.cfg')
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_nxos_bgp_af(self):
|
||||
|
@ -89,3 +89,12 @@ class TestNxosBgpAfModule(TestNxosModule):
|
|||
dampening_reuse_time=1900, dampening_max_suppress_time=10))
|
||||
result = self.execute_module(failed=True)
|
||||
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']
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue