summaryrefslogtreecommitdiff
path: root/test/units/modules
diff options
context:
space:
mode:
Diffstat (limited to 'test/units/modules')
-rw-r--r--test/units/modules/network/iosxr/fixtures/dir_7all6
-rw-r--r--test/units/modules/network/iosxr/fixtures/iosxr_acls_config.cfg5
-rw-r--r--test/units/modules/network/iosxr/fixtures/iosxr_config_config.cfg12
-rw-r--r--test/units/modules/network/iosxr/fixtures/iosxr_config_src.cfg11
-rw-r--r--test/units/modules/network/iosxr/fixtures/iosxr_static_routes_config.cfg18
-rw-r--r--test/units/modules/network/iosxr/fixtures/iosxr_system_config.cfg8
-rw-r--r--test/units/modules/network/iosxr/fixtures/iosxr_user_config.cfg8
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_interfaces41
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_ipv6_interface5
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_lldp1
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_lldp_neighbors_detail1
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_memory_summary5
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_running-config43
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_version84
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_version___utility_head_-n_2018
-rw-r--r--test/units/modules/network/iosxr/fixtures/show_version_brief18
-rw-r--r--test/units/modules/network/iosxr/iosxr_module.py88
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_acls.py246
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_command.py106
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_config.py221
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_facts.py103
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_netconf.py87
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_static_routes.py395
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_system.py101
-rw-r--r--test/units/modules/network/iosxr/test_iosxr_user.py94
25 files changed, 0 insertions, 1725 deletions
diff --git a/test/units/modules/network/iosxr/fixtures/dir_7all b/test/units/modules/network/iosxr/fixtures/dir_7all
deleted file mode 100644
index b992498c0e..0000000000
--- a/test/units/modules/network/iosxr/fixtures/dir_7all
+++ /dev/null
@@ -1,6 +0,0 @@
-Directory of disk0:
-file1
-file2
-
-Directory of flash0:
-file3
diff --git a/test/units/modules/network/iosxr/fixtures/iosxr_acls_config.cfg b/test/units/modules/network/iosxr/fixtures/iosxr_acls_config.cfg
deleted file mode 100644
index d9c32dd691..0000000000
--- a/test/units/modules/network/iosxr/fixtures/iosxr_acls_config.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-ipv4 access-list acl_2
- 10 deny ipv4 any any
- 20 permit tcp host 192.168.1.100 any
-ipv6 access-list acl6_1
- 10 deny icmpv6 any any
diff --git a/test/units/modules/network/iosxr/fixtures/iosxr_config_config.cfg b/test/units/modules/network/iosxr/fixtures/iosxr_config_config.cfg
deleted file mode 100644
index afad9d08aa..0000000000
--- a/test/units/modules/network/iosxr/fixtures/iosxr_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/iosxr/fixtures/iosxr_config_src.cfg b/test/units/modules/network/iosxr/fixtures/iosxr_config_src.cfg
deleted file mode 100644
index b3d8961a99..0000000000
--- a/test/units/modules/network/iosxr/fixtures/iosxr_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/iosxr/fixtures/iosxr_static_routes_config.cfg b/test/units/modules/network/iosxr/fixtures/iosxr_static_routes_config.cfg
deleted file mode 100644
index 36c9eb2330..0000000000
--- a/test/units/modules/network/iosxr/fixtures/iosxr_static_routes_config.cfg
+++ /dev/null
@@ -1,18 +0,0 @@
-Fri Nov 29 21:10:41.896 UTC
-router static
- address-family ipv4 unicast
- 192.0.2.16/28 FastEthernet0/0/0/1 192.0.2.10 tag 10 description LAB metric 120
- 192.0.2.16/28 FastEthernet0/0/0/5 track ip_sla_1
- 192.0.2.32/28 192.0.2.11 100
- !
- address-family ipv6 unicast
- 2001:db8:1000::/36 FastEthernet0/0/0/7 description DC
- 2001:db8:1000::/36 FastEthernet0/0/0/8 2001:db8:2000:2::1
- !
- vrf DEV_SITE
- address-family ipv4 unicast
- 192.0.2.48/28 vrf test_1 192.0.2.12 description DEV
- 192.0.2.80/28 vrf test_1 FastEthernet0/0/0/2 192.0.2.14 vrflabel 124 track ip_sla_2
- !
- !
-! \ No newline at end of file
diff --git a/test/units/modules/network/iosxr/fixtures/iosxr_system_config.cfg b/test/units/modules/network/iosxr/fixtures/iosxr_system_config.cfg
deleted file mode 100644
index fc6fd2b753..0000000000
--- a/test/units/modules/network/iosxr/fixtures/iosxr_system_config.cfg
+++ /dev/null
@@ -1,8 +0,0 @@
-hostname iosxr01
-domain name eng.ansible.com
-domain lookup disable
-domain lookup source-interface MgmtEth0/0/CPU0/0
-domain list redhat.com
-domain list cisco.com
-domain name-server 8.8.8.8
-domain name-server 8.8.4.4
diff --git a/test/units/modules/network/iosxr/fixtures/iosxr_user_config.cfg b/test/units/modules/network/iosxr/fixtures/iosxr_user_config.cfg
deleted file mode 100644
index 0f0ab168be..0000000000
--- a/test/units/modules/network/iosxr/fixtures/iosxr_user_config.cfg
+++ /dev/null
@@ -1,8 +0,0 @@
-username admin
- secret 5 $1$mdQIUxjg$3t3lzBpfKfITKvFm1uEIY.
- group sysadmin
-!
-username ansible
- secret 5 $1$3yWSXiIi$VdzV59ChiurrNdGxlDeAW/
- group sysadmin
-!
diff --git a/test/units/modules/network/iosxr/fixtures/show_interfaces b/test/units/modules/network/iosxr/fixtures/show_interfaces
deleted file mode 100644
index d68907c0b0..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_interfaces
+++ /dev/null
@@ -1,41 +0,0 @@
-Loopback0 is up, line protocol is up
- Interface state transitions: 1
- Hardware is Loopback interface(s)
- Description: Loopback
- Internet address is 192.168.0.3/32
- MTU 1500 bytes, BW 0 Kbit
- reliability Unknown, txload Unknown, rxload Unknown
- Encapsulation Loopback, loopback not set,
- Last link flapped 12w1d
- Last input Unknown, output Unknown
- Last clearing of "show interface" counters Unknown
- Input/output data rate is disabled.
-
-GigabitEthernet0/0/0/0 is up, line protocol is up
- Interface state transitions: 1
- Hardware is GigabitEthernet, address is fa16.3e6c.20bd (bia fa16.3e6c.20bd)
- Description: to nxos01
- Internet address is 10.0.0.5/30
- MTU 1514 bytes, BW 1000000 Kbit (Max: 1000000 Kbit)
- reliability 255/255, txload 0/255, rxload 0/255
- Encapsulation ARPA,
- Full-duplex, 1000Mb/s, unknown, link type is force-up
- output flow control is off, input flow control is off
- Carrier delay (up) is 10 msec
- loopback not set,
- Last link flapped 12w1d
- ARP type ARPA, ARP timeout 04:00:00
- Last input 00:00:44, output 00:12:45
- Last clearing of "show interface" counters never
- 5 minute input rate 0 bits/sec, 0 packets/sec
- 5 minute output rate 0 bits/sec, 0 packets/sec
- 150700 packets input, 36897055 bytes, 0 total input drops
- 0 drops for unrecognized upper-level protocol
- Received 1 broadcast packets, 150445 multicast packets
- 0 runts, 0 giants, 0 throttles, 0 parity
- 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
- 11691 packets output, 2904632 bytes, 0 total output drops
- Output 1 broadcast packets, 11436 multicast packets
- 0 output errors, 0 underruns, 0 applique, 0 resets
- 0 output buffer failures, 0 output buffers swapped out
- 1 carrier transitions
diff --git a/test/units/modules/network/iosxr/fixtures/show_ipv6_interface b/test/units/modules/network/iosxr/fixtures/show_ipv6_interface
deleted file mode 100644
index 971d1f65e7..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_ipv6_interface
+++ /dev/null
@@ -1,5 +0,0 @@
-Loopback0 is Up, ipv6 protocol is Up, Vrfid is default (0x60000000)
- IPv6 is disabled, link-local address unassigned
- No global unicast address is configured
-GigabitEthernet0/0/0/0 is Up, ipv6 protocol is Up, Vrfid is default (0x60000000)
- IPv6 is disabled, link-local address unassigned
diff --git a/test/units/modules/network/iosxr/fixtures/show_lldp b/test/units/modules/network/iosxr/fixtures/show_lldp
deleted file mode 100644
index 60ab287f87..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_lldp
+++ /dev/null
@@ -1 +0,0 @@
-% LLDP is not enabled
diff --git a/test/units/modules/network/iosxr/fixtures/show_lldp_neighbors_detail b/test/units/modules/network/iosxr/fixtures/show_lldp_neighbors_detail
deleted file mode 100644
index 60ab287f87..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_lldp_neighbors_detail
+++ /dev/null
@@ -1 +0,0 @@
-% LLDP is not enabled
diff --git a/test/units/modules/network/iosxr/fixtures/show_memory_summary b/test/units/modules/network/iosxr/fixtures/show_memory_summary
deleted file mode 100644
index b26abeae36..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_memory_summary
+++ /dev/null
@@ -1,5 +0,0 @@
-Physical Memory: 3095M total (1499M available)
- Application Memory : 2893M (1499M available)
- Image: 73M (bootram: 73M)
- Reserved: 128M, IOMem: 0, flashfsys: 0
- Total shared window: 23M
diff --git a/test/units/modules/network/iosxr/fixtures/show_running-config b/test/units/modules/network/iosxr/fixtures/show_running-config
deleted file mode 100644
index 085baef473..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_running-config
+++ /dev/null
@@ -1,43 +0,0 @@
-hostname iosxr01
-service timestamps log datetime msec
-service timestamps debug datetime msec
-telnet vrf default ipv4 server max-servers 10
-telnet vrf Mgmt-intf ipv4 server max-servers 10
-domain name eng.ansible.com
-domain lookup disable
-vrf Mgmt-intf
- address-family ipv4 unicast
- !
- address-family ipv6 unicast
- !
-!
-line template vty
- timestamp
- exec-timeout 720 0
-!
-line console
- exec-timeout 0 0
-!
-line default
- exec-timeout 720 0
-!
-vty-pool default 0 50
-control-plane
- management-plane
- inband
- interface all
- allow all
- !
- !
- !
-!
-interface Loopback0
- description Loopback
- ipv4 address 192.168.0.1 255.255.255.255
-!
-interface GigabitEthernet0/0/0/0
- description to nxos01
- cdp
- ipv4 address 10.0.0.1 255.255.255.252
-!
-end
diff --git a/test/units/modules/network/iosxr/fixtures/show_version b/test/units/modules/network/iosxr/fixtures/show_version
deleted file mode 100644
index faecfffdcb..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_version
+++ /dev/null
@@ -1,84 +0,0 @@
-Cisco IOS XR Software, Version 6.0.0[Default]
-Copyright (c) 2015 by Cisco Systems, Inc.
-
-ROM: GRUB, Version 1.99(0), DEV RELEASE
-
-iosxr01 uptime is 11 weeks, 2 days, 5 hours, 48 minutes
-System image file is "bootflash:disk0/xrvr-os-mbi-6.0.0/mbixrvr-rp.vm"
-
-cisco IOS XRv Series (Pentium Celeron Stepping 3) processor with 3169911K bytes of memory.
-Pentium Celeron Stepping 3 processor at 3836MHz, Revision 2.174
-IOS XRv Chassis
-
-1 Management Ethernet
-6 GigabitEthernet
-97070k bytes of non-volatile configuration memory.
-866M bytes of hard disk.
-2321392k bytes of disk0: (Sector size 512 bytes).
-
-Configuration register on node 0/0/CPU0 is 0x2102
-Boot device on node 0/0/CPU0 is disk0:
-Package active on node 0/0/CPU0:
-iosxr-infra, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-infra-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-fwding, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-fwding-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-routing, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-routing-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-ce, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-ce-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-xrvr-os-mbi, V 6.0.0[Default], Cisco Systems, at disk0:xrvr-os-mbi-6.0.0
- Built on Thu Dec 24 08:54:41 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-xrvr-base, V 6.0.0[Default], Cisco Systems, at disk0:xrvr-base-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-xrvr-fwding, V 6.0.0[Default], Cisco Systems, at disk0:xrvr-fwding-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-xrvr-mgbl-x, V 6.0.0[Default], Cisco Systems, at disk0:xrvr-mgbl-x-6.0.0
- Built on Thu Dec 24 08:53:57 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-mpls, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-mpls-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-mgbl, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-mgbl-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-mcast, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-mcast-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-xrvr-mcast-supp, V 6.0.0[Default], Cisco Systems, at disk0:xrvr-mcast-supp-6.0.0
- Built on Thu Dec 24 08:53:49 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-bng, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-bng-6.0.0
- Built on Thu Dec 24 08:53:47 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-xrvr-bng-supp, V 6.0.0[Default], Cisco Systems, at disk0:xrvr-bng-supp-6.0.0
- Built on Thu Dec 24 08:53:47 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-iosxr-security, V 6.0.0[Default], Cisco Systems, at disk0:iosxr-security-6.0.0
- Built on Thu Dec 24 08:53:41 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
-
-xrvr-fullk9-x, V 6.0.0[Default], Cisco Systems, at disk0:xrvr-fullk9-x-6.0.0
- Built on Thu Dec 24 08:55:12 UTC 2015
- By iox-lnx-010 in /auto/srcarchive16/production/6.0.0/xrvr/workspace for pie
diff --git a/test/units/modules/network/iosxr/fixtures/show_version___utility_head_-n_20 b/test/units/modules/network/iosxr/fixtures/show_version___utility_head_-n_20
deleted file mode 100644
index 7f82039ff1..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_version___utility_head_-n_20
+++ /dev/null
@@ -1,18 +0,0 @@
-Cisco IOS XR Software, Version 6.0.0[Default]
-Copyright (c) 2015 by Cisco Systems, Inc.
-
-ROM: GRUB, Version 1.99(0), DEV RELEASE
-
-iosxr01 uptime is 11 weeks, 6 days, 2 hours, 2 minutes
-System image file is "bootflash:disk0/xrvr-os-mbi-6.0.0/mbixrvr-rp.vm"
-
-cisco IOS XRv Series (Pentium Celeron Stepping 3) processor with 3169911K bytes
-of memory.
-Pentium Celeron Stepping 3 processor at 3836MHz, Revision 2.174
-IOS XRv Chassis
-
-1 Management Ethernet
-6 GigabitEthernet
-97070k bytes of non-volatile configuration memory.
-866M bytes of hard disk.
-2321392k bytes of disk0: (Sector size 512 bytes).
diff --git a/test/units/modules/network/iosxr/fixtures/show_version_brief b/test/units/modules/network/iosxr/fixtures/show_version_brief
deleted file mode 100644
index 7f82039ff1..0000000000
--- a/test/units/modules/network/iosxr/fixtures/show_version_brief
+++ /dev/null
@@ -1,18 +0,0 @@
-Cisco IOS XR Software, Version 6.0.0[Default]
-Copyright (c) 2015 by Cisco Systems, Inc.
-
-ROM: GRUB, Version 1.99(0), DEV RELEASE
-
-iosxr01 uptime is 11 weeks, 6 days, 2 hours, 2 minutes
-System image file is "bootflash:disk0/xrvr-os-mbi-6.0.0/mbixrvr-rp.vm"
-
-cisco IOS XRv Series (Pentium Celeron Stepping 3) processor with 3169911K bytes
-of memory.
-Pentium Celeron Stepping 3 processor at 3836MHz, Revision 2.174
-IOS XRv Chassis
-
-1 Management Ethernet
-6 GigabitEthernet
-97070k bytes of non-volatile configuration memory.
-866M bytes of hard disk.
-2321392k bytes of disk0: (Sector size 512 bytes).
diff --git a/test/units/modules/network/iosxr/iosxr_module.py b/test/units/modules/network/iosxr/iosxr_module.py
deleted file mode 100644
index 55f2a23688..0000000000
--- a/test/units/modules/network/iosxr/iosxr_module.py
+++ /dev/null
@@ -1,88 +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 TestIosxrModule(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/iosxr/test_iosxr_acls.py b/test/units/modules/network/iosxr/test_iosxr_acls.py
deleted file mode 100644
index 6eab446a9f..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_acls.py
+++ /dev/null
@@ -1,246 +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.iosxr import iosxr_acls
-from units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule, load_fixture
-
-
-class TestIosxrAclsModule(TestIosxrModule):
- module = iosxr_acls
-
- def setUp(self):
- super(TestIosxrAclsModule, 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_execute_show_command = patch(
- 'ansible.module_utils.network.iosxr.facts.acls.acls.AclsFacts.get_device_data'
- )
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestIosxrAclsModule, self).tearDown()
- self.mock_get_resource_connection_config.stop()
- self.mock_get_resource_connection_facts.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('iosxr_acls_config.cfg')
-
- self.execute_show_command.side_effect = load_from_file
-
- def test_iosxr_acls_merged(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="acl_1",
- aces=[
- dict(sequence="10",
- grant="permit",
- protocol="ospf",
- source=dict(prefix="192.168.1.0/24"),
- destination=dict(any="true"),
- log="true")
- ])
- ])
- ],
- state="merged"))
- commands = [
- 'ipv4 access-list acl_1',
- '10 permit ospf 192.168.1.0 0.0.0.255 any log'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_acls_merged_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="acl_2",
- aces=[
- dict(sequence="10",
- grant="deny",
- protocol='ipv4',
- destination=dict(any='true'),
- source=dict(any="true")),
- ])
- ])
- ],
- state="merged"))
- self.execute_module(changed=False, commands=[])
-
- def test_iosxr_acls_replaced(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="acl_2",
- aces=[
- dict(sequence="30",
- grant="permit",
- protocol="ospf",
- source=dict(prefix="10.0.0.0/8"),
- destination=dict(any="true"),
- log="true")
- ])
- ])
- ],
- state="replaced"))
- commands = [
- 'ipv4 access-list acl_2', 'no 10', 'no 20',
- '30 permit ospf 10.0.0.0 0.255.255.255 any log'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_acls_replaced_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="acl_2",
- aces=[
- dict(sequence="10",
- grant="deny",
- protocol='ipv4',
- destination=dict(any='true'),
- source=dict(any="true")),
- dict(sequence="20",
- grant="permit",
- protocol="tcp",
- destination=dict(any='true'),
- source=dict(host="192.168.1.100")),
- ])
- ])
- ],
- state="replaced"))
- self.execute_module(changed=False, commands=[])
-
- def test_iosxr_acls_overridden(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="acl_2",
- aces=[
- dict(sequence="40",
- grant="permit",
- protocol="ospf",
- source=dict(any="true"),
- destination=dict(any="true"),
- log="true")
- ])
- ])
- ],
- state="overridden"))
- commands = [
- 'no ipv6 access-list acl6_1', 'ipv4 access-list acl_2', 'no 10',
- 'no 20', '40 permit ospf any any log'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_acls_overridden_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="acl_2",
- aces=[
- dict(sequence="10",
- grant="deny",
- protocol='ipv4',
- destination=dict(any='true'),
- source=dict(any="true")),
- dict(sequence="20",
- grant="permit",
- protocol="tcp",
- destination=dict(any='true'),
- source=dict(host="192.168.1.100")),
- ])
- ]),
- dict(afi='ipv6',
- acls=[
- dict(name="acl6_1",
- aces=[
- dict(
- sequence="10",
- grant="deny",
- protocol="icmpv6",
- destination=dict(any='true'),
- source=dict(any='true'),
- )
- ])
- ])
- ],
- state="overridden"))
- self.execute_module(changed=False, commands=[])
-
- def test_iosxr_acls_deletedaces(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[dict(name="acl_2", aces=[dict(sequence="20")])])
- ],
- state="deleted"))
- commands = ['ipv4 access-list acl_2', 'no 20']
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_acls_deletedacls(self):
- set_module_args(
- dict(config=[dict(afi="ipv6", acls=[dict(name="acl6_1")])],
- state="deleted"))
- commands = ['no ipv6 access-list acl6_1']
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_acls_deletedafis(self):
- set_module_args(dict(config=[dict(afi="ipv4")], state="deleted"))
- commands = ['no ipv4 access-list acl_2']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acls_rendered(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="acl_2",
- aces=[
- dict(grant="permit",
- source=dict(any="true"),
- destination=dict(any="true"),
- protocol='igmp')
- ])
- ])
- ],
- state="rendered"))
- commands = ['ipv4 access-list acl_2', 'permit igmp any any']
- result = self.execute_module(changed=False)
- self.assertEqual(sorted(result['rendered']), sorted(commands),
- result['rendered'])
diff --git a/test/units/modules/network/iosxr/test_iosxr_command.py b/test/units/modules/network/iosxr/test_iosxr_command.py
deleted file mode 100644
index 49242939e4..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_command.py
+++ /dev/null
@@ -1,106 +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.iosxr import iosxr_command
-from units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule, load_fixture
-
-
-class TestIosxrCommandModule(TestIosxrModule):
-
- module = iosxr_command
-
- def setUp(self):
- super(TestIosxrCommandModule, self).setUp()
-
- self.mock_run_commands = patch('ansible.modules.network.iosxr.iosxr_command.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- def tearDown(self):
- super(TestIosxrCommandModule, 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:
- command = item['command']
- except Exception:
- command = item
- filename = str(command).replace(' ', '_')
- output.append(load_fixture(filename))
- return output
-
- self.run_commands.side_effect = load_from_file
-
- def test_iosxr_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 XR Software'))
-
- def test_iosxr_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 XR Software'))
-
- def test_iosxr_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_iosxr_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_iosxr_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_iosxr_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_iosxr_command_match_all(self):
- wait_for = ['result[0] contains "Cisco IOS"',
- 'result[0] contains "XR Software"']
- set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all'))
- self.execute_module()
-
- def test_iosxr_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)
diff --git a/test/units/modules/network/iosxr/test_iosxr_config.py b/test/units/modules/network/iosxr/test_iosxr_config.py
deleted file mode 100644
index aa08042b71..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_config.py
+++ /dev/null
@@ -1,221 +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.iosxr import iosxr_config
-from ansible.plugins.cliconf.iosxr import Cliconf
-from units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule, load_fixture
-
-
-class TestIosxrConfigModule(TestIosxrModule):
-
- module = iosxr_config
-
- def setUp(self):
- super(TestIosxrConfigModule, self).setUp()
-
- self.patcher_get_config = patch('ansible.modules.network.iosxr.iosxr_config.get_config')
- self.mock_get_config = self.patcher_get_config.start()
-
- self.patcher_exec_command = patch('ansible.modules.network.iosxr.iosxr_config.load_config')
- self.mock_exec_command = self.patcher_exec_command.start()
-
- self.mock_get_connection = patch('ansible.modules.network.iosxr.iosxr_config.get_connection')
- self.get_connection = self.mock_get_connection.start()
-
- self.conn = self.get_connection()
- self.conn.edit_config = MagicMock()
-
- self.cliconf_obj = Cliconf(MagicMock())
- self.running_config = load_fixture('iosxr_config_config.cfg')
-
- def tearDown(self):
- super(TestIosxrConfigModule, self).tearDown()
-
- self.patcher_get_config.stop()
- self.patcher_exec_command.stop()
- self.mock_get_connection.stop()
-
- def load_fixtures(self, commands=None):
- config_file = 'iosxr_config_config.cfg'
- self.mock_get_config.return_value = load_fixture(config_file)
- self.mock_exec_command.return_value = 'dummy diff'
-
- def test_iosxr_config_unchanged(self):
- src = load_fixture('iosxr_config_config.cfg')
- set_module_args(dict(src=src))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(src, src))
- self.execute_module()
-
- def test_iosxr_config_src(self):
- src = load_fixture('iosxr_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_iosxr_config_backup(self):
- set_module_args(dict(backup=True))
- result = self.execute_module()
- self.assertIn('__backup__', result)
-
- def test_iosxr_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_iosxr_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 = iosxr_config.get_candidate(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_iosxr_config_before(self):
- lines = ['hostname foo']
- set_module_args(dict(lines=lines, before=['test1', 'test2']))
- commands = ['test1', 'test2', 'hostname foo']
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_iosxr_config_after(self):
- lines = ['hostname foo']
- set_module_args(dict(lines=lines, after=['test1', 'test2']))
- commands = ['hostname foo', 'test1', 'test2']
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_iosxr_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_iosxr_config_config(self):
- config = 'hostname localhost'
- lines = ['hostname router']
- set_module_args(dict(lines=['hostname router'], 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_iosxr_config_replace_block(self):
- lines = ['description test string', 'test string']
- parents = ['interface GigabitEthernet0/0']
- set_module_args(dict(lines=lines, replace='block', parents=parents))
- commands = parents + lines
-
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = iosxr_config.get_candidate(module)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_replace='block', path=parents))
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_config_force(self):
- lines = ['hostname router']
- set_module_args(dict(lines=lines, force=True))
- 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_iosxr_config_admin(self):
- lines = ['username admin', 'group root-system', 'secret P@ssw0rd']
- set_module_args(dict(lines=lines, admin=True))
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- self.execute_module(changed=True, commands=lines)
-
- def test_iosxr_config_match_none(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'))
- commands = parents + lines
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = iosxr_config.get_candidate(module)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_match='none', path=parents))
-
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_iosxr_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'))
- commands = parents + ['shutdown']
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = iosxr_config.get_candidate(module)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_match='strict', path=parents))
-
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_iosxr_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'))
- commands = parents + lines
- module = MagicMock()
- module.params = {'lines': lines, 'parents': parents, 'src': None}
- candidate_config = iosxr_config.get_candidate(module)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(candidate_config, self.running_config, diff_match='exact', path=parents))
-
- self.execute_module(changed=True, commands=commands, sort=False)
-
- def test_iosxr_config_src_and_lines_fails(self):
- args = dict(src='foo', lines='foo')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_iosxr_config_src_and_parents_fails(self):
- args = dict(src='foo', parents='foo')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_iosxr_config_match_exact_requires_lines(self):
- args = dict(match='exact')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_iosxr_config_match_strict_requires_lines(self):
- args = dict(match='strict')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_iosxr_config_replace_block_requires_lines(self):
- args = dict(replace='block')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_iosxr_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/iosxr/test_iosxr_facts.py b/test/units/modules/network/iosxr/test_iosxr_facts.py
deleted file mode 100644
index 28f59c253a..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_facts.py
+++ /dev/null
@@ -1,103 +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 units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule, load_fixture
-from ansible.modules.network.iosxr import iosxr_facts
-
-
-class TestIosxrFacts(TestIosxrModule):
-
- module = iosxr_facts
-
- def setUp(self):
- super(TestIosxrFacts, self).setUp()
-
- self.mock_run_commands = patch(
- 'ansible.module_utils.network.iosxr.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.iosxr.facts.legacy.base.get_capabilities')
- self.get_capabilities = self.mock_get_capabilities.start()
- self.get_capabilities.return_value = {
- 'device_info': {
- 'network_os': 'iosxr',
- 'network_os_hostname': 'iosxr01',
- 'network_os_image': 'bootflash:disk0/xrvr-os-mbi-6.1.3/mbixrvr-rp.vm',
- 'network_os_version': '6.1.3[Default]'
- },
- 'network_api': 'cliconf'
- }
-
- def tearDown(self):
- super(TestIosxrFacts, self).tearDown()
-
- self.mock_run_commands.stop()
- self.mock_get_capabilities.stop()
- self.mock_get_resource_connection.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 = obj['command']
- except ValueError:
- command = item
- filename = str(command).replace(' ', '_')
- filename = filename.replace('/', '7')
- filename = filename.replace('|', '_')
- output.append(load_fixture(filename))
- return output
-
- self.run_commands.side_effect = load_from_file
-
- def test_iosxr_facts_gather_subset_default(self):
- set_module_args(dict())
- result = self.execute_module()
- ansible_facts = result['ansible_facts']
- self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
- self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
- self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
- self.assertEqual('iosxr01', ansible_facts['ansible_net_hostname'])
- self.assertEqual(['disk0:', 'flash0:'], ansible_facts['ansible_net_filesystems'])
- self.assertIn('GigabitEthernet0/0/0/0', ansible_facts['ansible_net_interfaces'].keys())
- self.assertEqual('3095', ansible_facts['ansible_net_memtotal_mb'])
- self.assertEqual('1499', ansible_facts['ansible_net_memfree_mb'])
-
- def test_iosxr_facts_gather_subset_config(self):
- set_module_args({'gather_subset': 'config'})
- result = self.execute_module()
- ansible_facts = result['ansible_facts']
- self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
- self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
- self.assertEqual('iosxr01', ansible_facts['ansible_net_hostname'])
- self.assertIn('ansible_net_config', ansible_facts)
diff --git a/test/units/modules/network/iosxr/test_iosxr_netconf.py b/test/units/modules/network/iosxr/test_iosxr_netconf.py
deleted file mode 100644
index a6f8b65cc1..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_netconf.py
+++ /dev/null
@@ -1,87 +0,0 @@
-# (c) 2017 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.iosxr import iosxr_netconf
-from units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule
-
-
-class TestIosxrNetconfModule(TestIosxrModule):
-
- module = iosxr_netconf
-
- def setUp(self):
- super(TestIosxrNetconfModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.iosxr.iosxr_netconf.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.iosxr.iosxr_netconf.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestIosxrNetconfModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
-
- def test_iosxr_disable_netconf_service(self):
- self.get_config.return_value = '''
- netconf-yang agent
- ssh
- !
- ssh server netconf vrf default
- '''
- self.load_config.return_value = 'dummy diff'
- set_module_args(dict(netconf_port=830, netconf_vrf='default', state='absent'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['no netconf-yang agent ssh', 'no ssh server netconf port 830', 'no ssh server netconf vrf default'])
-
- def test_iosxr_enable_netconf_service(self):
- self.get_config.return_value = ''
- self.load_config.return_value = 'dummy diff'
- set_module_args(dict(netconf_port=830, netconf_vrf='default', state='present'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['netconf-yang agent ssh', 'ssh server netconf port 830', 'ssh server netconf vrf default'])
-
- def test_iosxr_change_netconf_port(self):
- self.get_config.return_value = '''
- netconf-yang agent
- ssh
- !
- ssh server netconf vrf default
- '''
- self.load_config.return_value = 'dummy diff'
- set_module_args(dict(netconf_port=9000, state='present'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['ssh server netconf port 9000'])
-
- def test_iosxr_change_netconf_vrf(self):
- self.get_config.return_value = '''
- netconf-yang agent
- ssh
- !
- ssh server netconf vrf default
- '''
- self.load_config.return_value = 'dummy diff'
- set_module_args(dict(netconf_vrf='new_default', state='present'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['ssh server netconf vrf new_default'])
diff --git a/test/units/modules/network/iosxr/test_iosxr_static_routes.py b/test/units/modules/network/iosxr/test_iosxr_static_routes.py
deleted file mode 100644
index 257b855ba6..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_static_routes.py
+++ /dev/null
@@ -1,395 +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.iosxr import iosxr_static_routes
-from units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule, load_fixture
-
-
-class TestIosxrStaticRoutesModule(TestIosxrModule):
- module = iosxr_static_routes
-
- def setUp(self):
- super(TestIosxrStaticRoutesModule, 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_execute_show_command = patch(
- "ansible.module_utils.network.iosxr.facts.static_routes.static_routes.Static_routesFacts.get_device_data"
- )
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestIosxrStaticRoutesModule, self).tearDown()
- self.mock_get_resource_connection_config.stop()
- self.mock_get_resource_connection_facts.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("iosxr_static_routes_config.cfg")
-
- self.execute_show_command.side_effect = load_from_file
-
- def test_iosxr_static_routes_merged(self):
- set_module_args(
- dict(
- config=[
- dict(
- vrf="dev_site",
- address_families=[
- dict(
- afi="ipv6",
- safi="unicast",
- routes=[
- dict(
- dest="1200:10::/64",
- next_hops=[
- dict(
- interface="GigabitEthernet0/0/0/1",
- admin_distance=55,
- )
- ],
- )
- ],
- )
- ],
- )
- ],
- state="merged",
- )
- )
- commands = [
- "router static",
- "vrf dev_site",
- "address-family ipv6 unicast",
- "1200:10::/64 GigabitEthernet0/0/0/1 55",
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_merged_idempotent(self):
- set_module_args(
- dict(
- config=[
- dict(
- vrf="DEV_SITE",
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[
- dict(
- dest="192.0.2.48/28",
- next_hops=[
- dict(
- interface="192.0.2.12",
- description="DEV",
- dest_vrf="test_1",
- )
- ],
- )
- ],
- )
- ],
- )
- ],
- state="merged",
- )
- )
- self.execute_module(changed=False, commands=[])
-
- def test_iosxr_static_routes_default(self):
- set_module_args(
- dict(
- config=[
- dict(
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[
- dict(
- dest="192.168.1.0/24",
- next_hops=[
- dict(
- interface="GigabitEthernet0/0/0/2",
- track="ip_sla_2",
- vrflabel=1200,
- )
- ],
- )
- ],
- )
- ]
- )
- ]
- )
- )
- commands = [
- "router static",
- "address-family ipv4 unicast",
- "192.168.1.0/24 GigabitEthernet0/0/0/2 track ip_sla_2 vrflabel 1200",
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_default_idempotent(self):
- set_module_args(
- dict(
- config=[
- dict(
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[
- dict(
- dest="192.0.2.32/28",
- next_hops=[
- dict(
- forward_router_address="192.0.2.11",
- admin_distance=100,
- )
- ],
- )
- ],
- )
- ]
- )
- ]
- )
- )
- self.execute_module(changed=False, commands=[])
-
- def test_iosxr_static_routes_replaced(self):
- set_module_args(
- dict(
- config=[
- dict(
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[
- dict(
- dest="192.0.2.16/28",
- next_hops=[
- dict(
- forward_router_address="192.0.2.11",
- admin_distance=100,
- )
- ],
- )
- ],
- )
- ]
- )
- ],
- state="replaced",
- )
- )
- commands = [
- "router static",
- "address-family ipv4 unicast",
- "no 192.0.2.16/28 192.0.2.10 FastEthernet0/0/0/1",
- "no 192.0.2.16/28 FastEthernet0/0/0/5",
- "192.0.2.16/28 192.0.2.11 100",
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_replaced_idempotent(self):
- set_module_args(
- dict(
- config=[
- dict(
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[
- dict(
- dest="192.0.2.16/28",
- next_hops=[
- dict(
- interface="FastEthernet0/0/0/5",
- track="ip_sla_1",
- ),
- dict(
- interface="FastEthernet0/0/0/1",
- forward_router_address="192.0.2.10",
- tag=10,
- description="LAB",
- metric=120,
- ),
- ],
- )
- ],
- )
- ]
- )
- ],
- state="replaced",
- )
- )
- self.execute_module(changed=False, commands=[])
-
- def test_iosxr_static_routes_overridden(self):
- set_module_args(
- dict(
- config=[
- dict(
- vrf="DEV_SITE_NEW",
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[
- dict(
- dest="192.0.4.16/28",
- next_hops=[
- dict(
- interface="FastEthernet0/0/0/5",
- track="ip_sla_1",
- ),
- dict(
- interface="FastEthernet0/0/0/1",
- forward_router_address="192.0.2.10",
- tag=10,
- description="LAB",
- metric=120,
- ),
- ],
- )
- ],
- )
- ],
- )
- ],
- state="overridden",
- )
- )
- commands = [
- "router static",
- "no address-family ipv4 unicast",
- "no address-family ipv6 unicast",
- "no vrf DEV_SITE",
- "vrf DEV_SITE_NEW",
- "address-family ipv4 unicast",
- "192.0.4.16/28 192.0.2.10 FastEthernet0/0/0/1 description LAB metric 120 tag 10",
- "192.0.4.16/28 FastEthernet0/0/0/5 track ip_sla_1",
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_deleted_next_hop(self):
- set_module_args(
- dict(
- config=[
- dict(
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[
- dict(
- dest="192.0.2.16/28",
- next_hops=[
- dict(interface="FastEthernet0/0/0/5")
- ],
- )
- ],
- )
- ]
- )
- ],
- state="deleted",
- )
- )
-
- commands = [
- "router static",
- "address-family ipv4 unicast",
- "no 192.0.2.16/28 FastEthernet0/0/0/5",
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_deleted_dest(self):
- set_module_args(
- dict(
- config=[
- dict(
- address_families=[
- dict(
- afi="ipv4",
- safi="unicast",
- routes=[dict(dest="192.0.2.16/28")],
- )
- ]
- )
- ],
- state="deleted",
- )
- )
-
- commands = ["router static", "address-family ipv4 unicast", "no 192.0.2.16/28"]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_deleted_afi(self):
- set_module_args(
- dict(
- config=[dict(address_families=[dict(afi="ipv4", safi="unicast")])],
- state="deleted",
- )
- )
-
- commands = [
- "router static",
- "no address-family ipv4 unicast",
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_deleted_vrf(self):
- set_module_args(dict(config=[dict(vrf="DEV_SITE")], state="deleted"))
-
- commands = [
- "router static",
- "no vrf DEV_SITE",
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_static_routes_deleted_all(self):
- set_module_args(dict(state="deleted"))
-
- commands = [
- "no router static",
- ]
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/iosxr/test_iosxr_system.py b/test/units/modules/network/iosxr/test_iosxr_system.py
deleted file mode 100644
index 626f6fe358..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_system.py
+++ /dev/null
@@ -1,101 +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 units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule, load_fixture
-from ansible.modules.network.iosxr import iosxr_system
-
-
-class TestIosxrSystemModule(TestIosxrModule):
-
- module = iosxr_system
-
- def setUp(self):
- super(TestIosxrSystemModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.iosxr.iosxr_system.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.iosxr.iosxr_system.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_is_cliconf = patch('ansible.modules.network.iosxr.iosxr_system.is_cliconf')
- self.is_cliconf = self.mock_is_cliconf.start()
-
- def tearDown(self):
- super(TestIosxrSystemModule, 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('iosxr_system_config.cfg')
- self.load_config.return_value = dict(diff=None, session='session')
- self.is_cliconf.return_value = True
-
- def test_iosxr_system_hostname_changed(self):
- set_module_args(dict(hostname='foo'))
- commands = ['hostname foo', 'no domain lookup disable']
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_system_domain_name(self):
- set_module_args(dict(domain_name='test.com'))
- commands = ['domain name test.com', 'no domain lookup disable']
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_system_domain_search(self):
- set_module_args(dict(domain_search=['ansible.com', 'redhat.com']))
- commands = ['domain list ansible.com', 'no domain list cisco.com', 'no domain lookup disable']
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_system_lookup_source(self):
- set_module_args(dict(lookup_source='Ethernet1'))
- commands = ['domain lookup source-interface Ethernet1', 'no domain lookup disable']
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_system_lookup_enabled(self):
- set_module_args(dict(lookup_enabled=True))
- commands = ['no domain lookup disable']
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_system_name_servers(self):
- name_servers = ['8.8.8.8', '8.8.4.4', '1.1.1.1']
- set_module_args(dict(name_servers=name_servers))
- self.execute_module(changed=True)
-
- def test_iosxr_system_state_absent(self):
- set_module_args(dict(state='absent'))
- commands = [
- 'no hostname',
- 'no domain name',
- 'no domain lookup disable',
- 'no domain lookup source-interface MgmtEth0/0/CPU0/0',
- 'no domain list redhat.com',
- 'no domain list cisco.com',
- 'no domain name-server 8.8.8.8',
- 'no domain name-server 8.8.4.4'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_iosxr_system_no_change(self):
- set_module_args(dict(hostname='iosxr01', domain_name='eng.ansible.com', lookup_enabled=False))
- self.execute_module()
diff --git a/test/units/modules/network/iosxr/test_iosxr_user.py b/test/units/modules/network/iosxr/test_iosxr_user.py
deleted file mode 100644
index 755520fffd..0000000000
--- a/test/units/modules/network/iosxr/test_iosxr_user.py
+++ /dev/null
@@ -1,94 +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.iosxr import iosxr_user
-from units.modules.utils import set_module_args
-from .iosxr_module import TestIosxrModule, load_fixture
-
-
-class TestIosxrUserModule(TestIosxrModule):
-
- module = iosxr_user
-
- def setUp(self):
- super(TestIosxrUserModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.iosxr.iosxr_user.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.iosxr.iosxr_user.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_is_cliconf = patch('ansible.modules.network.iosxr.iosxr_user.is_cliconf')
- self.is_cliconf = self.mock_is_cliconf.start()
-
- def tearDown(self):
- super(TestIosxrUserModule, self).tearDown()
-
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_is_cliconf.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- self.get_config.return_value = load_fixture('iosxr_user_config.cfg')
- self.load_config.return_value = dict(diff=None, session='session')
- self.is_cliconf.return_value = True
-
- def test_iosxr_user_delete(self):
- set_module_args(dict(name='ansible', state='absent'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['no username ansible'])
-
- def test_iosxr_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_iosxr_user_purge(self):
- set_module_args(dict(purge=True))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['no username ansible'])
-
- def test_iosxr_user_group(self):
- set_module_args(dict(name='ansible', group='sysadmin'))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username ansible group sysadmin'])
-
- def test_iosxr_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', 'username test secret test'])
-
- def test_iosxr_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_iosxr_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_iosxr_user_admin_mode(self):
- set_module_args(dict(name='ansible-2', configured_password='test-2', admin=True))
- result = self.execute_module(changed=True)
- self.assertEqual(result['commands'], ['username ansible-2', 'username ansible-2 secret test-2'])