Beispiel #1
0
 def test_ios_ospf_interfaces_merged(self):
     set_module_args(
         dict(
             config=[
                 dict(
                     name="GigabitEthernet0/2",
                     address_family=[
                         dict(
                             afi="ipv4",
                             bfd=True,
                             cost=dict(interface_cost=30),
                             network=dict(broadcast=True),
                             priority=60,
                             resync_timeout=90,
                             ttl_security=dict(hops=120),
                         ),
                         dict(
                             afi="ipv6",
                             bfd=True,
                             dead_interval=dict(time=100),
                             network=dict(manet=True),
                             priority=50,
                         ),
                     ],
                 ),
                 dict(
                     name="GigabitEthernet0/3",
                     address_family=[
                         dict(
                             afi="ipv4",
                             bfd=True,
                             cost=dict(interface_cost=50),
                             priority=50,
                             ttl_security=dict(hops=150),
                         )
                     ],
                 ),
             ],
             state="merged",
         )
     )
     commands = [
         "interface GigabitEthernet0/3",
         "ip ospf bfd",
         "ip ospf cost 50",
         "ip ospf priority 50",
         "ip ospf ttl-security hops 150",
         "interface GigabitEthernet0/2",
         "ip ospf bfd",
         "ip ospf cost 30",
         "ip ospf network broadcast",
         "ip ospf priority 60",
         "ip ospf resync-timeout 90",
         "ip ospf ttl-security hops 120",
         "ipv6 ospf bfd",
         "ipv6 ospf dead-interval 100",
         "ipv6 ospf network manet",
         "ipv6 ospf priority 50",
     ]
     result = self.execute_module(changed=True)
     self.assertEqual(sorted(result["commands"]), sorted(commands))
Beispiel #2
0
 def test_ios_vrf_route_both_ipv4_mixed_idempotent(self):
     set_module_args(dict(name='test_18', rd='168.0.0.9:100', route_import_ipv4=['168.0.0.10:600'], route_export_ipv4=['168.0.0.10:100'],
                          route_both_ipv4=['168.0.0.9:100', '3:100']))
     self.execute_module(changed=False, commands=[], sort=False)
Beispiel #3
0
 def test_ios_vrf_name(self):
     set_module_args(dict(name='test_4'))
     commands = ['vrf definition test_4', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit']
     self.execute_module(changed=True, commands=commands, sort=False)
Beispiel #4
0
 def test_ios_vrf_route_both_ipv4(self):
     set_module_args(dict(name='test_9', rd='168.0.0.9:100', route_both_ipv4=['168.0.0.9:100', '3:100']))
     commands = ['vrf definition test_9', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'rd 168.0.0.9:100', 'address-family ipv4',
                 'route-target import 168.0.0.9:100', 'route-target import 3:100', 'exit-address-family', 'address-family ipv4',
                 'route-target export 168.0.0.9:100', 'route-target export 3:100', 'exit-address-family']
     self.execute_module(changed=True, commands=commands, sort=False)
Beispiel #5
0
 def test_ios_vrf_route_both_ipv6_mixed(self):
     set_module_args(dict(name='test_16', rd='5:100', route_both_ipv6=['168.0.0.9:100', '4:100'], route_export_ipv6=['168.0.0.12:100', '6:100']))
     self.execute_module(changed=True)
Beispiel #6
0
 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']
     self.execute_module(changed=True, commands=commands, sort=False)
Beispiel #7
0
 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)
Beispiel #8
0
 def test_ios_ping_unexpected_failure(self):
     """ Test for unsuccessful pings when destination should be reachable - FAIL. """
     set_module_args(dict(count=2, dest="10.255.255.250"))
     self.execute_module(failed=True)
Beispiel #9
0
 def test_ios_ping_with_size(self):
     """ Test for successful pings using size option. """
     set_module_args(dict(size=1400, dest="8.8.8.8"))
     commands = ["ping 8.8.8.8 size 1400"]
     self.execute_module(commands=commands)
Beispiel #10
0
 def test_ios_ping_expected_failure(self):
     """ Test for unsuccessful pings when destination should not be reachable """
     set_module_args(dict(count=2, dest="10.255.255.250", state="absent"))
     self.execute_module()
Beispiel #11
0
 def test_ios_ping_unexpected_success(self):
     """ Test for successful pings when destination should not be reachable - FAIL. """
     set_module_args(dict(count=2, dest="8.8.8.8", state="absent"))
     self.execute_module(failed=True)
Beispiel #12
0
 def test_ios_ping_expected_success(self):
     """ Test for successful pings when destination should be reachable """
     set_module_args(dict(count=2, dest="8.8.8.8"))
     self.execute_module()
Beispiel #13
0
 def test_ios_banner_nochange(self):
     banner_text = load_fixture('ios_banner_show_banner.txt')
     set_module_args(dict(banner='exec', text=banner_text))
     self.execute_module()
Beispiel #14
0
 def test_ios_banner_remove(self):
     set_module_args(dict(banner='login', state='absent'))
     commands = ['no banner login']
     self.execute_module(changed=True, commands=commands)
 def test_ios_bgp_address_family_overridden_multiple_neighbor(self):
     set_module_args(
         dict(
             config=dict(
                 as_number="65000",
                 address_family=[
                     dict(
                         afi="ipv4",
                         neighbor=[
                             dict(
                                 address="192.31.39.212",
                                 soft_reconfiguration=True,
                                 activate=True,
                             ),
                             dict(
                                 address="192.31.47.206",
                                 soft_reconfiguration=True,
                                 activate=True,
                             ),
                         ],
                         network=[
                             dict(
                                 address="192.0.3.1",
                                 mask="255.255.255.0",
                             ),
                             dict(
                                 address="192.0.2.1",
                                 mask="255.255.255.0",
                             ),
                             dict(
                                 address="192.0.4.1",
                                 mask="255.255.255.0",
                             ),
                         ],
                     ),
                 ],
             ),
             state="overridden",
         ), )
     commands = [
         "router bgp 65000",
         "no address-family ipv4 multicast",
         "no address-family ipv4 mdt",
         "no address-family ipv4 multicast vrf blue",
         "address-family ipv4",
         "no bgp redistribute-internal",
         "no redistribute connected",
         "no redistribute ospf 200 metric 100 match internal external 1 external 2",
         "no neighbor TEST-PEER-GROUP send-community",
         "no neighbor TEST-PEER-GROUP next-hop-self all",
         "no neighbor 2001:db8::1 activate",
         "neighbor 192.31.39.212 activate",
         "neighbor 192.31.39.212 soft-reconfiguration inbound",
         "neighbor 192.31.47.206 activate",
         "neighbor 192.31.47.206 soft-reconfiguration inbound",
         "network 192.0.3.1 mask 255.255.255.0",
         "network 192.0.2.1 mask 255.255.255.0",
         "network 192.0.4.1 mask 255.255.255.0",
     ]
     result = self.execute_module(changed=True)
     self.assertEqual(sorted(result["commands"]), sorted(commands))
Beispiel #16
0
 def test_ios_ping_with_size_df_bit(self):
     """ Test for successful pings using size and df-bit options. """
     set_module_args(dict(size=1400, df_bit=True, dest="8.8.8.8"))
     commands = ["ping 8.8.8.8 size 1400 df-bit"]
     self.execute_module(commands=commands)
Beispiel #17
0
 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',
                 'no vrf definition test_3', 'no vrf definition test_17', 'no vrf definition test_18', 'no vrf definition test_19']
     self.execute_module(changed=True, commands=commands)
 def test_ios_vlan_id_startwith_9(self):
     set_module_args({"vlan_id": "9", "name": "vlan9", "state": "present"})
     result = self.execute_module(changed=False)
     expected_commands = []
     self.assertEqual(result["commands"], expected_commands)
Beispiel #19
0
 def test_ios_vrfs_local_override_state(self):
     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_vlan_rename(self):
     set_module_args({"vlan_id": "2", "name": "test", "state": "present"})
     result = self.execute_module(changed=True)
     expected_commands = ["vlan 2", "name test"]
     self.assertEqual(result["commands"], expected_commands)
Beispiel #21
0
 def test_ios_vrf_route_both_mixed(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(changed=True)
 def test_ios_bgp_address_family_replaced(self):
     set_module_args(
         dict(
             config=dict(
                 as_number="65000",
                 address_family=[
                     dict(
                         afi="ipv4",
                         safi="multicast",
                         vrf="blue",
                         aggregate_address=[
                             dict(
                                 address="192.0.2.1",
                                 netmask="255.255.255.255",
                                 as_confed_set=True,
                             ),
                         ],
                         bgp=dict(
                             aggregate_timer=10,
                             slow_peer=[
                                 dict(detection=dict(threshold=200)),
                             ],
                         ),
                         redistribute=[dict(connected=dict(metric=10))],
                         neighbor=[
                             dict(
                                 address="198.51.110.1",
                                 activate=True,
                                 remote_as=200,
                                 route_maps=[
                                     dict(
                                         name="test-replaced-route",
                                         out=True,
                                     ),
                                 ],
                             ),
                         ],
                     ),
                 ],
             ),
             state="replaced",
         ), )
     commands = [
         "router bgp 65000",
         "address-family ipv4 multicast vrf blue",
         "redistribute connected metric 10",
         "no bgp dampening 1 1 1 1",
         "bgp slow-peer detection threshold 200",
         "no neighbor 198.51.100.1 activate",
         "no neighbor 198.51.100.1 next-hop-self all",
         "no neighbor 198.51.100.1 remote-as 10",
         "no neighbor 198.51.100.1 local-as 20",
         "no neighbor 198.51.100.1 aigp send cost-community 100 poi igp-cost transitive",
         "no neighbor 198.51.100.1 route-server-client",
         "no neighbor 198.51.100.1 slow-peer detection threshold 150",
         "neighbor 198.51.110.1 activate",
         "neighbor 198.51.110.1 remote-as 200",
         "neighbor 198.51.110.1 route-map test-replaced-route out",
         "no network 198.51.110.10 mask 255.255.255.255 backdoor",
     ]
     result = self.execute_module(changed=True)
     self.assertEqual(sorted(result["commands"]), sorted(commands))
Beispiel #23
0
 def test_ios_vrf_route_export_ipv6(self):
     set_module_args(dict(name='test_15', rd='4:100', route_export_ipv6=['168.0.0.15:100', '4:100']))
     commands = ['vrf definition test_15', 'address-family ipv4', 'exit', 'address-family ipv6', 'exit', 'rd 4:100', 'address-family ipv6',
                 'route-target export 168.0.0.15:100', 'route-target export 4:100', 'exit-address-family']
     self.execute_module(changed=True, commands=commands, sort=False)
 def test_ios_bgp_address_family_overridden_idempotent(self):
     set_module_args(
         dict(
             config=dict(
                 as_number="65000",
                 address_family=[
                     dict(
                         afi="ipv4",
                         bgp=dict(redistribute_internal=True),
                         redistribute=[
                             dict(
                                 connected=dict(set=True),
                                 ospf=dict(match=dict(
                                     external=True,
                                     internal=True,
                                     type_1=True,
                                     type_2=True,
                                 ), ),
                             ),
                         ],
                         neighbor=[
                             dict(
                                 tag="TEST-PEER-GROUP",
                                 nexthop_self=dict(all=True),
                                 send_community=dict(set=True),
                             ),
                             dict(
                                 ipv6_address="2001:db8::1",
                                 activate=True,
                             ),
                         ],
                     ),
                     dict(
                         afi="ipv4",
                         safi="multicast",
                         vrf="blue",
                         aggregate_address=[
                             dict(
                                 address="192.0.2.1",
                                 netmask="255.255.255.255",
                                 as_confed_set=True,
                             ),
                         ],
                         bgp=dict(
                             aggregate_timer=10,
                             dampening=dict(
                                 penalty_half_time=1,
                                 reuse_route_val=1,
                                 suppress_route_val=1,
                                 max_suppress=1,
                             ),
                             slow_peer=[
                                 dict(detection=dict(threshold=150)),
                             ],
                         ),
                         neighbor=[
                             dict(
                                 activate=True,
                                 address="198.51.100.1",
                                 aigp=dict(send=dict(cost_community=dict(
                                     id=100,
                                     poi=dict(
                                         igp_cost=True,
                                         transitive=True,
                                     ),
                                 ), ), ),
                                 nexthop_self=dict(all=True),
                                 prefix_lists=[
                                     dict(
                                         name="AS65100-PREFIX-OUT",
                                         out="true",
                                     ),
                                 ],
                                 slow_peer=[
                                     dict(detection=dict(threshold=150)),
                                 ],
                                 remote_as=10,
                                 local_as=dict(number=20),
                                 route_maps=[
                                     dict(name="test-out", out=True),
                                 ],
                                 route_server_client=True,
                             ),
                         ],
                         network=[
                             dict(
                                 address="198.51.110.10",
                                 mask="255.255.255.255",
                                 backdoor=True,
                             ),
                         ],
                     ),
                     dict(
                         afi="ipv4",
                         safi="mdt",
                         bgp=dict(
                             dmzlink_bw=True,
                             dampening=dict(
                                 penalty_half_time=1,
                                 reuse_route_val=10,
                                 suppress_route_val=100,
                                 max_suppress=5,
                             ),
                             soft_reconfig_backup=True,
                         ),
                     ),
                     dict(
                         afi="ipv4",
                         safi="multicast",
                         aggregate_address=[
                             dict(
                                 address="192.0.3.1",
                                 netmask="255.255.255.255",
                                 as_confed_set=True,
                             ),
                         ],
                         default_metric=12,
                         distance=dict(external=10, internal=10, local=100),
                         network=[
                             dict(
                                 address="198.51.111.11",
                                 mask="255.255.255.255",
                                 route_map="test",
                             ),
                         ],
                         table_map=dict(name="test_tableMap", filter=True),
                     ),
                 ],
             ),
             state="overridden",
         ), )
     self.execute_module(changed=False, commands=[])
Beispiel #25
0
 def test_ios_vrf_route_both_ipv6_mixed_idempotent(self):
     set_module_args(dict(name='test_17', rd='2:100', route_import_ipv6=['168.0.0.14:100'], route_both_ipv6=['2:100', '168.0.0.13:100'],
                          route_export_ipv6=['168.0.0.15:100', '4:100']))
     self.execute_module(changed=False, commands=[], sort=False)
 def test_ios_bgp_address_family_rendered(self):
     set_module_args(
         dict(
             config=dict(
                 as_number="65000",
                 address_family=[
                     dict(
                         afi="ipv4",
                         safi="multicast",
                         vrf="blue",
                         aggregate_address=[
                             dict(
                                 address="192.0.2.1",
                                 netmask="255.255.255.255",
                                 as_confed_set=True,
                             ),
                         ],
                         bgp=dict(dampening=dict(
                             penalty_half_time=1,
                             reuse_route_val=1,
                             suppress_route_val=1,
                             max_suppress=1,
                         ), ),
                         neighbor=[
                             dict(
                                 activate=True,
                                 address="198.51.100.1",
                                 aigp=dict(send=dict(cost_community=dict(
                                     id=100,
                                     poi=dict(
                                         igp_cost=True,
                                         transitive=True,
                                     ),
                                 ), ), ),
                                 slow_peer=[
                                     dict(detection=dict(threshold=150)),
                                 ],
                                 remote_as=10,
                                 route_maps=[
                                     dict(name="test-route", out=True),
                                 ],
                                 route_server_client=True,
                             ),
                         ],
                         network=[
                             dict(
                                 address="198.51.110.10",
                                 mask="255.255.255.255",
                                 backdoor=True,
                             ),
                         ],
                     ),
                     dict(
                         afi="ipv4",
                         safi="multicast",
                         aggregate_address=[
                             dict(
                                 address="192.0.3.1",
                                 netmask="255.255.255.255",
                                 as_confed_set=True,
                             ),
                         ],
                         default_metric=12,
                         distance=dict(external=10, internal=10, local=100),
                         network=[
                             dict(
                                 address="198.51.111.11",
                                 mask="255.255.255.255",
                                 route_map="test",
                             ),
                         ],
                         table_map=dict(name="test_tableMap", filter=True),
                     ),
                 ],
             ),
             state="rendered",
         ), )
     commands = [
         "router bgp 65000",
         "address-family ipv4 multicast vrf blue",
         "bgp dampening 1 1 1 1",
         "neighbor 198.51.100.1 remote-as 10",
         "neighbor 198.51.100.1 activate",
         "neighbor 198.51.100.1 aigp send cost-community 100 poi igp-cost transitive",
         "neighbor 198.51.100.1 route-map test-route out",
         "neighbor 198.51.100.1 route-server-client",
         "neighbor 198.51.100.1 slow-peer detection threshold 150",
         "network 198.51.110.10 mask 255.255.255.255 backdoor",
         "aggregate-address 192.0.2.1 255.255.255.255 as-confed-set",
         "address-family ipv4 multicast",
         "network 198.51.111.11 mask 255.255.255.255 route-map test",
         "aggregate-address 192.0.3.1 255.255.255.255 as-confed-set",
         "default-metric 12",
         "distance bgp 10 10 100",
         "table-map test_tableMap filter",
     ]
     result = self.execute_module(changed=False)
     self.assertEqual(sorted(result["rendered"]), sorted(commands))
Beispiel #27
0
 def test_ios_vrf_all_route_both_idempotent(self):
     set_module_args(dict(name='test_19', rd='10:700', route_both=['2:100', '2:101'], route_export=['2:102', '2:103'], route_import=['2:104', '2:105'],
                          route_both_ipv4=['2:100', '2:101'], route_export_ipv4=['2:102', '2:103'], route_import_ipv4=['2:104', '2:105'],
                          route_both_ipv6=['2:100', '2:101'], route_export_ipv6=['2:102', '2:103'], route_import_ipv6=['2:104', '2:105']))
     self.execute_module(changed=False, commands=[], sort=False)
 def test_ios_bgp_address_family_merged(self):
     set_module_args(
         dict(
             config=dict(
                 as_number="65000",
                 address_family=[
                     dict(
                         afi="ipv4",
                         safi="multicast",
                         vrf="blue",
                         aggregate_address=[
                             dict(
                                 address="192.0.3.1",
                                 netmask="255.255.255.255",
                                 as_confed_set=True,
                             ),
                         ],
                         bgp=dict(dampening=dict(
                             penalty_half_time=10,
                             reuse_route_val=10,
                             suppress_route_val=10,
                             max_suppress=10,
                         ), ),
                         neighbor=[
                             dict(
                                 address="198.51.100.1",
                                 remote_as=65100,
                                 route_maps=[
                                     dict(
                                         name="test-route-out",
                                         out="true",
                                     ),
                                 ],
                                 prefix_lists=[
                                     dict(
                                         name="AS65100-PREFIX-OUT",
                                         out="true",
                                     ),
                                 ],
                             ),
                         ],
                     ),
                     dict(
                         afi="nsap",
                         bgp=dict(
                             aggregate_timer=20,
                             dmzlink_bw=True,
                             scan_time=10,
                         ),
                         default_metric=10,
                         network=[
                             dict(
                                 address="192.0.1.1",
                                 route_map="test_route",
                             ),
                         ],
                     ),
                 ],
             ),
             state="merged",
         ), )
     commands = [
         "router bgp 65000",
         "address-family ipv4 multicast vrf blue",
         "bgp dampening 10 10 10 10",
         "aggregate-address 192.0.3.1 255.255.255.255 as-confed-set",
         "address-family nsap",
         "bgp aggregate-timer 20",
         "bgp dmzlink-bw",
         "bgp scan-time 10",
         "neighbor 198.51.100.1 remote-as 65100",
         "neighbor 198.51.100.1 route-map test-route-out out",
         "network 192.0.1.1 route-map test_route",
         "default-metric 10",
     ]
     result = self.execute_module(changed=True)
     self.assertEqual(sorted(result["commands"]), sorted(commands))
Beispiel #29
0
 def test_ios_vrf_name_unchanged(self):
     set_module_args(dict(name='test_1', rd='1:100', description='test vrf 1'))
     self.execute_module()
Beispiel #30
0
 def test_ios_banner_idemp(self):
     banner_text = ""
     set_module_args(dict(banner="login", text=banner_text))
     self.execute_module()