|
|
|
@ -27,7 +27,6 @@ from .ios_module import TestIosModule, load_fixture
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestIosVrfModule(TestIosModule):
|
|
|
|
|
|
|
|
|
|
module = ios_vrf
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
@ -74,9 +73,7 @@ class TestIosVrfModule(TestIosModule):
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_interfaces(self):
|
|
|
|
|
set_module_args(dict(name='test_1', interfaces=['Ethernet1']))
|
|
|
|
|
commands = ['interface Ethernet2', 'no vrf forwarding test_1',
|
|
|
|
|
'interface Ethernet1', 'vrf forwarding test_1',
|
|
|
|
|
'ip address 1.2.3.4/5']
|
|
|
|
|
commands = ['interface Ethernet2', 'no vrf forwarding test_1', 'interface Ethernet1', 'vrf forwarding test_1', 'ip address 1.2.3.4/5']
|
|
|
|
|
self.execute_module(changed=True, commands=commands, sort=False)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_state_absent(self):
|
|
|
|
@ -86,8 +83,7 @@ class TestIosVrfModule(TestIosModule):
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_purge_all(self):
|
|
|
|
|
set_module_args(dict(purge=True))
|
|
|
|
|
commands = ['no vrf definition test_1', 'no vrf definition test_2',
|
|
|
|
|
'no vrf definition test_3']
|
|
|
|
|
commands = ['no vrf definition test_1', 'no vrf definition test_2', 'no vrf definition test_3']
|
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_purge_all_but_one(self):
|
|
|
|
@ -98,39 +94,54 @@ class TestIosVrfModule(TestIosModule):
|
|
|
|
|
def test_ios_vrfs_no_purge(self):
|
|
|
|
|
vrfs = [{'name': 'test_1'}, {'name': 'test_4'}]
|
|
|
|
|
set_module_args(dict(vrfs=vrfs))
|
|
|
|
|
commands = ['vrf definition test_4',
|
|
|
|
|
'address-family ipv4', 'exit',
|
|
|
|
|
'address-family ipv6', 'exit']
|
|
|
|
|
commands = ['vrf definition test_4', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit']
|
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrfs_purge(self):
|
|
|
|
|
vrfs = [{'name': 'test_1'}, {'name': 'test_4'}]
|
|
|
|
|
set_module_args(dict(vrfs=vrfs, purge=True))
|
|
|
|
|
commands = ['vrf definition test_4',
|
|
|
|
|
'address-family ipv4', 'exit',
|
|
|
|
|
'address-family ipv6', 'exit',
|
|
|
|
|
'no vrf definition test_2',
|
|
|
|
|
commands = ['vrf definition test_4', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'no vrf definition test_2',
|
|
|
|
|
'no vrf definition test_3']
|
|
|
|
|
self.execute_module(changed=True, commands=commands)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrfs_global_arg(self):
|
|
|
|
|
vrfs = [{'name': 'test_1'}, {'name': 'test_2'}]
|
|
|
|
|
set_module_args(dict(vrfs=vrfs, description='test string'))
|
|
|
|
|
commands = ['vrf definition test_1', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'description test string',
|
|
|
|
|
'vrf definition test_2', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'description test string']
|
|
|
|
|
commands = ['vrf definition test_1', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'description test string', 'vrf definition test_2',
|
|
|
|
|
'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'description test string']
|
|
|
|
|
self.execute_module(changed=True, commands=commands, sort=False)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrfs_local_override_description(self):
|
|
|
|
|
vrfs = [{'name': 'test_1', 'description': 'test vrf 1'},
|
|
|
|
|
{'name': 'test_2'}]
|
|
|
|
|
vrfs = [{'name': 'test_1', 'description': 'test vrf 1'}, {'name': 'test_2'}]
|
|
|
|
|
set_module_args(dict(vrfs=vrfs, description='test string'))
|
|
|
|
|
commands = ['vrf definition test_2', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'description test string']
|
|
|
|
|
self.execute_module(changed=True, commands=commands, sort=False)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrfs_local_override_state(self):
|
|
|
|
|
vrfs = [{'name': 'test_1', 'state': 'absent'},
|
|
|
|
|
{'name': 'test_2'}]
|
|
|
|
|
vrfs = [{'name': 'test_1', 'state': 'absent'}, {'name': 'test_2'}]
|
|
|
|
|
set_module_args(dict(vrfs=vrfs, description='test string'))
|
|
|
|
|
commands = ['no vrf definition test_1', 'vrf definition test_2', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit',
|
|
|
|
|
'description test string']
|
|
|
|
|
self.execute_module(changed=True, commands=commands, sort=False)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_route_both(self):
|
|
|
|
|
set_module_args(dict(name='test_5', rd='2:100', route_both=['2:100', '3:100']))
|
|
|
|
|
commands = ['vrf definition test_5', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'rd 2:100', 'route-target both 2:100',
|
|
|
|
|
'route-target both 3:100']
|
|
|
|
|
self.execute_module(changed=True, commands=commands, sort=False)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_route_import(self):
|
|
|
|
|
set_module_args(dict(name='test_6', rd='3:100', route_import=['3:100', '4:100']))
|
|
|
|
|
commands = ['vrf definition test_6', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'rd 3:100', 'route-target import 3:100',
|
|
|
|
|
'route-target import 4:100']
|
|
|
|
|
self.execute_module(changed=True, commands=commands, sort=False)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_route_export(self):
|
|
|
|
|
set_module_args(dict(name='test_7', rd='4:100', route_export=['3:100', '4:100']))
|
|
|
|
|
commands = ['vrf definition test_7', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'rd 4:100', 'route-target export 3:100',
|
|
|
|
|
'route-target export 4:100']
|
|
|
|
|
self.execute_module(changed=True, commands=commands, sort=False)
|
|
|
|
|
|
|
|
|
|
def test_ios_vrf_route_both_exclusive(self):
|
|
|
|
|
set_module_args(dict(name='test_8', rd='5:100', route_both=['3:100', '4:100'], route_export=['3:100', '4:100']))
|
|
|
|
|
self.execute_module(failed=True)
|
|
|
|
|