nxos: 32 bits AS in as-dot format not recognized by regexp asn_regex (#30569)
* added test for 32 bits AS * Lint not happy.
This commit is contained in:
parent
a9afb1e19e
commit
84117e57ba
6 changed files with 46 additions and 4 deletions
|
@ -461,7 +461,7 @@ def get_existing(module, args, warnings):
|
|||
existing = {}
|
||||
netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=['bgp all']))
|
||||
|
||||
asn_re = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+).*', re.S)
|
||||
asn_re = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+(\.\d+)?).*', re.S)
|
||||
asn_match = asn_re.match(str(netcfg))
|
||||
|
||||
if asn_match:
|
||||
|
|
|
@ -449,7 +449,7 @@ def get_existing(module, args, warnings):
|
|||
existing = {}
|
||||
netcfg = CustomNetworkConfig(indent=2, contents=get_config(module))
|
||||
|
||||
asn_regex = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+).*', re.DOTALL)
|
||||
asn_regex = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+(\.\d+)?).*', re.DOTALL)
|
||||
match_asn = asn_regex.match(str(netcfg))
|
||||
|
||||
if match_asn:
|
||||
|
|
|
@ -308,7 +308,7 @@ def get_existing(module, args, warnings):
|
|||
existing = {}
|
||||
netcfg = CustomNetworkConfig(indent=2, contents=get_config(module))
|
||||
|
||||
asn_regex = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+).*', re.S)
|
||||
asn_regex = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+(\.\d+)?).*', re.S)
|
||||
match_asn = asn_regex.match(str(netcfg))
|
||||
|
||||
if match_asn:
|
||||
|
|
|
@ -446,7 +446,7 @@ def get_existing(module, args, warnings):
|
|||
existing = {}
|
||||
netcfg = CustomNetworkConfig(indent=2, contents=get_config(module))
|
||||
|
||||
asn_regex = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+).*', re.S)
|
||||
asn_regex = re.compile(r'.*router\sbgp\s(?P<existing_asn>\d+(\.\d+)?).*', re.S)
|
||||
match_asn = asn_regex.match(str(netcfg))
|
||||
|
||||
if match_asn:
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
feature bgp
|
||||
|
||||
router bgp 65535.65535
|
||||
router-id 192.168.1.1
|
||||
vrf test
|
||||
address-family ipv4 unicast
|
|
@ -96,3 +96,39 @@ class TestNxosBgpModule(TestNxosModule):
|
|||
changed=True,
|
||||
commands=['router bgp 65535', 'graceful-restart restart-time 120']
|
||||
)
|
||||
|
||||
|
||||
class TestNxosBgp32BitsAS(TestNxosModule):
|
||||
|
||||
module = nxos_bgp
|
||||
|
||||
def setUp(self):
|
||||
super(TestNxosBgp32BitsAS, self).setUp()
|
||||
|
||||
self.mock_load_config = patch('ansible.modules.network.nxos.nxos_bgp.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
self.mock_get_config = patch('ansible.modules.network.nxos.nxos_bgp.get_config')
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestNxosBgp32BitsAS, self).tearDown()
|
||||
self.mock_load_config.stop()
|
||||
self.mock_get_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, device=''):
|
||||
self.get_config.return_value = load_fixture('nxos_bgp', 'config_32_bits_as.cfg')
|
||||
self.load_config.return_value = []
|
||||
|
||||
def test_nxos_bgp_change_nothing(self):
|
||||
set_module_args(dict(asn='65535.65535', router_id='192.168.1.1'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_nxos_bgp_wrong_asn(self):
|
||||
set_module_args(dict(asn='65535.10', router_id='192.168.1.1'))
|
||||
result = self.execute_module(failed=True)
|
||||
self.assertEqual(result['msg'], 'Another BGP ASN already exists.')
|
||||
|
||||
def test_nxos_bgp_remove(self):
|
||||
set_module_args(dict(asn='65535.65535', state='absent'))
|
||||
self.execute_module(changed=True, commands=['no router bgp 65535.65535'])
|
||||
|
|
Loading…
Reference in a new issue