summaryrefslogtreecommitdiff
path: root/test/units/modules/network
diff options
context:
space:
mode:
authorAnsible Core Team <info@ansible.com>2020-03-09 09:40:34 +0000
committerMatt Martz <matt@sivel.net>2020-03-23 11:14:21 -0500
commit7e04b5ba8ba32ec6992362788626ea10fc69b375 (patch)
tree4ffffd9e84c1ba29943e8a65943af8a4db45c423 /test/units/modules/network
parent8a2e2e8af27705627d424c33b2cd39ac0b5c4a50 (diff)
downloadansible-7e04b5ba8ba32ec6992362788626ea10fc69b375.tar.gz
Migrated to cisco.ios
Diffstat (limited to 'test/units/modules/network')
-rw-r--r--test/units/modules/network/ios/fixtures/configure_terminal2
-rw-r--r--test/units/modules/network/ios/fixtures/ios_acl_interfaces.cfg8
-rw-r--r--test/units/modules/network/ios/fixtures/ios_acls_config.cfg4
-rw-r--r--test/units/modules/network/ios/fixtures/ios_banner_show_banner.txt3
-rw-r--r--test/units/modules/network/ios/fixtures/ios_banner_show_running_config_ios12.txt15
-rw-r--r--test/units/modules/network/ios/fixtures/ios_bgp_config.cfg24
-rw-r--r--test/units/modules/network/ios/fixtures/ios_config_config.cfg12
-rw-r--r--test/units/modules/network/ios/fixtures/ios_config_defaults.cfg13
-rw-r--r--test/units/modules/network/ios/fixtures/ios_config_src.cfg11
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_dir23
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_cdp4
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_cdp_neighbors_detail40
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_interfaces61
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_ip_interface0
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_ipv6_interface0
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_lldp6
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_lldp_neighbors_detail50
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_memory_statistics0
-rw-r--r--test/units/modules/network/ios/fixtures/ios_facts_show_version68
-rw-r--r--test/units/modules/network/ios/fixtures/ios_logging_config.cfg11
-rw-r--r--test/units/modules/network/ios/fixtures/ios_logging_config_ios12.cfg6
-rw-r--r--test/units/modules/network/ios/fixtures/ios_ntp_config.cfg7
-rw-r--r--test/units/modules/network/ios/fixtures/ios_ping_ping_10.255.255.250_repeat_24
-rw-r--r--test/units/modules/network/ios/fixtures/ios_ping_ping_8.8.8.8_repeat_24
-rw-r--r--test/units/modules/network/ios/fixtures/ios_static_routes_config.cfg2
-rw-r--r--test/units/modules/network/ios/fixtures/ios_system_config.cfg14
-rw-r--r--test/units/modules/network/ios/fixtures/ios_user_config.cfg2
-rw-r--r--test/units/modules/network/ios/fixtures/ios_vlan_config.cfg9
-rw-r--r--test/units/modules/network/ios/fixtures/ios_vrf_config.cfg81
-rw-r--r--test/units/modules/network/ios/fixtures/show_version45
-rw-r--r--test/units/modules/network/ios/ios_module.py87
-rw-r--r--test/units/modules/network/ios/test_ios_acl_interfaces.py335
-rw-r--r--test/units/modules/network/ios/test_ios_acls.py451
-rw-r--r--test/units/modules/network/ios/test_ios_banner.py76
-rw-r--r--test/units/modules/network/ios/test_ios_bgp.py207
-rw-r--r--test/units/modules/network/ios/test_ios_command.py126
-rw-r--r--test/units/modules/network/ios/test_ios_config.py250
-rw-r--r--test/units/modules/network/ios/test_ios_facts.py123
-rw-r--r--test/units/modules/network/ios/test_ios_logging.py140
-rw-r--r--test/units/modules/network/ios/test_ios_ntp.py99
-rw-r--r--test/units/modules/network/ios/test_ios_ping.py72
-rw-r--r--test/units/modules/network/ios/test_ios_static_routes.py357
-rw-r--r--test/units/modules/network/ios/test_ios_system.py123
-rw-r--r--test/units/modules/network/ios/test_ios_user.py141
-rw-r--r--test/units/modules/network/ios/test_ios_vlan.py149
-rw-r--r--test/units/modules/network/ios/test_ios_vrf.py210
46 files changed, 0 insertions, 3475 deletions
diff --git a/test/units/modules/network/ios/fixtures/configure_terminal b/test/units/modules/network/ios/fixtures/configure_terminal
deleted file mode 100644
index 139597f9cb..0000000000
--- a/test/units/modules/network/ios/fixtures/configure_terminal
+++ /dev/null
@@ -1,2 +0,0 @@
-
-
diff --git a/test/units/modules/network/ios/fixtures/ios_acl_interfaces.cfg b/test/units/modules/network/ios/fixtures/ios_acl_interfaces.cfg
deleted file mode 100644
index 1462c13530..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_acl_interfaces.cfg
+++ /dev/null
@@ -1,8 +0,0 @@
-interface GigabitEthernet0/1
-ip access-group 110 in
-ip access-group 123 out
-ipv6 traffic-filter temp_v6 in
-ipv6 traffic-filter test_v6 out
-interface GigabitEthernet0/2
-ip access-group 110 in
-ip access-group 123 out
diff --git a/test/units/modules/network/ios/fixtures/ios_acls_config.cfg b/test/units/modules/network/ios/fixtures/ios_acls_config.cfg
deleted file mode 100644
index c90c8db909..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_acls_config.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-ip access-list extended 110
-deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10
-ipv6 access-list R1_TRAFFIC
-deny tcp any eq www any eq telnet ack dscp af11 \ No newline at end of file
diff --git a/test/units/modules/network/ios/fixtures/ios_banner_show_banner.txt b/test/units/modules/network/ios/fixtures/ios_banner_show_banner.txt
deleted file mode 100644
index a134a31753..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_banner_show_banner.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-this is a sample
-mulitline banner
-used for testing
diff --git a/test/units/modules/network/ios/fixtures/ios_banner_show_running_config_ios12.txt b/test/units/modules/network/ios/fixtures/ios_banner_show_running_config_ios12.txt
deleted file mode 100644
index 004387a9b8..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_banner_show_running_config_ios12.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-banner exec ^C
-this is a sample
-mulitline banner
-used for testing
-^C
-banner login ^C
-this is a sample
-mulitline banner
-used for testing
-^C
-!
-dummy
-end
-of
-config
diff --git a/test/units/modules/network/ios/fixtures/ios_bgp_config.cfg b/test/units/modules/network/ios/fixtures/ios_bgp_config.cfg
deleted file mode 100644
index 9fec934aa4..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_bgp_config.cfg
+++ /dev/null
@@ -1,24 +0,0 @@
-!
-router bgp 64496
- bgp router-id 192.0.2.1
- bgp log-neighbor-changes
- neighbor 192.51.100.1 remote-as 64496
- neighbor 192.51.100.1 timers 120 360 360
- neighbor 198.51.100.3 remote-as 64498
- neighbor 203.0.113.5 remote-as 500
- neighbor 203.0.113.5 description EBGP_PEER
- !
- address-family ipv4
- network 192.0.2.0 mask 255.255.254.0 route-map RMAP_1
- network 198.51.100.0 mask 255.255.255.128 route-map RMAP_2
- redistribute static metric 100
- redistribute eigrp metric 10 route-map RMAP_3
- neighbor 203.0.113.1 remove-private-as
- neighbor 203.0.113.1 maximum-prefix 100
- exit-address-family
- !
- address-family ipv4 multicast
- network 203.0.113.0 mask 255.255.255.224 route-map RMAP_1
- network 192.0.2.0 mask 255.255.255.192 route-map RMAP_2
- exit-address-family
-!
diff --git a/test/units/modules/network/ios/fixtures/ios_config_config.cfg b/test/units/modules/network/ios/fixtures/ios_config_config.cfg
deleted file mode 100644
index afad9d08aa..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_config_config.cfg
+++ /dev/null
@@ -1,12 +0,0 @@
-!
-hostname router
-!
-interface GigabitEthernet0/0
- ip address 1.2.3.4 255.255.255.0
- description test string
-!
-interface GigabitEthernet0/1
- ip address 6.7.8.9 255.255.255.0
- description test string
- shutdown
-!
diff --git a/test/units/modules/network/ios/fixtures/ios_config_defaults.cfg b/test/units/modules/network/ios/fixtures/ios_config_defaults.cfg
deleted file mode 100644
index e54645ab14..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_config_defaults.cfg
+++ /dev/null
@@ -1,13 +0,0 @@
-!
-hostname router
-!
-interface GigabitEthernet0/0
- ip address 1.2.3.4 255.255.255.0
- description test string
- no shutdown
-!
-interface GigabitEthernet0/1
- ip address 6.7.8.9 255.255.255.0
- description test string
- shutdown
-!
diff --git a/test/units/modules/network/ios/fixtures/ios_config_src.cfg b/test/units/modules/network/ios/fixtures/ios_config_src.cfg
deleted file mode 100644
index b3d8961a99..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_config_src.cfg
+++ /dev/null
@@ -1,11 +0,0 @@
-!
-hostname foo
-!
-interface GigabitEthernet0/0
- no ip address
-!
-interface GigabitEthernet0/1
- ip address 6.7.8.9 255.255.255.0
- description test string
- shutdown
-!
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_dir b/test/units/modules/network/ios/fixtures/ios_facts_dir
deleted file mode 100644
index 3adc44adba..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_dir
+++ /dev/null
@@ -1,23 +0,0 @@
-Directory of bootflash:/
-
- 11 drwx 16384 Jun 1 2017 13:03:27 +00:00 lost+found
-325121 drwx 4096 Jun 1 2017 13:03:54 +00:00 .super.iso.dir
- 12 -rw- 31 Jun 22 2018 15:17:06 +00:00 .CsrLxc_LastInstall
- 13 -rw- 69 Jun 1 2017 13:05:53 +00:00 virtual-instance.conf
-438913 drwx 4096 Jun 1 2017 13:04:57 +00:00 core
- 15 -rw- 125736960 Jun 1 2017 13:03:54 +00:00 iosxe-remote-mgmt.16.03.04.ova
-105667 -rw- 292164568 Jun 1 2017 13:04:04 +00:00 csr1000v-mono-universalk9.16.03.04.SPA.pkg
-105668 -rw- 34370768 Jun 1 2017 13:04:10 +00:00 csr1000v-rpboot.16.03.04.SPA.pkg
-105666 -rw- 5317 Jun 1 2017 13:04:10 +00:00 packages.conf
-195073 drwx 4096 Jun 1 2017 13:04:51 +00:00 .prst_sync
-414529 drwx 4096 Jun 1 2017 13:04:57 +00:00 .rollback_timer
- 16 -rw- 0 Jun 1 2017 13:05:00 +00:00 tracelogs.kZn
-16257 drwx 24576 Jun 22 2018 16:03:11 +00:00 tracelogs
-349505 drwx 4096 Jun 1 2017 13:05:08 +00:00 .installer
-292609 drwx 4096 Jun 1 2017 13:05:59 +00:00 virtual-instance
- 17 -rw- 30 Jun 22 2018 15:17:59 +00:00 throughput_monitor_params
-48769 drwx 4096 Jun 1 2017 13:06:04 +00:00 onep
- 19 -rw- 376 Jun 22 2018 15:18:11 +00:00 csrlxc-cfg.log
- 20 -rw- 0 Jun 22 2018 15:17:59 +00:00 cvac.log
-
-7897796608 bytes total (6608056320 bytes free)
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_cdp b/test/units/modules/network/ios/fixtures/ios_facts_show_cdp
deleted file mode 100644
index c5fff7d278..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_cdp
+++ /dev/null
@@ -1,4 +0,0 @@
-Global CDP information:
- Sending CDP packets every 60 seconds
- Sending a holdtime value of 180 seconds
- Sending CDPv2 advertisements is enabled
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_cdp_neighbors_detail b/test/units/modules/network/ios/fixtures/ios_facts_show_cdp_neighbors_detail
deleted file mode 100644
index b3d5453dd2..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_cdp_neighbors_detail
+++ /dev/null
@@ -1,40 +0,0 @@
--------------------------
-Device ID: R2
-Entry address(es):
- IP address: 10.0.0.3
-Platform: cisco CSR1000V, Capabilities: Router IGMP
-Interface: GigabitEthernet1, Port ID (outgoing port): GigabitEthernet2
-Holdtime : 149 sec
-
-Version :
-Cisco IOS Software [Everest], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.4, RELEASE SOFTWARE (fc3)
-Technical Support: http://www.cisco.com/techsupport
-Copyright (c) 1986-2018 by Cisco Systems, Inc.
-Compiled Sun 08-Jul-18 04:30 by mcpre
-
-advertisement version: 2
-Duplex: full
-Management address(es):
- IP address: 10.0.0.3
-
--------------------------
-Device ID: R3
-Entry address(es):
- IP address: 10.0.0.4
-Platform: cisco CSR1000V, Capabilities: Router IGMP
-Interface: GigabitEthernet1, Port ID (outgoing port): GigabitEthernet3
-Holdtime : 149 sec
-
-Version :
-Cisco IOS Software [Everest], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.4, RELEASE SOFTWARE (fc3)
-Technical Support: http://www.cisco.com/techsupport
-Copyright (c) 1986-2018 by Cisco Systems, Inc.
-Compiled Sun 08-Jul-18 04:30 by mcpre
-
-advertisement version: 2
-Duplex: full
-Management address(es):
- IP address: 10.0.0.4
-
-
-Total cdp entries displayed : 2
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_interfaces b/test/units/modules/network/ios/fixtures/ios_facts_show_interfaces
deleted file mode 100644
index 002b8b9eee..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_interfaces
+++ /dev/null
@@ -1,61 +0,0 @@
-GigabitEthernet0/0 is up, line protocol is up
- Hardware is iGbE, address is 5e00.0003.0000 (bia 5e00.0003.0000)
- Description: OOB Management
- Internet address is 10.8.38.66/24
- MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
- reliability 253/255, txload 1/255, rxload 1/255
- Encapsulation ARPA, loopback not set
- Keepalive set (10 sec)
- Full Duplex, Auto Speed, link type is auto, media type is RJ45
- output flow-control is unsupported, input flow-control is unsupported
- ARP type: ARPA, ARP Timeout 04:00:00
- Last input 00:00:00, output 00:00:00, output hang never
- Last clearing of "show interface" counters never
- Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
- Queueing strategy: fifo
- Output queue: 0/40 (size/max)
- 5 minute input rate 3000 bits/sec, 2 packets/sec
- 5 minute output rate 2000 bits/sec, 2 packets/sec
- 2226666 packets input, 398288440 bytes, 0 no buffer
- Received 156442 broadcasts (0 IP multicasts)
- 25440 runts, 0 giants, 0 throttles
- 25440 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
- 0 watchdog, 0 multicast, 0 pause input
- 1304895 packets output, 119337031 bytes, 0 underruns
- 0 output errors, 0 collisions, 3 interface resets
- 1083697 unknown protocol drops
- 0 babbles, 0 late collision, 0 deferred
- 1 lost carrier, 0 no carrier, 0 pause output
- 0 output buffer failures, 0 output buffers swapped out
-GigabitEthernet1 is up, line protocol is up
- Hardware is CSR vNIC, address is 5e00.0006.0000 (bia 5e00.0006.0000)
- Description: OOB Management
- Internet address is 10.8.38.67/24
- MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec,
- reliability 255/255, txload 1/255, rxload 1/255
- Encapsulation ARPA, loopback not set
- Keepalive set (10 sec)
- Full Duplex, 1000Mbps, link type is auto, media type is RJ45
- output flow-control is unsupported, input flow-control is unsupported
- ARP type: ARPA, ARP Timeout 04:00:00
- Last input 00:00:01, output 00:00:07, output hang never
- Last clearing of "show interface" counters never
- Input queue: 0/375/0/0 (size/max/drops/flushes); Total output drops: 0
- Queueing strategy: fifo
- Output queue: 0/40 (size/max)
- 5 minute input rate 3000 bits/sec, 3 packets/sec
- 5 minute output rate 3000 bits/sec, 3 packets/sec
- 8463791 packets input, 1445150230 bytes, 0 no buffer
- Received 0 broadcasts (0 IP multicasts)
- 0 runts, 0 giants, 0 throttles
- 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
- 0 watchdog, 0 multicast, 0 pause input
- 3521571 packets output, 348781823 bytes, 0 underruns
- 0 output errors, 0 collisions, 1 interface resets
- 4150764 unknown protocol drops
- 0 babbles, 0 late collision, 0 deferred
- 0 lost carrier, 0 no carrier, 0 pause output
- 0 output buffer failures, 0 output buffers swapped out
-Tunnel1110 is up, line protocol is up
- Hardware is Tunnel
- Internet address is 10.10.10.2/30
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_ip_interface b/test/units/modules/network/ios/fixtures/ios_facts_show_ip_interface
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_ip_interface
+++ /dev/null
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_ipv6_interface b/test/units/modules/network/ios/fixtures/ios_facts_show_ipv6_interface
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_ipv6_interface
+++ /dev/null
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_lldp b/test/units/modules/network/ios/fixtures/ios_facts_show_lldp
deleted file mode 100644
index 09847c318c..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_lldp
+++ /dev/null
@@ -1,6 +0,0 @@
-
-Global LLDP Information:
- Status: ACTIVE
- LLDP advertisements are sent every 30 seconds
- LLDP hold time advertised is 120 seconds
- LLDP interface reinitialisation delay is 2 seconds
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_lldp_neighbors_detail b/test/units/modules/network/ios/fixtures/ios_facts_show_lldp_neighbors_detail
deleted file mode 100644
index adc4f30e46..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_lldp_neighbors_detail
+++ /dev/null
@@ -1,50 +0,0 @@
-------------------------------------------------
-Local Intf: Gi1
-Chassis id: 001e.14d4.5300
-Port id: Gi3
-Port Description: GigabitEthernet3
-System Name: R3
-
-System Description:
-Cisco IOS Software [Everest], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.4, RELEASE SOFTWARE (fc3)
-Technical Support: http://www.cisco.com/techsupport
-Copyright (c) 1986-2018 by Cisco Systems, Inc.
-Compiled Sun 08-Jul-18 04:30 by
-
-Time remaining: 116 seconds
-System Capabilities: B,R
-Enabled Capabilities: R
-Management Addresses:
- IP: 10.0.0.4
-Auto Negotiation - not supported
-Physical media capabilities - not advertised
-Media Attachment Unit type - not advertised
-Vlan ID: - not advertised
-
-------------------------------------------------
-Local Intf: Gi3
-Chassis id: 001e.e6c9.6d00
-Port id: Gi1
-Port Description: GigabitEthernet1
-System Name: Rtest
-
-System Description:
-Cisco IOS Software [Everest], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.6.4, RELEASE SOFTWARE (fc3)
-Technical Support: http://www.cisco.com/techsupport
-Copyright (c) 1986-2018 by Cisco Systems, Inc.
-Compiled Sun 08-Jul-18 04:30 by
-
-Time remaining: 116 seconds
-System Capabilities: B,R
-Enabled Capabilities: R
-Management Addresses:
- IP: 10.3.0.3
-Auto Negotiation - not supported
-Physical media capabilities - not advertised
-Media Attachment Unit type - not advertised
-Vlan ID: - not advertised
-
-
-Total entries displayed: 2
-
-
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_memory_statistics b/test/units/modules/network/ios/fixtures/ios_facts_show_memory_statistics
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_memory_statistics
+++ /dev/null
diff --git a/test/units/modules/network/ios/fixtures/ios_facts_show_version b/test/units/modules/network/ios/fixtures/ios_facts_show_version
deleted file mode 100644
index 58322c80b4..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_facts_show_version
+++ /dev/null
@@ -1,68 +0,0 @@
-Cisco Internetwork Operating System Software
-IOS (tm) C3750 Software (C3750-I5-M), Version 12.1(14)EA1, RELEASE SOFTWARE (fc1)
-Copyright (c) 1986-2003 by cisco Systems, Inc.
-Compiled Tue 22-Jul-03 13:17 by antonino
-Image text-base: 0x00003000, data-base: 0x008F0CF8
-
-ROM: Bootstrap program is C3750 boot loader
-BOOTLDR: C3750 Boot Loader (C3750-HBOOT-M) Version 12.1(11r)AX, RELEASE SOFTWARE (fc1)
-
-3750RJ uptime is 1 hour, 29 minutes
-System returned to ROM by power-on
-System image file is "flash:c3750-i5-mz.121.14-EA1/c3750-i5-mz.121.14-EA1.bin"
-
-cisco WS-C3750-24TS (PowerPC405) processor (revision A0) with 120822K/10240K bytes of memory.
-Processor board ID CAT0726R0ZU
-Last reset from power-on
-Bridging software.
-2 Virtual Ethernet/IEEE 802.3 interface(s)
-48 FastEthernet/IEEE 802.3 interface(s)
-16 Gigabit Ethernet/IEEE 802.3 interface(s)
-The password-recovery mechanism is enabled.
-
-512K bytes of flash-simulated non-volatile configuration memory.
-Base ethernet MAC Address : 00:0D:29:B4:18:00
-Motherboard assembly number : 73-7055-06
-Power supply part number : 341-0034-01
-Motherboard serial number : CAT0726043V
-Power supply serial number : PHI0708009K
-Model revision number : A0
-Motherboard revision number : A0
-Model number : WS-C3750-24TS-E
-System serial number : CAT0726R0ZU
-
-Switch Ports Model SW Version SW Image
------- ----- ----- ---------- ----------
-* 1 26 WS-C3750-24TS 12.1(14)EA1 C3750-I5-M
-2 26 WS-C3750-24TS 12.1(14)EA1 C3750-I5-M
-3 12 WS-C3750G-12S 12.1(14)EA1 C3750-I5-M
-
-Switch 02
----------
-Switch Uptime : 1 hour, 29 minutes
-Base ethernet MAC Address : 00:0D:29:B4:3F:00
-Motherboard assembly number : 73-7055-06
-Power supply part number : 341-0034-01
-Motherboard serial number : CAT07260438
-Power supply serial number : PHI0708008X
-Model revision number : A0
-Motherboard revision number : A0
-Model number : WS-C3750-24TS-E
-System serial number : CAT0726R10A
-
-Switch 03
----------
-Switch Uptime : 1 hour, 29 minutes
-Base ethernet MAC Address : 00:0D:BD:6A:3E:00
-Motherboard assembly number : 73-8307-06
-Power supply part number : 341-0048-01
-Motherboard serial number : CAT073205S2
-Power supply serial number : DTH0731055Z
-Model revision number : A0
-Motherboard revision number : A0
-Model number : WS-C3750G-12S-E
-System serial number : CAT0732R0M4
-Top assembly part number : 800-23419-01
-Top assembly revision number : A0
-
-Configuration register is 0xF
diff --git a/test/units/modules/network/ios/fixtures/ios_logging_config.cfg b/test/units/modules/network/ios/fixtures/ios_logging_config.cfg
deleted file mode 100644
index 8a51afa7e5..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_logging_config.cfg
+++ /dev/null
@@ -1,11 +0,0 @@
-!
-logging buffered 5000
-logging console informational
-logging facility local0
-no logging monitor
-logging host 1.2.3.4 transport tcp
-logging host 1.2.3.4
-logging host 2.3.4.5
-logging host 1.2.3.4 transport tcp port 1000
-logging host 1.2.3.4 transport udp port 1000
-!
diff --git a/test/units/modules/network/ios/fixtures/ios_logging_config_ios12.cfg b/test/units/modules/network/ios/fixtures/ios_logging_config_ios12.cfg
deleted file mode 100644
index 58be36dff5..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_logging_config_ios12.cfg
+++ /dev/null
@@ -1,6 +0,0 @@
-!
-logging buffered 5000
-logging console informational
-logging facility local0
-logging 2.3.4.5
-!
diff --git a/test/units/modules/network/ios/fixtures/ios_ntp_config.cfg b/test/units/modules/network/ios/fixtures/ios_ntp_config.cfg
deleted file mode 100644
index ccd8558ab3..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_ntp_config.cfg
+++ /dev/null
@@ -1,7 +0,0 @@
-ntp logging
-ntp authentication-key 10 md5 15435A030726242723273C21181319000A 7
-ntp authenticate
-ntp trusted-key 10
-ntp source Loopback0
-ntp access-group peer NTP_ACL
-ntp server 10.75.32.5
diff --git a/test/units/modules/network/ios/fixtures/ios_ping_ping_10.255.255.250_repeat_2 b/test/units/modules/network/ios/fixtures/ios_ping_ping_10.255.255.250_repeat_2
deleted file mode 100644
index 9b25d64549..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_ping_ping_10.255.255.250_repeat_2
+++ /dev/null
@@ -1,4 +0,0 @@
-Type escape sequence to abort.
-Sending 2, 100-byte ICMP Echos to 10.255.255.250, timeout is 2 seconds:
-..
-Success rate is 0 percent (0/2)
diff --git a/test/units/modules/network/ios/fixtures/ios_ping_ping_8.8.8.8_repeat_2 b/test/units/modules/network/ios/fixtures/ios_ping_ping_8.8.8.8_repeat_2
deleted file mode 100644
index 4dddd76b0f..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_ping_ping_8.8.8.8_repeat_2
+++ /dev/null
@@ -1,4 +0,0 @@
-Type escape sequence to abort.
-Sending 2, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
-!!
-Success rate is 100 percent (2/2), round-trip min/avg/max = 25/25/25 ms
diff --git a/test/units/modules/network/ios/fixtures/ios_static_routes_config.cfg b/test/units/modules/network/ios/fixtures/ios_static_routes_config.cfg
deleted file mode 100644
index b947d5dcfe..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_static_routes_config.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-ip route vrf ansible_vrf 192.0.2.0 255.255.255.0 192.0.2.1 name test_vrf track 175 tag 50
-ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 multicast name route_1 tag 60
diff --git a/test/units/modules/network/ios/fixtures/ios_system_config.cfg b/test/units/modules/network/ios/fixtures/ios_system_config.cfg
deleted file mode 100644
index 3330b4aa34..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_system_config.cfg
+++ /dev/null
@@ -1,14 +0,0 @@
-!
-hostname ios01
-!
-ip domain list vrf management example.net
-ip domain list example.net
-ip domain list example.com
-ip domain lookup source-interface GigabitEthernet0/0
-ip domain name vrf management eng.example.net
-ip domain name eng.example.net
-ip name-server vrf management 8.8.8.8
-ip name-server 8.8.8.8
-!
-vrf definition test
-!
diff --git a/test/units/modules/network/ios/fixtures/ios_user_config.cfg b/test/units/modules/network/ios/fixtures/ios_user_config.cfg
deleted file mode 100644
index dd5b2095fa..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_user_config.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-username admin view network-admin secret 5 $1$mdQIUxjg$3t3lzBpfKfITKvFm1uEIY.
-username ansible view network-admin secret 5 $1$3yWSXiIi$VdzV59ChiurrNdGxlDeAW/
diff --git a/test/units/modules/network/ios/fixtures/ios_vlan_config.cfg b/test/units/modules/network/ios/fixtures/ios_vlan_config.cfg
deleted file mode 100644
index 69ac0b5e55..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_vlan_config.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-VLAN Name Status Ports
----- -------------------------------- --------- -------------------------------
-1 default active Gi1/0/4, Gi1/0/5
- Gi1/0/52
- Gi1/0/54
-2 vlan2 active Gi1/0/6, Gi1/0/7
-9 vlan9 active Gi1/0/6
-1002 fddi-default act/unsup
-1003 fddo-default act/unsup
diff --git a/test/units/modules/network/ios/fixtures/ios_vrf_config.cfg b/test/units/modules/network/ios/fixtures/ios_vrf_config.cfg
deleted file mode 100644
index 0a2d35f8fb..0000000000
--- a/test/units/modules/network/ios/fixtures/ios_vrf_config.cfg
+++ /dev/null
@@ -1,81 +0,0 @@
-!
-vrf definition test_1
- description test vrf 1
- rd 1:100
-!
-vrf definition test_2
- description test vrf 2
-!
-vrf definition test_3
-!
-vrf definition test_17
- rd 2:100
- !
- address-family ipv4
- exit-address-family
- !
- address-family ipv6
- route-target export 168.0.0.15:100
- route-target export 4:100
- route-target export 2:100
- route-target export 168.0.0.13:100
- route-target import 168.0.0.14:100
- route-target import 2:100
- route-target import 168.0.0.13:100
- exit-address-family
-!
-vrf definition test_18
- rd 168.0.0.9:100
- !
- address-family ipv4
- route-target export 168.0.0.10:100
- route-target export 168.0.0.9:100
- route-target export 3:100
- route-target import 168.0.0.9:100
- route-target import 3:100
- route-target import 168.0.0.10:600
- exit-address-family
- !
- address-family ipv6
- exit-address-family
-!
-vrf definition test_19
- rd 10:700
- route-target export 2:102
- route-target export 2:103
- route-target export 2:100
- route-target export 2:101
- route-target import 2:104
- route-target import 2:105
- route-target import 2:100
- route-target import 2:101
- !
- address-family ipv4
- route-target export 2:102
- route-target export 2:103
- route-target export 2:100
- route-target export 2:101
- route-target import 2:104
- route-target import 2:105
- route-target import 2:100
- route-target import 2:101
- exit-address-family
- !
- address-family ipv6
- route-target export 2:102
- route-target export 2:103
- route-target export 2:100
- route-target export 2:101
- route-target import 2:104
- route-target import 2:105
- route-target import 2:100
- route-target import 2:101
- exit-address-family
-!
-interface Ethernet1
- ip address 1.2.3.4/5
-!
-interface Ethernet2
- ip address 1.2.3.4/5
- vrf forwarding test_1
-!
diff --git a/test/units/modules/network/ios/fixtures/show_version b/test/units/modules/network/ios/fixtures/show_version
deleted file mode 100644
index d293df3a18..0000000000
--- a/test/units/modules/network/ios/fixtures/show_version
+++ /dev/null
@@ -1,45 +0,0 @@
-Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.6(1)T, RELEASE SOFTWARE (fc1)
-Technical Support: http://www.cisco.com/techsupport
-Copyright (c) 1986-2015 by Cisco Systems, Inc.
-Compiled Fri 20-Nov-15 13:39 by prod_rel_team
-
-
-ROM: Bootstrap program is IOSv
-
-ios01 uptime is 7 weeks, 5 days, 11 hours, 14 minutes
-System returned to ROM by reload
-System image file is "flash0:/vios-adventerprisek9-m"
-Last reload reason: Unknown reason
-
-
-
-This product contains cryptographic features and is subject to United
-States and local country laws governing import, export, transfer and
-use. Delivery of Cisco cryptographic products does not imply
-third-party authority to import, export, distribute or use encryption.
-Importers, exporters, distributors and users are responsible for
-compliance with U.S. and local country laws. By using this product you
-agree to comply with applicable laws and regulations. If you are unable
-to comply with U.S. and local laws, return this product immediately.
-
-A summary of U.S. laws governing Cisco cryptographic products may be found at:
-http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
-
-If you require further assistance please contact us by sending email to
-export@cisco.com.
-
-Cisco IOSv (revision 1.0) with with 472441K/50176K bytes of memory.
-Processor board ID 99I10YFMUCJ3JEZMV4DQB
-3 Gigabit Ethernet interfaces
-DRAM configuration is 72 bits wide with parity disabled.
-256K bytes of non-volatile configuration memory.
-2097152K bytes of ATA System CompactFlash 0 (Read/Write)
-0K bytes of ATA CompactFlash 1 (Read/Write)
-0K bytes of ATA CompactFlash 2 (Read/Write)
-10080K bytes of ATA CompactFlash 3 (Read/Write)
-
-
-
-Configuration register is 0x0
-
-
diff --git a/test/units/modules/network/ios/ios_module.py b/test/units/modules/network/ios/ios_module.py
deleted file mode 100644
index 34df31c812..0000000000
--- a/test/units/modules/network/ios/ios_module.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# (c) 2016 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import os
-import json
-
-from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase
-
-
-fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
-fixture_data = {}
-
-
-def load_fixture(name):
- path = os.path.join(fixture_path, name)
-
- if path in fixture_data:
- return fixture_data[path]
-
- with open(path) as f:
- data = f.read()
-
- try:
- data = json.loads(data)
- except Exception:
- pass
-
- fixture_data[path] = data
- return data
-
-
-class TestIosModule(ModuleTestCase):
-
- def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False):
- self.load_fixtures(commands)
-
- if failed:
- result = self.failed()
- self.assertTrue(result['failed'], result)
- else:
- result = self.changed(changed)
- self.assertEqual(result['changed'], changed, result)
-
- if commands is not None:
- if sort:
- self.assertEqual(sorted(commands), sorted(result['commands']), result['commands'])
- else:
- self.assertEqual(commands, result['commands'], result['commands'])
-
- return result
-
- def failed(self):
- with self.assertRaises(AnsibleFailJson) as exc:
- self.module.main()
-
- result = exc.exception.args[0]
- self.assertTrue(result['failed'], result)
- return result
-
- def changed(self, changed=False):
- with self.assertRaises(AnsibleExitJson) as exc:
- self.module.main()
-
- result = exc.exception.args[0]
- self.assertEqual(result['changed'], changed, result)
- return result
-
- def load_fixtures(self, commands=None):
- pass
diff --git a/test/units/modules/network/ios/test_ios_acl_interfaces.py b/test/units/modules/network/ios/test_ios_acl_interfaces.py
deleted file mode 100644
index b3296062a5..0000000000
--- a/test/units/modules/network/ios/test_ios_acl_interfaces.py
+++ /dev/null
@@ -1,335 +0,0 @@
-#
-# (c) 2019, Ansible by Red Hat, inc
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_acl_interfaces
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosAclInterfacesModule(TestIosModule):
- module = ios_acl_interfaces
-
- def setUp(self):
- super(TestIosAclInterfacesModule, self).setUp()
-
- self.mock_get_config = patch('ansible.module_utils.network.common.network.Config.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.module_utils.network.common.network.Config.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_get_resource_connection_config = patch('ansible.module_utils.network.common.cfg.base.'
- 'get_resource_connection')
- self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
-
- self.mock_get_resource_connection_facts = patch('ansible.module_utils.network.common.facts.facts.'
- 'get_resource_connection')
- self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
-
- self.mock_edit_config = patch('ansible.module_utils.network.ios.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.ios.facts.acl_interfaces.acl_interfaces.'
- 'Acl_InterfacesFacts.get_acl_interfaces_data')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestIosAclInterfacesModule, self).tearDown()
- self.mock_get_resource_connection_config.stop()
- self.mock_get_resource_connection_facts.stop()
- self.mock_edit_config.stop()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_execute_show_command.stop()
-
- def load_fixtures(self, commands=None):
-
- def load_from_file(*args, **kwargs):
- return load_fixture('ios_acl_interfaces.cfg')
- self.execute_show_command.side_effect = load_from_file
-
- def test_ios_acl_interfaces_merged(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/1",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="merge_110",
- direction="in"),
- dict(name="merge_123",
- direction="out")
- ]),
- dict(afi="ipv6",
- acls=[
- dict(name="merge_temp_v6",
- direction="in"),
- dict(name="merge_test_v6",
- direction="out")
- ])
- ]),
- dict(name="GigabitEthernet0/2",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="merge_110",
- direction="in"),
- dict(name="merge_123",
- direction="out")
- ])
- ])
- ], state="merged"))
- commands = ['interface GigabitEthernet0/1',
- 'ip access-group merge_110 in',
- 'ip access-group merge_123 out',
- 'ipv6 traffic-filter merge_temp_v6 in',
- 'ipv6 traffic-filter merge_test_v6 out',
- 'interface GigabitEthernet0/2',
- 'ip access-group merge_110 in',
- 'ip access-group merge_123 out'
- ]
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], commands)
-
- def test_ios_acl_interfaces_merged_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="GigabitEthernet0/1",
- access_groups=[dict(
- afi="ipv4",
- acls=[dict(
- name="110",
- direction="in"
- ), dict(
- name="123",
- direction="out"
- )]
- ), dict(
- afi="ipv6",
- acls=[dict(
- name="test_v6",
- direction="out"
- ), dict(
- name="temp_v6",
- direction="in"
- )]
- )]
- ), dict(
- name="GigabitEthernet0/2",
- access_groups=[dict(
- afi="ipv4",
- acls=[dict(
- name="110",
- direction="in"
- ), dict(
- name="123",
- direction="out"
- )]
- )]
- )], state="merged"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_ios_acl_interfaces_replaced(self):
- set_module_args(dict(
- config=[dict(
- name="GigabitEthernet0/1",
- access_groups=[dict(
- afi="ipv4",
- acls=[dict(
- name="replace_100",
- direction="out"
- ), dict(
- name="110",
- direction="in"
- )]
- )]
- )], state="replaced"
- ))
- commands = ['interface GigabitEthernet0/1',
- 'no ip access-group 123 out',
- 'no ipv6 traffic-filter temp_v6 in',
- 'no ipv6 traffic-filter test_v6 out',
- 'ip access-group replace_100 out'
- ]
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], commands)
-
- def test_ios_acl_interfaces_replaced_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="GigabitEthernet0/1",
- access_groups=[dict(
- afi="ipv4",
- acls=[dict(
- name="110",
- direction="in"
- ), dict(
- name="123",
- direction="out"
- )]
- ), dict(
- afi="ipv6",
- acls=[dict(
- name="test_v6",
- direction="out"
- ), dict(
- name="temp_v6",
- direction="in"
- )]
- )]
- )], state="replaced"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_ios_acl_interfaces_overridden(self):
- set_module_args(dict(
- config=[dict(
- name="GigabitEthernet0/1",
- access_groups=[dict(
- afi="ipv4",
- acls=[dict(
- name="100",
- direction="out"
- ), dict(
- name="110",
- direction="in"
- )]
- )]
- )], state="overridden"
- ))
-
- commands = [
- 'interface GigabitEthernet0/1',
- 'no ip access-group 123 out',
- 'no ipv6 traffic-filter test_v6 out',
- 'no ipv6 traffic-filter temp_v6 in',
- 'ip access-group 100 out',
- 'interface GigabitEthernet0/2',
- 'no ip access-group 110 in',
- 'no ip access-group 123 out'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_acl_interfaces_overridden_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="GigabitEthernet0/1",
- access_groups=[dict(
- afi="ipv4",
- acls=[dict(
- name="110",
- direction="in"
- ), dict(
- name="123",
- direction="out"
- )]
- ), dict(
- afi="ipv6",
- acls=[dict(
- name="test_v6",
- direction="out"
- ), dict(
- name="temp_v6",
- direction="in"
- )]
- )]
- ), dict(
- name="GigabitEthernet0/2",
- access_groups=[dict(
- afi="ipv4",
- acls=[dict(
- name="110",
- direction="in"
- ), dict(
- name="123",
- direction="out"
- )]
- )]
- )], state="overridden"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_ios_acl_interfaces_deleted_interface(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/1")
- ], state="deleted"))
- commands = ['interface GigabitEthernet0/1',
- 'no ip access-group 110 in',
- 'no ip access-group 123 out',
- 'no ipv6 traffic-filter test_v6 out',
- 'no ipv6 traffic-filter temp_v6 in',
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_acl_interfaces_deleted_afi(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/1",
- access_groups=[
- dict(afi="ipv6")])
- ], state="deleted"))
- commands = ['interface GigabitEthernet0/1',
- 'no ipv6 traffic-filter test_v6 out',
- 'no ipv6 traffic-filter temp_v6 in',
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_acl_interfaces_parsed(self):
- set_module_args(
- dict(
- running_config="interface GigabitEthernet0/1\nip access-group 110 in\nipv6 traffic-filter test_v6 out",
- state="parsed"
- )
- )
- result = self.execute_module(changed=False)
- parsed_list = [
- {'access_groups':
- [
- {'acls':
- [
- {'direction': 'in', 'name': '110'}
- ], 'afi': 'ipv4'},
- {'acls':
- [
- {'direction': 'out', 'name': 'test_v6'}
- ],
- 'afi': 'ipv6'}
- ],
- 'name': 'GigabitEthernet0/1'}]
- self.assertEqual(parsed_list, result['parsed'])
-
- def test_ios_acl_interfaces_rendered(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/1",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="110",
- direction="in"),
- dict(name="123",
- direction="out")
- ]),
- dict(afi="ipv6",
- acls=[
- dict(name="temp_v6", direction="in"),
- dict(name="test_v6", direction="out")
- ])
- ])
- ], state="rendered"))
- commands = ['interface GigabitEthernet0/1',
- 'ip access-group 110 in',
- 'ip access-group 123 out',
- 'ipv6 traffic-filter temp_v6 in',
- 'ipv6 traffic-filter test_v6 out'
- ]
- result = self.execute_module(changed=False)
- self.assertEqual(sorted(result['rendered']), commands)
diff --git a/test/units/modules/network/ios/test_ios_acls.py b/test/units/modules/network/ios/test_ios_acls.py
deleted file mode 100644
index 3dc7ee6aa2..0000000000
--- a/test/units/modules/network/ios/test_ios_acls.py
+++ /dev/null
@@ -1,451 +0,0 @@
-#
-# (c) 2019, Ansible by Red Hat, inc
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import sys
-
-import pytest
-
-# These tests and/or the module under test are unstable on Python 3.5.
-# See: https://app.shippable.com/github/ansible/ansible/runs/161331/15/tests
-# This is most likely due to CPython 3.5 not maintaining dict insertion order.
-pytestmark = pytest.mark.skipif(sys.version_info[:2] == (3, 5), reason="Tests and/or module are unstable on Python 3.5.")
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_acls
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosAclsModule(TestIosModule):
- module = ios_acls
-
- def setUp(self):
- super(TestIosAclsModule, self).setUp()
-
- self.mock_get_config = patch('ansible.module_utils.network.common.network.Config.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.module_utils.network.common.network.Config.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_get_resource_connection_config = patch('ansible.module_utils.network.common.cfg.base.'
- 'get_resource_connection')
- self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
-
- self.mock_get_resource_connection_facts = patch('ansible.module_utils.network.common.facts.facts.'
- 'get_resource_connection')
- self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
-
- self.mock_edit_config = patch('ansible.module_utils.network.ios.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.ios.facts.acls.acls.'
- 'AclsFacts.get_acl_data')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestIosAclsModule, self).tearDown()
- self.mock_get_resource_connection_config.stop()
- self.mock_get_resource_connection_facts.stop()
- self.mock_edit_config.stop()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_execute_show_command.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- def load_from_file(*args, **kwargs):
- return load_fixture('ios_acls_config.cfg')
- self.execute_show_command.side_effect = load_from_file
-
- def test_ios_acls_merged(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="std_acl",
- acl_type="standard",
- aces=[
- dict(
- grant="deny",
- source=dict(
- address="192.0.2.0",
- wildcard_bits="0.0.0.255"
- )
- )
- ])
- ]),
- dict(afi="ipv6",
- acls=[
- dict(name="merge_v6_acl",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(
- tcp=dict(ack="true")
- ),
- source=dict(
- any="true",
- port_protocol=dict(eq="www")
- ),
- destination=dict(
- any="true",
- port_protocol=dict(eq="telnet")),
- dscp="af11"
- )
- ])
- ])
- ], state="merged"
- )
- )
- result = self.execute_module(changed=True)
- commands = [
- 'ip access-list standard std_acl',
- 'deny 192.0.2.0 0.0.0.255',
- 'ipv6 access-list merge_v6_acl',
- 'deny tcp any eq www any eq telnet ack dscp af11'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_acls_merged_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="110",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(
- icmp=dict(echo="true")
- ),
- source=dict(
- address="192.0.2.0",
- wildcard_bits="0.0.0.255"
- ),
- destination=dict(
- address="192.0.3.0",
- wildcard_bits="0.0.0.255"
- ),
- dscp="ef",
- ttl=dict(eq=10)
- )
- ])
- ]),
- dict(afi="ipv6",
- acls=[
- dict(name="R1_TRAFFIC",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(tcp=dict(ack="true")),
- source=dict(
- any="true",
- port_protocol=dict(eq="www")
- ),
- destination=dict(
- any="true",
- port_protocol=dict(eq="telnet")
- ),
- dscp="af11"
- )
- ])
- ])
- ], state="merged"
- ))
- self.execute_module(changed=False, commands=[], sort=True)
-
- def test_ios_acls_replaced(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="replace_acl",
- acl_type="extended",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(
- tcp=dict(ack="true")
- ),
- source=dict(
- address="198.51.100.0",
- wildcard_bits="0.0.0.255"
- ),
- destination=dict(
- address="198.51.101.0",
- wildcard_bits="0.0.0.255",
- port_protocol=dict(eq="telnet")
- ),
- tos=dict(service_value=12)
- )
- ])
- ])
- ], state="replaced"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'ip access-list extended replace_acl',
- 'deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_acls_replaced_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="110",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(
- icmp=dict(echo="true")
- ),
- source=dict(
- address="192.0.2.0",
- wildcard_bits="0.0.0.255"
- ),
- destination=dict(
- address="192.0.3.0",
- wildcard_bits="0.0.0.255"
- ),
- dscp="ef",
- ttl=dict(eq=10)
- )
- ])
- ])
- ], state="replaced"
- ))
- self.execute_module(changed=False, commands=[], sort=True)
-
- def test_ios_acls_overridden(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="150",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(
- tcp=dict(syn="true")
- ),
- source=dict(
- address="198.51.100.0",
- wildcard_bits="0.0.0.255",
- port_protocol=dict(eq="telnet")
- ),
- destination=dict(
- address="198.51.110.0",
- wildcard_bits="0.0.0.255",
- port_protocol=dict(eq="telnet")
- ),
- dscp="ef",
- ttl=dict(eq=10)
- )
- ])
- ])
- ], state="overridden"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'no ip access-list extended 110',
- 'no ipv6 access-list R1_TRAFFIC',
- 'ip access-list extended 150',
- 'deny tcp 198.51.100.0 0.0.0.255 eq telnet 198.51.110.0 0.0.0.255 eq telnet syn dscp ef ttl eq 10'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_acls_overridden_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="110",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(
- icmp=dict(echo="true")
- ),
- source=dict(
- address="192.0.2.0",
- wildcard_bits="0.0.0.255"
- ),
- destination=dict(
- address="192.0.3.0",
- wildcard_bits="0.0.0.255"
- ),
- dscp="ef",
- ttl=dict(eq=10)
- )
- ])
- ]),
- dict(afi="ipv6",
- acls=[
- dict(name="R1_TRAFFIC",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(tcp=dict(ack="true")),
- source=dict(
- any="true",
- port_protocol=dict(eq="www")
- ),
- destination=dict(
- any="true",
- port_protocol=dict(eq="telnet")
- ),
- dscp="af11"
- )
- ])
- ])
- ], state="overridden"
- ))
- self.execute_module(changed=False, commands=[], sort=True)
-
- def test_ios_acls_deleted_afi_based(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4")
- ], state="deleted"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'no ip access-list extended 110'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_acls_deleted_acl_based(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="110",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(
- icmp=dict(echo="true")
- ),
- source=dict(
- address="192.0.2.0",
- wildcard_bits="0.0.0.255"
- ),
- destination=dict(
- address="192.0.3.0",
- wildcard_bits="0.0.0.255"
- ),
- dscp="ef",
- ttl=dict(eq=10)
- )
- ])
- ]),
- dict(afi="ipv6",
- acls=[
- dict(name="R1_TRAFFIC",
- aces=[
- dict(
- grant="deny",
- protocol_options=dict(tcp=dict(ack="true")),
- source=dict(
- any="true",
- port_protocol=dict(eq="www")
- ),
- destination=dict(
- any="true",
- port_protocol=dict(eq="telnet")
- ),
- dscp="af11"
- )
- ])
- ])
- ], state="deleted"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'no ip access-list extended 110',
- 'no ipv6 access-list R1_TRAFFIC',
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_acls_rendered(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="110",
- aces=[
- dict(
- grant="deny",
- sequence="10",
- protocol_options=dict(
- tcp=dict(syn="true")
- ),
- source=dict(
- address="192.0.2.0",
- wildcard_bits="0.0.0.255"
- ),
- destination=dict(
- address="192.0.3.0",
- wildcard_bits="0.0.0.255",
- port_protocol=dict(eq="www")
- ),
- dscp="ef",
- ttl=dict(eq=10)
- )
- ])
- ])
- ], state="rendered"))
- commands = [
- 'ip access-list extended 110',
- '10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www syn dscp ef ttl eq 10'
- ]
- result = self.execute_module(changed=False)
- self.assertEqual(result['rendered'], commands)
-
- def test_ios_acls_parsed(self):
- set_module_args(
- dict(running_config="ipv6 access-list R1_TRAFFIC\ndeny tcp any eq www any eq telnet ack dscp af11",
- state="parsed"))
- result = self.execute_module(changed=False)
- parsed_list = [
- {
- "acls": [
- {
- "aces": [
- {
- "destination": {
- "any": True,
- "port_protocol": {
- "eq": "telnet"
- }
- },
- "dscp": "af11",
- "grant": "deny",
- "protocol": "tcp",
- "protocol_options": {
- "tcp": {
- "ack": True
- }
- },
- "source": {
- "any": True,
- "port_protocol": {
- "eq": "www"
- }
- }
- }
- ],
- "name": "R1_TRAFFIC"
- }
- ],
- "afi": "ipv6"
- }
- ]
- self.assertEqual(parsed_list, result['parsed'])
diff --git a/test/units/modules/network/ios/test_ios_banner.py b/test/units/modules/network/ios/test_ios_banner.py
deleted file mode 100644
index cdd43d8e79..0000000000
--- a/test/units/modules/network/ios/test_ios_banner.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_banner
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosBannerModule(TestIosModule):
-
- module = ios_banner
-
- def setUp(self):
- super(TestIosBannerModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_banner.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios.ios_banner.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestIosBannerModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
-
- def load_fixtures(self, commands=None):
- def load_from_file(*args, **kwargs):
- return load_fixture('ios_banner_show_running_config_ios12.txt')
- self.get_config.side_effect = load_from_file
-
- def test_ios_banner_create(self):
- for banner_type in ('login', 'motd', 'exec', 'incoming', 'slip-ppp'):
- set_module_args(dict(banner=banner_type, text='test\nbanner\nstring'))
- commands = ['banner {0} @\ntest\nbanner\nstring\n@'.format(banner_type)]
- self.execute_module(changed=True, commands=commands)
-
- 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_banner_nochange(self):
- banner_text = load_fixture('ios_banner_show_banner.txt')
- set_module_args(dict(banner='login', text=banner_text))
- self.execute_module()
-
-
-class TestIosBannerIos12Module(TestIosBannerModule):
-
- def load_fixtures(self, commands=None):
- def load_from_file(*args, **kwargs):
- return load_fixture('ios_banner_show_running_config_ios12.txt')
- self.get_config.side_effect = load_from_file
-
- 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()
diff --git a/test/units/modules/network/ios/test_ios_bgp.py b/test/units/modules/network/ios/test_ios_bgp.py
deleted file mode 100644
index 792219778c..0000000000
--- a/test/units/modules/network/ios/test_ios_bgp.py
+++ /dev/null
@@ -1,207 +0,0 @@
-#
-# (c) 2019, Ansible by Red Hat, inc
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from ansible.module_utils.network.ios.providers.cli.config.bgp.process import Provider
-from ansible.modules.network.ios import ios_bgp
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosBgpModule(TestIosModule):
- module = ios_bgp
-
- def setUp(self):
- super(TestIosBgpModule, self).setUp()
- self._bgp_config = load_fixture('ios_bgp_config.cfg')
-
- def test_ios_bgp(self):
- obj = Provider(params=dict(config=dict(bgp_as=64496, router_id='192.0.2.2', networks=None,
- address_family=None), operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, ['router bgp 64496', 'bgp router-id 192.0.2.2', 'exit'])
-
- def test_ios_bgp_idempotent(self):
- obj = Provider(params=dict(config=dict(bgp_as=64496, router_id='192.0.2.1', networks=None,
- address_family=None), operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_ios_bgp_remove(self):
- obj = Provider(params=dict(config=dict(bgp_as=64496, networks=None, address_family=None), operation='delete'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, ['no router bgp 64496'])
-
- def test_ios_bgp_neighbor(self):
- obj = Provider(params=dict(config=dict(bgp_as=64496, neighbors=[dict(neighbor='192.51.100.2', remote_as=64496)],
- networks=None, address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, ['router bgp 64496', 'neighbor 192.51.100.2 remote-as 64496', 'exit'])
-
- def test_ios_bgp_neighbor_idempotent(self):
- obj = Provider(params=dict(config=dict(bgp_as=64496, neighbors=[dict(neighbor='192.51.100.1', remote_as=64496,
- timers=dict(keepalive=120, holdtime=360,
- min_neighbor_holdtime=360))],
- networks=None, address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_ios_bgp_network(self):
- obj = Provider(params=dict(config=dict(bgp_as=64496, networks=[dict(prefix='192.0.1.0', masklen=23, route_map='RMAP_1')],
- address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(sorted(commands), sorted(['router bgp 64496', 'network 192.0.1.0 mask 255.255.254.0 route-map RMAP_1',
- 'exit']))
-
- def test_ios_bgp_network_idempotent(self):
- obj = Provider(
- params=dict(config=dict(bgp_as=64496, networks=[dict(prefix='192.0.2.0', masklen=23, route_map='RMAP_1'),
- dict(prefix='198.51.100.0', masklen=25,
- route_map='RMAP_2')],
- address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_ios_bgp_address_family_redistribute(self):
- rd_1 = dict(protocol='ospf', id='233', metric=90, route_map=None)
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', safi='unicast', redistribute=[rd_1])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- cmd = ['router bgp 64496', 'address-family ipv4', 'redistribute ospf 233 metric 90',
- 'exit-address-family', 'exit']
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_ios_bgp_address_family_redistribute_idempotent(self):
- rd_1 = dict(protocol='eigrp', metric=10, route_map='RMAP_3', id=None)
- rd_2 = dict(protocol='static', metric=100, id=None, route_map=None)
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', safi='unicast', redistribute=[rd_1, rd_2])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_ios_bgp_address_family_neighbors(self):
- af_nbr_1 = dict(neighbor='192.51.100.1', maximum_prefix=35, activate=True)
- af_nbr_2 = dict(neighbor='192.51.100.3', route_reflector_client=True, activate=True)
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', safi='multicast', neighbors=[af_nbr_1, af_nbr_2])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- cmd = ['router bgp 64496', 'address-family ipv4 multicast', 'neighbor 192.51.100.1 activate',
- 'neighbor 192.51.100.1 maximum-prefix 35', 'neighbor 192.51.100.3 activate',
- 'neighbor 192.51.100.3 route-reflector-client', 'exit-address-family', 'exit']
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_ios_bgp_address_family_neighbors_idempotent(self):
- af_nbr_1 = dict(neighbor='203.0.113.1', remove_private_as=True, maximum_prefix=100)
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', safi='unicast', neighbors=[af_nbr_1])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_ios_bgp_address_family_networks(self):
- net = dict(prefix='1.0.0.0', masklen=8, route_map='RMAP_1')
- net2 = dict(prefix='192.168.1.0', masklen=24, route_map='RMAP_2')
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', safi='multicast', networks=[net, net2])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- cmd = ['router bgp 64496', 'address-family ipv4 multicast', 'network 1.0.0.0 mask 255.0.0.0 route-map RMAP_1',
- 'network 192.168.1.0 mask 255.255.255.0 route-map RMAP_2', 'exit-address-family', 'exit']
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_ios_bgp_address_family_networks_idempotent(self):
- net = dict(prefix='203.0.113.0', masklen=27, route_map='RMAP_1')
- net2 = dict(prefix='192.0.2.0', masklen=26, route_map='RMAP_2')
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', safi='multicast', networks=[net, net2])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_ios_bgp_operation_override(self):
- net_1 = dict(prefix='1.0.0.0', masklen=8, route_map='RMAP_1')
- net_2 = dict(prefix='192.168.1.0', masklen=24, route_map='RMAP_2')
- nbr_1 = dict(neighbor='192.51.100.1', remote_as=64496, update_source='GigabitEthernet0/1')
- nbr_2 = dict(neighbor='192.51.100.3', remote_as=64496, timers=dict(keepalive=300, holdtime=360,
- min_neighbor_holdtime=360))
- af_nbr_1 = dict(neighbor='192.51.100.1', maximum_prefix=35)
- af_nbr_2 = dict(neighbor='192.51.100.3', route_reflector_client=True)
-
- af_1 = dict(afi='ipv4', safi='unicast', neighbors=[af_nbr_1, af_nbr_2])
- af_2 = dict(afi='ipv4', safi='multicast', networks=[net_1, net_2])
- config = dict(bgp_as=64496, neighbors=[nbr_1, nbr_2], address_family=[af_1, af_2], networks=None)
-
- obj = Provider(params=dict(config=config, operation='override'))
- commands = obj.render(self._bgp_config)
-
- cmd = ['no router bgp 64496', 'router bgp 64496', 'neighbor 192.51.100.1 remote-as 64496',
- 'neighbor 192.51.100.1 update-source GigabitEthernet0/1', 'neighbor 192.51.100.3 remote-as 64496',
- 'neighbor 192.51.100.3 timers 300 360 360', 'address-family ipv4',
- 'neighbor 192.51.100.1 maximum-prefix 35', 'neighbor 192.51.100.3 route-reflector-client',
- 'exit-address-family',
- 'address-family ipv4 multicast', 'network 1.0.0.0 mask 255.0.0.0 route-map RMAP_1',
- 'network 192.168.1.0 mask 255.255.255.0 route-map RMAP_2',
- 'exit-address-family', 'exit']
-
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_ios_bgp_operation_replace(self):
- rd = dict(protocol='ospf', id=223, metric=110, route_map=None)
- net = dict(prefix='203.0.113.0', masklen=27, route_map='RMAP_1')
- net2 = dict(prefix='192.0.2.0', masklen=26, route_map='RMAP_2')
-
- af_1 = dict(afi='ipv4', safi='unicast', redistribute=[rd])
- af_2 = dict(afi='ipv4', safi='multicast', networks=[net, net2])
-
- config = dict(bgp_as=64496, address_family=[af_1, af_2], networks=None)
- obj = Provider(params=dict(config=config, operation='replace'))
- commands = obj.render(self._bgp_config)
-
- cmd = ['router bgp 64496', 'address-family ipv4', 'redistribute ospf 223 metric 110',
- 'no redistribute eigrp',
- 'no redistribute static', 'exit-address-family', 'exit']
-
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_ios_bgp_operation_replace_with_new_as(self):
- rd = dict(protocol='ospf', id=223, metric=110, route_map=None)
-
- af_1 = dict(afi='ipv4', safi='unicast', redistribute=[rd])
-
- config = dict(bgp_as=64497, address_family=[af_1], networks=None)
- obj = Provider(params=dict(config=config, operation='replace'))
- commands = obj.render(self._bgp_config)
-
- cmd = ['no router bgp 64496', 'router bgp 64497', 'address-family ipv4',
- 'redistribute ospf 223 metric 110',
- 'exit-address-family', 'exit']
-
- self.assertEqual(sorted(commands), sorted(cmd))
diff --git a/test/units/modules/network/ios/test_ios_command.py b/test/units/modules/network/ios/test_ios_command.py
deleted file mode 100644
index 1dab227b9a..0000000000
--- a/test/units/modules/network/ios/test_ios_command.py
+++ /dev/null
@@ -1,126 +0,0 @@
-# (c) 2016 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import json
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_command
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosCommandModule(TestIosModule):
-
- module = ios_command
-
- def setUp(self):
- super(TestIosCommandModule, self).setUp()
-
- self.mock_run_commands = patch('ansible.modules.network.ios.ios_command.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- def tearDown(self):
- super(TestIosCommandModule, self).tearDown()
- self.mock_run_commands.stop()
-
- def load_fixtures(self, commands=None):
-
- def load_from_file(*args, **kwargs):
- module, commands = args
- output = list()
-
- for item in commands:
- try:
- obj = json.loads(item['command'])
- command = obj['command']
- except ValueError:
- command = item['command']
- filename = str(command).replace(' ', '_')
- output.append(load_fixture(filename))
- return output
-
- self.run_commands.side_effect = load_from_file
-
- def test_ios_command_simple(self):
- set_module_args(dict(commands=['show version']))
- result = self.execute_module()
- self.assertEqual(len(result['stdout']), 1)
- self.assertTrue(result['stdout'][0].startswith('Cisco IOS Software'))
-
- def test_ios_command_multiple(self):
- set_module_args(dict(commands=['show version', 'show version']))
- result = self.execute_module()
- self.assertEqual(len(result['stdout']), 2)
- self.assertTrue(result['stdout'][0].startswith('Cisco IOS Software'))
-
- def test_ios_command_wait_for(self):
- wait_for = 'result[0] contains "Cisco IOS"'
- set_module_args(dict(commands=['show version'], wait_for=wait_for))
- self.execute_module()
-
- def test_ios_command_wait_for_fails(self):
- wait_for = 'result[0] contains "test string"'
- set_module_args(dict(commands=['show version'], wait_for=wait_for))
- self.execute_module(failed=True)
- self.assertEqual(self.run_commands.call_count, 10)
-
- def test_ios_command_retries(self):
- wait_for = 'result[0] contains "test string"'
- set_module_args(dict(commands=['show version'], wait_for=wait_for, retries=2))
- self.execute_module(failed=True)
- self.assertEqual(self.run_commands.call_count, 2)
-
- def test_ios_command_match_any(self):
- wait_for = ['result[0] contains "Cisco IOS"',
- 'result[0] contains "test string"']
- set_module_args(dict(commands=['show version'], wait_for=wait_for, match='any'))
- self.execute_module()
-
- def test_ios_command_match_all(self):
- wait_for = ['result[0] contains "Cisco IOS"',
- 'result[0] contains "IOSv Software"']
- set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all'))
- self.execute_module()
-
- def test_ios_command_match_all_failure(self):
- wait_for = ['result[0] contains "Cisco IOS"',
- 'result[0] contains "test string"']
- commands = ['show version', 'show version']
- set_module_args(dict(commands=commands, wait_for=wait_for, match='all'))
- self.execute_module(failed=True)
-
- def test_ios_command_configure_check_warning(self):
- commands = ['configure terminal']
- set_module_args({
- 'commands': commands,
- '_ansible_check_mode': True,
- })
- result = self.execute_module()
- self.assertEqual(
- result['warnings'],
- ['Only show commands are supported when using check mode, not executing configure terminal'],
- )
-
- def test_ios_command_configure_not_warning(self):
- commands = ['configure terminal']
- set_module_args(dict(commands=commands))
- result = self.execute_module()
- self.assertEqual(result['warnings'], [])
diff --git a/test/units/modules/network/ios/test_ios_config.py b/test/units/modules/network/ios/test_ios_config.py
deleted file mode 100644
index 0aa4dcc90b..0000000000
--- a/test/units/modules/network/ios/test_ios_config.py
+++ /dev/null
@@ -1,250 +0,0 @@
-#
-# (c) 2016 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch, MagicMock
-from ansible.modules.network.ios import ios_config
-from ansible.plugins.cliconf.ios import Cliconf
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosConfigModule(TestIosModule):
-
- module = ios_config
-
- def setUp(self):
- super(TestIosConfigModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_config.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_get_connection = patch('ansible.modules.network.ios.ios_config.get_connection')
- self.get_connection = self.mock_get_connection.start()
-
- self.conn = self.get_connection()
- self.conn.edit_config = MagicMock()
-
- self.mock_run_commands = patch('ansible.modules.network.ios.ios_config.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- self.cliconf_obj = Cliconf(MagicMock())
- self.running_config = load_fixture('ios_config_config.cfg')
-
- def tearDown(self):
- super(TestIosConfigModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_run_commands.stop()
- self.mock_get_connection.stop()
-
- def load_fixtures(self, commands=None):
- config_file = 'ios_config_config.cfg'
- self.get_config.return_value = load_fixture(config_file)
- self.get_connection.edit_config.return_value = None
-
- def test_ios_config_unchanged(self):
- src = load_fixture('ios_config_config.cfg')
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(src, src))
- set_module_args(dict(src=src))
- self.execute_module()
-
- def test_ios_config_src(self):
- src = load_fixture('ios_config_src.cfg')
- set_module_args(dict(src=src))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(src, self.running_config))
- commands = ['hostname foo', 'interface GigabitEthernet0/0',
- 'no ip address']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_config_backup(self):
- set_module_args(dict(backup=True))
- result = self.execute_module()
- self.assertIn('__backup__', result)
-
- def test_ios_config_save_changed_true(self):
- src = load_fixture('ios_config_src.cfg')
- set_module_args(dict(src=src, save_when='changed'))
- commands = ['hostname foo', 'interface GigabitEthernet0/0', 'no ip address']
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(src, self.running_config))
- self.execute_module(changed=True, commands=commands)
- self.assertEqual(self.run_commands.call_count, 1)
- self.assertEqual(self.get_config.call_count, 1)
- self.assertEqual(self.conn.edit_config.call_count, 1)
- args = self.run_commands.call_args[0][1]
- self.assertIn('copy running-config startup-config\r', args)
-
- def test_ios_config_save_changed_false(self):
- set_module_args(dict(save_when='changed'))
- self.execute_module(changed=False)
- self.assertEqual(self.run_commands.call_count, 0)
- self.assertEqual(self.get_config.call_count, 0)
- self.assertEqual(self.conn.edit_config.call_count, 0)
-
- def test_ios_config_save_always(self):
- self.run_commands.return_value = "hostname foo"
- set_module_args(dict(save_when='always'))
- self.execute_module(changed=True)
- self.assertEqual(self.run_commands.call_count, 1)
- self.assertEqual(self.get_config.call_count, 0)
- self.assertEqual(self.conn.edit_config.call_count, 0)
- args = self.run_commands.call_args[0][1]
- self.assertIn('copy running-config startup-config\r', args)
-
- def test_ios_config_lines_wo_parents(self):
- lines = ['hostname foo']
- set_module_args(dict(lines=lines))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- commands = ['hostname foo']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_config_lines_w_parents(self):
- lines = ['shutdown']
- parents = ['interface GigabitEthernet0/0']
- set_module_args(dict(lines=lines, parents=parents))
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = ios_config.get_candidate_config(module)
-
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config))
-
- commands = ['interface GigabitEthernet0/0', 'shutdown']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_config_before(self):
- lines = ['hostname foo']
- set_module_args(dict(lines=lines, before=['test1', 'test2']))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- commands = ['test1', 'test2', 'hostname foo']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_config_after(self):
- lines = ['hostname foo']
- set_module_args(dict(lines=lines, after=['test1', 'test2']))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- commands = ['hostname foo', 'test1', 'test2']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_config_before_after_no_change(self):
- lines = ['hostname router']
- set_module_args(dict(lines=lines,
- before=['test1', 'test2'],
- after=['test3', 'test4']))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- self.execute_module()
-
- def test_ios_config_config(self):
- config = 'hostname localhost'
- lines = ['hostname router']
- set_module_args(dict(lines=lines, config=config))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), config))
- commands = ['hostname router']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_config_replace_block(self):
- lines = ['description test string', 'test string']
- parents = ['interface GigabitEthernet0/0']
- set_module_args(dict(lines=lines, replace='block', parents=parents))
-
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = ios_config.get_candidate_config(module)
-
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_replace='block', path=parents))
-
- commands = parents + lines
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_config_match_none(self):
- lines = ['hostname router']
- set_module_args(dict(lines=lines, match='none'))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config, diff_match='none'))
- self.execute_module(changed=True, commands=lines)
-
- def test_ios_config_match_none2(self):
- lines = ['ip address 1.2.3.4 255.255.255.0', 'description test string']
- parents = ['interface GigabitEthernet0/0']
- set_module_args(dict(lines=lines, parents=parents, match='none'))
-
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = ios_config.get_candidate_config(module)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_match='none', path=parents))
-
- commands = parents + lines
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_config_match_strict(self):
- lines = ['ip address 1.2.3.4 255.255.255.0', 'description test string',
- 'shutdown']
- parents = ['interface GigabitEthernet0/0']
- set_module_args(dict(lines=lines, parents=parents, match='strict'))
-
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = ios_config.get_candidate_config(module)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_match='strict', path=parents))
-
- commands = parents + ['shutdown']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_config_match_exact(self):
- lines = ['ip address 1.2.3.4 255.255.255.0', 'description test string',
- 'shutdown']
- parents = ['interface GigabitEthernet0/0']
- set_module_args(dict(lines=lines, parents=parents, match='exact'))
-
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = ios_config.get_candidate_config(module)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_match='exact', path=parents))
-
- commands = parents + lines
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_config_src_and_lines_fails(self):
- args = dict(src='foo', lines='foo')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_ios_config_src_and_parents_fails(self):
- args = dict(src='foo', parents='foo')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_ios_config_match_exact_requires_lines(self):
- args = dict(match='exact')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_ios_config_match_strict_requires_lines(self):
- args = dict(match='strict')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_ios_config_replace_block_requires_lines(self):
- args = dict(replace='block')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_ios_config_replace_config_requires_src(self):
- args = dict(replace='config')
- set_module_args(args)
- self.execute_module(failed=True)
diff --git a/test/units/modules/network/ios/test_ios_facts.py b/test/units/modules/network/ios/test_ios_facts.py
deleted file mode 100644
index e197fe5995..0000000000
--- a/test/units/modules/network/ios/test_ios_facts.py
+++ /dev/null
@@ -1,123 +0,0 @@
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_facts
-from ansible.module_utils.six import assertCountEqual
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosFactsModule(TestIosModule):
-
- module = ios_facts
-
- def setUp(self):
- super(TestIosFactsModule, self).setUp()
- self.mock_run_commands = patch('ansible.module_utils.network.ios.facts.legacy.base.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- self.mock_get_resource_connection = patch('ansible.module_utils.network.common.facts.facts.get_resource_connection')
- self.get_resource_connection = self.mock_get_resource_connection.start()
-
- self.mock_get_capabilities = patch('ansible.module_utils.network.ios.facts.legacy.base.get_capabilities')
- self.get_capabilities = self.mock_get_capabilities.start()
- self.get_capabilities.return_value = {
- 'device_info': {
- 'network_os': 'ios',
- 'network_os_hostname': 'an-ios-01',
- 'network_os_image': 'flash0:/vios-adventerprisek9-m',
- 'network_os_model': 'WS-C3750-24TS',
- 'network_os_version': '15.6(3)M2'
- },
- 'network_api': 'cliconf'
- }
-
- def tearDown(self):
- super(TestIosFactsModule, self).tearDown()
- self.mock_run_commands.stop()
- self.mock_get_capabilities.stop()
-
- def load_fixtures(self, commands=None):
- def load_from_file(*args, **kwargs):
- commands = kwargs['commands']
- output = list()
-
- for command in commands:
- filename = str(command).split(' | ')[0].replace(' ', '_')
- output.append(load_fixture('ios_facts_%s' % filename))
- return output
-
- self.run_commands.side_effect = load_from_file
-
- def test_ios_facts_stacked(self):
- set_module_args(dict(gather_subset='default'))
- result = self.execute_module()
- self.assertEqual(
- result['ansible_facts']['ansible_net_model'], 'WS-C3750-24TS'
- )
- self.assertEqual(
- result['ansible_facts']['ansible_net_serialnum'], 'CAT0726R0ZU'
- )
- self.assertEqual(
- result['ansible_facts']['ansible_net_stacked_models'], ['WS-C3750-24TS-E', 'WS-C3750-24TS-E', 'WS-C3750G-12S-E']
- )
- self.assertEqual(
- result['ansible_facts']['ansible_net_stacked_serialnums'], ['CAT0726R0ZU', 'CAT0726R10A', 'CAT0732R0M4']
- )
-
- def test_ios_facts_tunnel_address(self):
- set_module_args(dict(gather_subset='interfaces'))
- result = self.execute_module()
- self.assertEqual(
- result['ansible_facts']['ansible_net_interfaces']['GigabitEthernet0/0']['macaddress'], '5e00.0003.0000'
- )
- self.assertEqual(
- result['ansible_facts']['ansible_net_interfaces']['GigabitEthernet1']['macaddress'], '5e00.0006.0000'
- )
- self.assertIsNone(
- result['ansible_facts']['ansible_net_interfaces']['Tunnel1110']['macaddress']
- )
-
- def test_ios_facts_filesystems_info(self):
- set_module_args(dict(gather_subset='hardware'))
- result = self.execute_module()
- self.assertEqual(
- result['ansible_facts']['ansible_net_filesystems_info']['bootflash:']['spacetotal_kb'], 7712692.0
- )
- self.assertEqual(
- result['ansible_facts']['ansible_net_filesystems_info']['bootflash:']['spacefree_kb'], 6453180.0
- )
-
- def test_ios_facts_neighbors(self):
- set_module_args(dict(gather_subset='interfaces'))
- result = self.execute_module()
- assertCountEqual(
- self,
- result['ansible_facts']['ansible_net_neighbors'].keys(), ['GigabitEthernet1', 'GigabitEthernet3']
- )
- assertCountEqual(
- self,
- result['ansible_facts']['ansible_net_neighbors']['GigabitEthernet1'],
- [{'host': 'R2', 'port': 'GigabitEthernet2'}, {'host': 'R3', 'port': 'GigabitEthernet3'}]
- )
- assertCountEqual(
- self,
- result['ansible_facts']['ansible_net_neighbors']['GigabitEthernet3'], [{'host': 'Rtest', 'port': 'Gi1'}]
- )
diff --git a/test/units/modules/network/ios/test_ios_logging.py b/test/units/modules/network/ios/test_ios_logging.py
deleted file mode 100644
index c54f4a6eb6..0000000000
--- a/test/units/modules/network/ios/test_ios_logging.py
+++ /dev/null
@@ -1,140 +0,0 @@
-#
-# (c) 2016 Red Hat Inc.
-# (c) 2017 Paul Neumann
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_logging
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosLoggingModule(TestIosModule):
-
- module = ios_logging
-
- def setUp(self):
- super(TestIosLoggingModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_logging.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios.ios_logging.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_get_capabilities = patch('ansible.modules.network.ios.ios_logging.get_capabilities')
- self.get_capabilities = self.mock_get_capabilities.start()
- self.get_capabilities.return_value = {'device_info': {'network_os_version': '15.6(2)T'}}
-
- def tearDown(self):
- super(TestIosLoggingModule, self).tearDown()
-
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_get_capabilities.stop()
-
- def load_fixtures(self, commands=None):
- self.get_config.return_value = load_fixture('ios_logging_config.cfg')
- self.load_config.return_value = None
-
- def test_ios_logging_buffer_size_changed_implicit(self):
- set_module_args(dict(dest='buffered'))
- commands = ['logging buffered 4096']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_logging_buffer_size_changed_explicit(self):
- set_module_args(dict(dest='buffered', size=6000))
- commands = ['logging buffered 6000']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_logging_add_host(self):
- set_module_args(dict(dest='host', name='192.168.1.1'))
- commands = ['logging host 192.168.1.1']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_logging_host_idempotent(self):
- set_module_args(dict(dest='host', name='2.3.4.5'))
- commands = []
- self.execute_module(changed=False, commands=commands)
-
- def test_ios_logging_delete_non_exist_host(self):
- set_module_args(dict(dest='host', name='192.168.1.1', state='absent'))
- commands = []
- self.execute_module(changed=False, commands=commands)
-
- def test_ios_logging_delete_host(self):
- set_module_args(dict(dest='host', name='2.3.4.5', state='absent'))
- commands = ['no logging host 2.3.4.5']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_logging_configure_disabled_monitor_destination(self):
- set_module_args(dict(dest='monitor', level='debugging'))
- commands = ['logging monitor debugging']
- self.execute_module(changed=True, commands=commands)
-
-
-class TestIosLoggingModuleIOS12(TestIosModule):
-
- module = ios_logging
-
- def setUp(self):
- super(TestIosLoggingModuleIOS12, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_logging.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios.ios_logging.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_get_capabilities = patch('ansible.modules.network.ios.ios_logging.get_capabilities')
- self.get_capabilities = self.mock_get_capabilities.start()
- self.get_capabilities.return_value = {'device_info': {'network_os_version': '12.1(2)T'}}
-
- def tearDown(self):
- super(TestIosLoggingModuleIOS12, self).tearDown()
-
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_get_capabilities.stop()
-
- def load_fixtures(self, commands=None):
- self.get_config.return_value = load_fixture('ios_logging_config_ios12.cfg')
- self.load_config.return_value = None
-
- def test_ios_logging_add_host(self):
- set_module_args(dict(dest='host', name='192.168.1.1'))
- commands = ['logging 192.168.1.1']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_logging_host_idempotent(self):
- set_module_args(dict(dest='host', name='2.3.4.5'))
- commands = []
- self.execute_module(changed=False, commands=commands)
-
- def test_ios_logging_delete_non_exist_host(self):
- set_module_args(dict(dest='host', name='192.168.1.1', state='absent'))
- commands = []
- self.execute_module(changed=False, commands=commands)
-
- def test_ios_logging_delete_host(self):
- set_module_args(dict(dest='host', name='2.3.4.5', state='absent'))
- commands = ['no logging 2.3.4.5']
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/ios/test_ios_ntp.py b/test/units/modules/network/ios/test_ios_ntp.py
deleted file mode 100644
index 0d106a75c0..0000000000
--- a/test/units/modules/network/ios/test_ios_ntp.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_ntp
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosNtpModule(TestIosModule):
-
- module = ios_ntp
-
- def setUp(self):
- super(TestIosNtpModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_ntp.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios.ios_ntp.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestIosNtpModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
-
- def load_fixtures(self, commands=None):
- self.get_config.return_value = load_fixture('ios_ntp_config.cfg').strip()
- self.load_config.return_value = dict(diff=None, session='session')
-
- def test_ios_ntp_idempotent(self):
- set_module_args(dict(
- server='10.75.32.5',
- source_int='Loopback0',
- acl='NTP_ACL',
- logging=True,
- auth=True,
- auth_key='15435A030726242723273C21181319000A',
- key_id='10',
- state='present'
- ))
- commands = []
- self.execute_module(changed=False, commands=commands)
-
- def test_ios_ntp_config(self):
- set_module_args(dict(
- server='10.75.33.5',
- source_int='Vlan2',
- acl='NTP_ACL',
- logging=True,
- auth=True,
- auth_key='15435A030726242723273C21181319000A',
- key_id='10',
- state='present'
- ))
- commands = [
- 'ntp server 10.75.33.5',
- 'ntp source Vlan2'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_ntp_remove(self):
- set_module_args(dict(
- server='10.75.32.5',
- source_int='Loopback0',
- acl='NTP_ACL',
- logging=True,
- auth=True,
- auth_key='15435A030726242723273C21181319000A',
- key_id='10',
- state='absent'
- ))
- commands = [
- 'no ntp server 10.75.32.5',
- 'no ntp source Loopback0',
- 'no ntp access-group peer NTP_ACL',
- 'no ntp logging',
- 'no ntp authenticate',
- 'no ntp trusted-key 10',
- 'no ntp authentication-key 10 md5 15435A030726242723273C21181319000A 7'
- ]
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/ios/test_ios_ping.py b/test/units/modules/network/ios/test_ios_ping.py
deleted file mode 100644
index 0bb73bb756..0000000000
--- a/test/units/modules/network/ios/test_ios_ping.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# (c) 2016 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_ping
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosPingModule(TestIosModule):
- ''' Class used for Unit Tests agains ios_ping module '''
- module = ios_ping
-
- def setUp(self):
- super(TestIosPingModule, self).setUp()
- self.mock_run_commands = patch('ansible.modules.network.ios.ios_ping.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- def tearDown(self):
- super(TestIosPingModule, self).tearDown()
- self.mock_run_commands.stop()
-
- def load_fixtures(self, commands=None):
- def load_from_file(*args, **kwargs):
- commands = kwargs['commands']
- output = list()
-
- for command in commands:
- filename = str(command).split(' | ')[0].replace(' ', '_')
- output.append(load_fixture('ios_ping_%s' % filename))
- return output
-
- self.run_commands.side_effect = load_from_file
-
- 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()
-
- 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()
-
- 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)
-
- 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)
diff --git a/test/units/modules/network/ios/test_ios_static_routes.py b/test/units/modules/network/ios/test_ios_static_routes.py
deleted file mode 100644
index 50b0ffa7ec..0000000000
--- a/test/units/modules/network/ios/test_ios_static_routes.py
+++ /dev/null
@@ -1,357 +0,0 @@
-#
-# (c) 2019, Ansible by Red Hat, inc
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-#
-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_static_routes
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosStaticRoutesModule(TestIosModule):
- module = ios_static_routes
-
- def setUp(self):
- super(TestIosStaticRoutesModule, self).setUp()
-
- self.mock_get_config = patch('ansible.module_utils.network.common.network.Config.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.module_utils.network.common.network.Config.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_get_resource_connection_config = patch('ansible.module_utils.network.common.cfg.base.'
- 'get_resource_connection')
- self.get_resource_connection_config = self.mock_get_resource_connection_config.start()
-
- self.mock_get_resource_connection_facts = patch('ansible.module_utils.network.common.facts.facts.'
- 'get_resource_connection')
- self.get_resource_connection_facts = self.mock_get_resource_connection_facts.start()
-
- self.mock_edit_config = patch('ansible.module_utils.network.ios.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.ios.facts.static_routes.static_routes.'
- 'Static_RoutesFacts.get_static_routes_data')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestIosStaticRoutesModule, self).tearDown()
- self.mock_get_resource_connection_config.stop()
- self.mock_get_resource_connection_facts.stop()
- self.mock_edit_config.stop()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_execute_show_command.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- def load_from_file(*args, **kwargs):
- return load_fixture('ios_static_routes_config.cfg')
- self.execute_show_command.side_effect = load_from_file
-
- def test_ios_static_routes_merged(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0 255.255.255.0",
- next_hops=[dict(
- forward_router_address="192.0.2.1",
- name="test_vrf",
- tag=50,
- track=150
- )],
- )],
- )],
- ), dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0 255.255.255.0",
- next_hops=[dict(
- forward_router_address="198.51.101.1",
- name="route_1",
- distance_metric=110,
- tag=40,
- multicast=True
- )],
- )],
- )],
- )], state="merged"
- ))
- result = self.execute_module(changed=True)
- commands = ['ip route vrf ansible_vrf 192.0.2.0 255.255.255.0 192.0.2.1 name test_vrf track 150 tag 50',
- 'ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 multicast name route_1 tag 40'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_static_routes_merged_idempotent(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0/24",
- next_hops=[dict(
- forward_router_address="192.0.2.1",
- name="test_vrf",
- tag=50,
- track=175
- )],
- )],
- )],
- ), dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0/24",
- next_hops=[dict(
- forward_router_address="198.51.101.1",
- name="route_1",
- distance_metric=110,
- tag=60,
- multicast=True
- )],
- )],
- )],
- )], state="merged"
- ))
- self.execute_module(changed=False, commands=[], sort=True)
-
- def test_ios_static_routes_replaced(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0 255.255.255.0",
- next_hops=[dict(
- forward_router_address="192.0.2.1",
- name="replaced_vrf",
- tag=10,
- track=170
- )],
- )],
- )],
- ), dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0 255.255.255.0",
- next_hops=[dict(
- forward_router_address="198.51.101.1",
- name="replaced_route_1",
- distance_metric=110,
- tag=60,
- multicast=True
- )],
- )],
- )],
- )], state="replaced"
- ))
- result = self.execute_module(changed=True)
- commands = ['ip route vrf ansible_vrf 192.0.2.0 255.255.255.0 192.0.2.1 name replaced_vrf track 170 tag 10',
- 'ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 multicast name replaced_route_1 tag 60'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_static_routes_replaced_idempotent(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0/24",
- next_hops=[dict(
- forward_router_address="192.0.2.1",
- name="test_vrf",
- tag=50,
- track=175
- )],
- )],
- )],
- ), dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0/24",
- next_hops=[dict(
- forward_router_address="198.51.101.1",
- name="route_1",
- distance_metric=110,
- tag=60,
- multicast=True
- )],
- )],
- )],
- )], state="replaced"
- ))
- self.execute_module(changed=False, commands=[], sort=True)
-
- def test_ios_static_routes_overridden(self):
- set_module_args(dict(
- config=[dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0 255.255.255.0",
- next_hops=[dict(
- forward_router_address="198.51.101.1",
- name="override_route_1",
- distance_metric=150,
- tag=50,
- multicast=True
- )],
- )],
- )],
- )], state="overridden"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'no ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 multicast name route_1 tag 60',
- 'no ip route vrf ansible_vrf 192.0.2.0 255.255.255.0 192.0.2.1 name test_vrf track 175 tag 50',
- 'ip route 198.51.100.0 255.255.255.0 198.51.101.1 150 multicast name override_route_1 tag 50'
- ]
-
- self.assertEqual(result['commands'], commands)
-
- def test_ios_static_routes_overridden_idempotent(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0/24",
- next_hops=[dict(
- forward_router_address="192.0.2.1",
- name="test_vrf",
- tag=50,
- track=175
- )],
- )],
- )],
- ), dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0/24",
- next_hops=[dict(
- forward_router_address="198.51.101.1",
- name="route_1",
- distance_metric=110,
- tag=60,
- multicast=True
- )],
- )],
- )],
- )], state="overridden"
- ))
- self.execute_module(changed=False, commands=[], sort=True)
-
- def test_ios_delete_static_route_config(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0/24",
- next_hops=[dict(
- forward_router_address="192.0.2.1",
- name="test_vrf",
- tag=50,
- track=175
- )],
- )],
- )],
- ), dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0/24",
- next_hops=[dict(
- forward_router_address="198.51.101.1",
- name="route_1",
- distance_metric=110,
- tag=60,
- multicast=True
- )],
- )],
- )],
- )], state="deleted"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'no ip route vrf ansible_vrf 192.0.2.0 255.255.255.0 192.0.2.1 name test_vrf track 175 tag 50',
- 'no ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 multicast name route_1 tag 60'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_delete_static_route_dest_based(self):
- set_module_args(dict(
- config=[dict(
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="198.51.100.0/24"
- )],
- )],
- )], state="deleted"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'no ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 multicast name route_1 tag 60'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_ios_delete_static_route_vrf_based(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0/24"
- )],
- )],
- )], state="deleted"
- ))
- result = self.execute_module(changed=True)
- commands = [
- 'no ip route vrf ansible_vrf 192.0.2.0 255.255.255.0 192.0.2.1 name test_vrf track 175 tag 50'
- ]
- self.assertEqual(result['commands'], commands)
-
- def test_static_route_rendered(self):
- set_module_args(dict(
- config=[dict(
- vrf="ansible_vrf",
- address_families=[dict(
- afi="ipv4",
- routes=[dict(
- dest="192.0.2.0/24",
- next_hops=[dict(
- forward_router_address="192.0.2.1",
- name="test_vrf",
- tag=50,
- track=175
- )],
- )],
- )],
- )], state="rendered"
- ))
- commands = [
- 'ip route vrf ansible_vrf 192.0.2.0 255.255.255.0 192.0.2.1 name test_vrf track 175 tag 50'
- ]
- result = self.execute_module(changed=False)
- self.assertEqual(sorted(result['rendered']), commands)
diff --git a/test/units/modules/network/ios/test_ios_system.py b/test/units/modules/network/ios/test_ios_system.py
deleted file mode 100644
index 0d43949f47..0000000000
--- a/test/units/modules/network/ios/test_ios_system.py
+++ /dev/null
@@ -1,123 +0,0 @@
-#
-# (c) 2016 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_system
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosSystemModule(TestIosModule):
-
- module = ios_system
-
- def setUp(self):
- super(TestIosSystemModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_system.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios.ios_system.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestIosSystemModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
-
- def load_fixtures(self, commands=None):
- self.get_config.return_value = load_fixture('ios_system_config.cfg')
- self.load_config.return_value = None
-
- def test_ios_system_hostname_changed(self):
- set_module_args(dict(hostname='foo'))
- commands = ['hostname foo']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_system_domain_name(self):
- set_module_args(dict(domain_name=['test.com']))
- commands = ['ip domain name test.com',
- 'no ip domain name eng.example.net',
- 'no ip domain name vrf management eng.example.net']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_system_domain_name_complex(self):
- set_module_args(dict(domain_name=[{'name': 'test.com', 'vrf': 'test'},
- {'name': 'eng.example.net'}]))
- commands = ['ip domain name vrf test test.com',
- 'no ip domain name vrf management eng.example.net']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_system_domain_search(self):
- set_module_args(dict(domain_search=['ansible.com', 'redhat.com']))
- commands = ['no ip domain list vrf management example.net',
- 'no ip domain list example.net',
- 'no ip domain list example.com',
- 'ip domain list ansible.com',
- 'ip domain list redhat.com']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_system_domain_search_complex(self):
- set_module_args(dict(domain_search=[{'name': 'ansible.com', 'vrf': 'test'}]))
- commands = ['no ip domain list vrf management example.net',
- 'no ip domain list example.net',
- 'no ip domain list example.com',
- 'ip domain list vrf test ansible.com']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_system_lookup_source(self):
- set_module_args(dict(lookup_source='Ethernet1'))
- commands = ['ip domain lookup source-interface Ethernet1']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_system_name_servers(self):
- name_servers = ['8.8.8.8', '8.8.4.4']
- set_module_args(dict(name_servers=name_servers))
- commands = ['no ip name-server vrf management 8.8.8.8',
- 'ip name-server 8.8.4.4']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def rest_ios_system_name_servers_complex(self):
- name_servers = dict(server='8.8.8.8', vrf='test')
- set_module_args(dict(name_servers=name_servers))
- commands = ['no name-server 8.8.8.8',
- 'no name-server vrf management 8.8.8.8',
- 'ip name-server vrf test 8.8.8.8']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_system_state_absent(self):
- set_module_args(dict(state='absent'))
- commands = ['no hostname',
- 'no ip domain lookup source-interface GigabitEthernet0/0',
- 'no ip domain list vrf management', 'no ip domain list',
- 'no ip domain name vrf management', 'no ip domain name',
- 'no ip name-server vrf management', 'no ip name-server']
- self.execute_module(changed=True, commands=commands)
-
- def test_ios_system_no_change(self):
- set_module_args(dict(hostname='ios01'))
- self.execute_module(commands=[])
-
- def test_ios_system_missing_vrf(self):
- name_servers = dict(server='8.8.8.8', vrf='missing')
- set_module_args(dict(name_servers=name_servers))
- self.execute_module(failed=True)
diff --git a/test/units/modules/network/ios/test_ios_user.py b/test/units/modules/network/ios/test_ios_user.py
deleted file mode 100644
index 5f0032bcae..0000000000
--- a/test/units/modules/network/ios/test_ios_user.py
+++ /dev/null
@@ -1,141 +0,0 @@
-# (c) 2016 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_user
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosUserModule(TestIosModule):
-
- module = ios_user
-
- def setUp(self):
- super(TestIosUserModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_user.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios.ios_user.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestIosUserModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- self.get_config.return_value = load_fixture('ios_user_config.cfg')
- self.load_config.return_value = dict(diff=None, session='session')
-
- def test_ios_user_create(self):
- set_module_args(dict(name='test', nopassword=True))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username test nopassword'])
-
- def test_ios_user_delete(self):
- set_module_args(dict(name='ansible', state='absent'))
- result = self.execute_module(changed=True)
- cmds = [
- {
- "command": "no username ansible", "answer": "y", "newline": False,
- "prompt": "This operation will remove all username related configurations with same name",
- }
- ]
-
- result_cmd = []
- for i in result['commands']:
- result_cmd.append(i)
-
- self.assertEqual(result_cmd, cmds)
-
- def test_ios_user_password(self):
- set_module_args(dict(name='ansible', configured_password='test'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username ansible secret test'])
-
- def test_ios_user_privilege(self):
- set_module_args(dict(name='ansible', privilege=15))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username ansible privilege 15'])
-
- def test_ios_user_privilege_invalid(self):
- set_module_args(dict(name='ansible', privilege=25))
- self.execute_module(failed=True)
-
- def test_ios_user_purge(self):
- set_module_args(dict(purge=True))
- result = self.execute_module(changed=True)
- cmd = {
- "command": "no username ansible", "answer": "y", "newline": False,
- "prompt": "This operation will remove all username related configurations with same name",
- }
-
- result_cmd = []
- for i in result['commands']:
- result_cmd.append(i)
-
- self.assertEqual(result_cmd, [cmd])
-
- def test_ios_user_view(self):
- set_module_args(dict(name='ansible', view='test'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username ansible view test'])
-
- def test_ios_user_update_password_changed(self):
- set_module_args(dict(name='test', configured_password='test', update_password='on_create'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username test secret test'])
-
- def test_ios_user_update_password_on_create_ok(self):
- set_module_args(dict(name='ansible', configured_password='test', update_password='on_create'))
- self.execute_module()
-
- def test_ios_user_update_password_always(self):
- set_module_args(dict(name='ansible', configured_password='test', update_password='always'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username ansible secret test'])
-
- def test_ios_user_set_sshkey(self):
- set_module_args(dict(name='ansible', sshkey='dGVzdA=='))
- commands = [
- 'ip ssh pubkey-chain',
- 'username ansible',
- 'key-hash ssh-rsa 098F6BCD4621D373CADE4E832627B4F6',
- 'exit',
- 'exit'
- ]
- result = self.execute_module(changed=True, commands=commands)
- self.assertEqual(result['commands'], commands)
-
- def test_ios_user_set_sshkey_multiple(self):
- set_module_args(dict(name='ansible', sshkey=['dGVzdA==', 'eHWacB2==']))
- commands = [
- 'ip ssh pubkey-chain',
- 'username ansible',
- 'key-hash ssh-rsa 098F6BCD4621D373CADE4E832627B4F6',
- 'key-hash ssh-rsa A019918340A1E9183388D9A675603036',
- 'exit',
- 'exit'
- ]
- result = self.execute_module(changed=True, commands=commands)
- self.assertEqual(result['commands'], commands)
diff --git a/test/units/modules/network/ios/test_ios_vlan.py b/test/units/modules/network/ios/test_ios_vlan.py
deleted file mode 100644
index 201efd1ad4..0000000000
--- a/test/units/modules/network/ios/test_ios_vlan.py
+++ /dev/null
@@ -1,149 +0,0 @@
-# (c) 2018 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import _ios_vlan
-from ansible.modules.network.ios._ios_vlan import parse_vlan_brief
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosVlanModule(TestIosModule):
-
- module = _ios_vlan
-
- def setUp(self):
- super(TestIosVlanModule, self).setUp()
-
- self.mock_run_commands = patch('ansible.modules.network.ios._ios_vlan.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios._ios_vlan.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestIosVlanModule, self).tearDown()
- self.mock_run_commands.stop()
- self.mock_load_config.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- self.run_commands.return_value = [load_fixture('ios_vlan_config.cfg')]
- self.load_config.return_value = {'diff': None, 'session': 'session'}
-
- def test_ios_vlan_create(self):
- set_module_args({'vlan_id': '3', 'name': 'test', 'state': 'present'})
- result = self.execute_module(changed=True)
- expected_commands = [
- 'vlan 3',
- 'name test',
- ]
- self.assertEqual(result['commands'], expected_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)
-
- 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)
-
- def test_ios_vlan_with_interfaces(self):
- set_module_args({'vlan_id': '2', 'name': 'vlan2', 'state': 'present', 'interfaces': ['GigabitEthernet1/0/8', 'GigabitEthernet1/0/7']})
- result = self.execute_module(changed=True)
- expected_commands = [
- 'vlan 2',
- 'interface GigabitEthernet1/0/8',
- 'switchport mode access',
- 'switchport access vlan 2',
- 'vlan 2',
- 'interface GigabitEthernet1/0/6',
- 'switchport mode access',
- 'no switchport access vlan 2',
- ]
- self.assertEqual(result['commands'], expected_commands)
-
- def test_ios_vlan_with_interfaces_and_newvlan(self):
- set_module_args({'vlan_id': '3', 'name': 'vlan3', 'state': 'present', 'interfaces': ['GigabitEthernet1/0/8', 'GigabitEthernet1/0/7']})
- result = self.execute_module(changed=True)
- expected_commands = [
- 'vlan 3',
- 'name vlan3',
- 'interface GigabitEthernet1/0/8',
- 'switchport mode access',
- 'switchport access vlan 3',
- 'interface GigabitEthernet1/0/7',
- 'switchport mode access',
- 'switchport access vlan 3',
- ]
- self.assertEqual(result['commands'], expected_commands)
-
- def test_parse_vlan_brief(self):
- result = parse_vlan_brief(load_fixture('ios_vlan_config.cfg'))
- obj = [
- {
- 'name': 'default',
- 'interfaces': [
- 'GigabitEthernet1/0/4',
- 'GigabitEthernet1/0/5',
- 'GigabitEthernet1/0/52',
- 'GigabitEthernet1/0/54',
- ],
- 'state': 'active',
- 'vlan_id': '1',
- },
- {
- 'name': 'vlan2',
- 'interfaces': [
- 'GigabitEthernet1/0/6',
- 'GigabitEthernet1/0/7',
- ],
- 'state': 'active',
- 'vlan_id': '2',
- },
- {
- 'name': 'vlan9',
- 'interfaces': [
- 'GigabitEthernet1/0/6',
- ],
- 'state': 'active',
- 'vlan_id': '9',
- },
- {
- 'name': 'fddi-default',
- 'interfaces': [],
- 'state': 'act/unsup',
- 'vlan_id': '1002',
- },
- {
- 'name': 'fddo-default',
- 'interfaces': [],
- 'state': 'act/unsup',
- 'vlan_id': '1003',
- },
- ]
- self.assertEqual(result, obj)
diff --git a/test/units/modules/network/ios/test_ios_vrf.py b/test/units/modules/network/ios/test_ios_vrf.py
deleted file mode 100644
index 1b00c4e665..0000000000
--- a/test/units/modules/network/ios/test_ios_vrf.py
+++ /dev/null
@@ -1,210 +0,0 @@
-#
-# (c) 2016 Red Hat Inc.
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-
-__metaclass__ = type
-
-from units.compat.mock import patch
-from ansible.modules.network.ios import ios_vrf
-from units.modules.utils import set_module_args
-from .ios_module import TestIosModule, load_fixture
-
-
-class TestIosVrfModule(TestIosModule):
- module = ios_vrf
-
- def setUp(self):
- super(TestIosVrfModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.ios.ios_vrf.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.ios.ios_vrf.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_exec_command = patch('ansible.modules.network.ios.ios_vrf.exec_command')
- self.exec_command = self.mock_exec_command.start()
-
- def tearDown(self):
- super(TestIosVrfModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_exec_command.stop()
-
- def load_fixtures(self, commands=None):
- self.get_config.return_value = load_fixture('ios_vrf_config.cfg')
- self.exec_command.return_value = (0, load_fixture('ios_vrf_config.cfg').strip(), None)
- self.load_config.return_value = None
-
- def test_ios_vrf_name(self):
- set_module_args(dict(name='test_4'))
- commands = ['vrf definition test_4']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_vrf_name_unchanged(self):
- set_module_args(dict(name='test_1', rd='1:100', description='test vrf 1'))
- self.execute_module()
-
- def test_ios_vrf_description(self):
- set_module_args(dict(name='test_1', description='test string'))
- commands = ['vrf definition test_1', 'description test string']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_vrf_rd(self):
- set_module_args(dict(name='test_1', rd='2:100'))
- commands = ['vrf definition test_1', 'rd 2:100']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- 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']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_vrf_state_absent(self):
- set_module_args(dict(name='test_1', state='absent'))
- commands = ['no vrf definition test_1']
- self.execute_module(changed=True, commands=commands)
-
- 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', '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_vrf_purge_all_but_one(self):
- set_module_args(dict(name='test_1', purge=True))
- commands = ['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_vrfs_no_purge(self):
- vrfs = [{'name': 'test_1'}, {'name': 'test_4'}]
- set_module_args(dict(vrfs=vrfs))
- commands = ['vrf definition test_4']
- 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', '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_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', 'description test string', 'vrf definition test_2', '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'}]
- set_module_args(dict(vrfs=vrfs, description='test string'))
- commands = ['vrf definition test_2', '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'}]
- set_module_args(dict(vrfs=vrfs, description='test string'))
- commands = ['no vrf definition test_1', 'vrf definition test_2', '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 import 2:100',
- 'route-target import 3:100', 'route-target export 2:100', 'route-target export 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', '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', '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_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_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', '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)
-
- def test_ios_vrf_route_import_ipv4(self):
- set_module_args(dict(name='test_10', rd='168.0.0.10:100', route_import_ipv4=['168.0.0.10:100', '3:100']))
- commands = ['vrf definition test_10', 'address-family ipv4', 'exit', 'rd 168.0.0.10:100', 'address-family ipv4',
- 'route-target import 168.0.0.10:100', 'route-target import 3:100', 'exit-address-family']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_vrf_route_export_ipv4(self):
- set_module_args(dict(name='test_11', rd='168.0.0.11:100', route_export_ipv4=['168.0.0.11:100', '3:100']))
- commands = ['vrf definition test_11', 'address-family ipv4', 'exit', 'rd 168.0.0.11:100', 'address-family ipv4',
- 'route-target export 168.0.0.11:100', 'route-target export 3:100', 'exit-address-family']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_vrf_route_both_ipv4_mixed(self):
- set_module_args(dict(name='test_12', rd='168.0.0.12:100', route_both_ipv4=['168.0.0.12:100', '3:100'], route_export_ipv4=['168.0.0.15:100', '6:100']))
- self.execute_module(changed=True)
-
- def test_ios_vrf_route_both_ipv6(self):
- set_module_args(dict(name='test_13', rd='2:100', route_both_ipv6=['2:100', '168.0.0.13:100']))
- commands = ['vrf definition test_13', 'address-family ipv6', 'exit', 'rd 2:100', 'address-family ipv6',
- 'route-target import 2:100', 'route-target import 168.0.0.13:100', 'exit-address-family', 'address-family ipv6',
- 'route-target export 2:100', 'route-target export 168.0.0.13:100', 'exit-address-family']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_ios_vrf_route_import_ipv6(self):
- set_module_args(dict(name='test_14', rd='3:100', route_import_ipv6=['3:100', '168.0.0.14:100']))
- commands = ['vrf definition test_14', 'address-family ipv6', 'exit', 'rd 3:100', 'address-family ipv6',
- 'route-target import 3:100', 'route-target import 168.0.0.14:100', 'exit-address-family']
- self.execute_module(changed=True, commands=commands, sort=False)
-
- 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 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_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)
-
- 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_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)
-
- 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)