summaryrefslogtreecommitdiff
path: root/test/units/modules/network/eos
diff options
context:
space:
mode:
Diffstat (limited to 'test/units/modules/network/eos')
-rw-r--r--test/units/modules/network/eos/eos_module.py103
-rw-r--r--test/units/modules/network/eos/fixtures/eos_acl_interfaces_config.cfg6
-rw-r--r--test/units/modules/network/eos/fixtures/eos_acls_config.cfg3
-rw-r--r--test/units/modules/network/eos/fixtures/eos_banner_show_banner.txt3
-rw-r--r--test/units/modules/network/eos/fixtures/eos_bgp_config.cfg24
-rw-r--r--test/units/modules/network/eos/fixtures/eos_command_show_version.txt15
-rw-r--r--test/units/modules/network/eos/fixtures/eos_config_candidate.cfg7
-rw-r--r--test/units/modules/network/eos/fixtures/eos_config_config.cfg26
-rw-r--r--test/units/modules/network/eos/fixtures/eos_config_config_updated.cfg26
-rw-r--r--test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt.json47
-rw-r--r--test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt_unconfigured.json42
-rw-r--r--test/units/modules/network/eos/fixtures/eos_eapi_show_vrf.text11
-rw-r--r--test/units/modules/network/eos/fixtures/eos_interfaces_config.cfg5
-rw-r--r--test/units/modules/network/eos/fixtures/eos_l2_interfaces_config.cfg12
-rw-r--r--test/units/modules/network/eos/fixtures/eos_lacp_config.cfg1
-rw-r--r--test/units/modules/network/eos/fixtures/eos_lacp_interfaces_config.cfg4
-rw-r--r--test/units/modules/network/eos/fixtures/eos_logging_config.cfg6
-rw-r--r--test/units/modules/network/eos/fixtures/eos_static_routes_config.cfg3
-rw-r--r--test/units/modules/network/eos/fixtures/eos_static_routes_config1.cfg1
-rw-r--r--test/units/modules/network/eos/fixtures/eos_system_config.cfg12
-rw-r--r--test/units/modules/network/eos/fixtures/eos_user_config.cfg2
-rw-r--r--test/units/modules/network/eos/fixtures/eos_vlan_config.cfg2
-rw-r--r--test/units/modules/network/eos/test_eos_acl_interfaces.py285
-rw-r--r--test/units/modules/network/eos/test_eos_acls.py278
-rw-r--r--test/units/modules/network/eos/test_eos_banner.py85
-rw-r--r--test/units/modules/network/eos/test_eos_bgp.py197
-rw-r--r--test/units/modules/network/eos/test_eos_command.py107
-rw-r--r--test/units/modules/network/eos/test_eos_config.py210
-rw-r--r--test/units/modules/network/eos/test_eos_eapi.py162
-rw-r--r--test/units/modules/network/eos/test_eos_interfaces.py181
-rw-r--r--test/units/modules/network/eos/test_eos_l2_interfaces.py150
-rw-r--r--test/units/modules/network/eos/test_eos_lacp.py106
-rw-r--r--test/units/modules/network/eos/test_eos_lacp_interfaces.py148
-rw-r--r--test/units/modules/network/eos/test_eos_logging.py101
-rw-r--r--test/units/modules/network/eos/test_eos_static_routes.py308
-rw-r--r--test/units/modules/network/eos/test_eos_system.py110
-rw-r--r--test/units/modules/network/eos/test_eos_user.py100
-rw-r--r--test/units/modules/network/eos/test_eos_vlans.py172
38 files changed, 0 insertions, 3061 deletions
diff --git a/test/units/modules/network/eos/eos_module.py b/test/units/modules/network/eos/eos_module.py
deleted file mode 100644
index fb0398cdac..0000000000
--- a/test/units/modules/network/eos/eos_module.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
-import os
-
-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 TestEosModule(ModuleTestCase):
-
- def execute_module(self, failed=False, changed=False, commands=None, inputs=None, sort=True, defaults=False, transport='cli', filename=None):
-
- if filename is None:
- self.load_fixtures(commands, transport=transport)
- else:
- self.load_fixtures(commands, transport=transport, filename=filename)
-
- 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 transport == 'eapi':
- cmd = []
- value = []
- for item in result['commands']:
- cmd.append(item['cmd'])
- if 'input' in item:
- value.append(item['input'])
- if sort:
- self.assertEqual(sorted(commands), sorted(cmd), cmd)
- else:
- self.assertEqual(commands, cmd, cmd)
- if inputs:
- self.assertEqual(inputs, value, value)
- else:
- 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, transport='cli', filename=None):
- pass
diff --git a/test/units/modules/network/eos/fixtures/eos_acl_interfaces_config.cfg b/test/units/modules/network/eos/fixtures/eos_acl_interfaces_config.cfg
deleted file mode 100644
index 3a60567925..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_acl_interfaces_config.cfg
+++ /dev/null
@@ -1,6 +0,0 @@
-interface GigabitEthernet0/0
-ip access-group aclv404 in
-ipv6 access-group aclv601 out
-interface GigabitEthernet0/1
-ipv6 access-group aclv601 in
-
diff --git a/test/units/modules/network/eos/fixtures/eos_acls_config.cfg b/test/units/modules/network/eos/fixtures/eos_acls_config.cfg
deleted file mode 100644
index fa4e4aae57..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_acls_config.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-ip access-list test1
- 35 deny tcp 20.0.0.0/8 any log
- 45 permit tcp any any
diff --git a/test/units/modules/network/eos/fixtures/eos_banner_show_banner.txt b/test/units/modules/network/eos/fixtures/eos_banner_show_banner.txt
deleted file mode 100644
index a134a31753..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_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/eos/fixtures/eos_bgp_config.cfg b/test/units/modules/network/eos/fixtures/eos_bgp_config.cfg
deleted file mode 100644
index 3df62417d1..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_bgp_config.cfg
+++ /dev/null
@@ -1,24 +0,0 @@
-router bgp 64496
- bgp router-id 192.0.2.1
- bgp log-neighbor-changes
- neighbor 198.51.100.102 remote-as 64498
- neighbor 198.51.100.102 timers 300 360
- neighbor 192.0.2.111 remote-as 64496
- neighbor 192.0.2.111 update-source Ethernet1
- neighbor 203.0.113.5 remote-as 64511
- neighbor 203.0.113.5 maximum-routes 500
- redistribute ospf route-map RMAP_1
- address-family ipv4
- neighbor 198.51.100.102 activate
- neighbor 198.51.100.102 graceful-restart
- neighbor 198.51.100.102 default-originate
- neighbor 198.51.100.102 weight 25
- neighbor 192.0.2.111 activate
- neighbor 192.0.2.111 default-originate
- network 192.0.2.0/27 route-map RMAP_1
- network 198.51.100.0/24 route-map RMAP_2
- !
- address-family ipv6
- network 2001:db8:8000::/34
- network 2001:db8:c000::/34
-
diff --git a/test/units/modules/network/eos/fixtures/eos_command_show_version.txt b/test/units/modules/network/eos/fixtures/eos_command_show_version.txt
deleted file mode 100644
index 07c427ba92..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_command_show_version.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-Arista vEOS
-Hardware version:
-Serial number:
-System MAC address: 0050.564a.009e
-
-Software image version: 4.15.4F
-Architecture: i386
-Internal build version: 4.15.4F-2923910.4154F
-Internal build ID: d8a3c846-c735-4766-93cd-82bb7427da51
-
-Uptime: 30 weeks, 3 days, 18 hours and 28 minutes
-Total memory: 1897592 kB
-Free memory: 63424 kB
-
-
diff --git a/test/units/modules/network/eos/fixtures/eos_config_candidate.cfg b/test/units/modules/network/eos/fixtures/eos_config_candidate.cfg
deleted file mode 100644
index b11bc93e25..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_config_candidate.cfg
+++ /dev/null
@@ -1,7 +0,0 @@
-hostname switch01
-!
-interface Ethernet1
- description test interface
- no shutdown
-!
-ip routing
diff --git a/test/units/modules/network/eos/fixtures/eos_config_config.cfg b/test/units/modules/network/eos/fixtures/eos_config_config.cfg
deleted file mode 100644
index 6a471371a5..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_config_config.cfg
+++ /dev/null
@@ -1,26 +0,0 @@
-!
-hostname localhost
-ip domain-name eng.ansible.com
-!
-vrf definition mgmt
-!
-vrf definition test
-!
-interface Management1
- ip address 192.168.1.1/24
-!
-interface Ethernet1
- shutdown
-!
-interface Ethernet2
- shutdown
-!
-interface Ethernet3
- shutdown
-!
-interface Ethernet4
- shutdown
-!
-interface Ethernet5
- shutdown
-!
diff --git a/test/units/modules/network/eos/fixtures/eos_config_config_updated.cfg b/test/units/modules/network/eos/fixtures/eos_config_config_updated.cfg
deleted file mode 100644
index 416cd59974..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_config_config_updated.cfg
+++ /dev/null
@@ -1,26 +0,0 @@
-!
-hostname changed
-ip domain-name eng.ansible.com
-!
-vrf definition mgmt
-!
-vrf definition test
-!
-interface Management1
- ip address 192.168.1.1/24
-!
-interface Ethernet1
- shutdown
-!
-interface Ethernet2
- shutdown
-!
-interface Ethernet3
- shutdown
-!
-interface Ethernet4
- shutdown
-!
-interface Ethernet5
- shutdown
-!
diff --git a/test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt.json b/test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt.json
deleted file mode 100644
index 444d47d30d..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt.json
+++ /dev/null
@@ -1,47 +0,0 @@
-{
- "httpServer": {
- "running": true,
- "configured": true,
- "port": 80
- },
- "users": {
- "admin": {
- "requestCount": 17153,
- "bytesOut": 19950055,
- "lastHitTime": 1484142997.1464522,
- "bytesIn": 3189628
- }
- },
- "localHttpServer": {
- "running": true,
- "configured": true,
- "port": 8080
- },
- "executionTime": 6642.150056908686,
- "dscpValue": 0,
- "bytesOut": 19950055,
- "enabled": true,
- "httpsServer": {
- "running": true,
- "configured": true,
- "port": 443
- },
- "corsOrigins": [],
- "hitCount": 17318,
- "vrf": "default",
- "urls": [
- "Management1 : https://172.26.4.24:443",
- "Management1 : http://172.26.4.24:80",
- "Unix Socket : unix:/var/run/command-api.sock",
- "Local : http://localhost:8080/command-api"
- ],
- "lastHitTime": 1484142997.146127,
- "unixSocketServer": {
- "running": true,
- "configured": true
- },
- "requestCount": 17153,
- "commandCount": 59298,
- "bytesIn": 3189628
-}
-
diff --git a/test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt_unconfigured.json b/test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt_unconfigured.json
deleted file mode 100644
index 8a17b19abc..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_eapi_show_mgmt_unconfigured.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "httpServer": {
- "running": false,
- "configured": false,
- "port": 80
- },
- "users": {
- "admin": {
- "requestCount": 17153,
- "bytesOut": 19950055,
- "lastHitTime": 1484142997.1464522,
- "bytesIn": 3189628
- }
- },
- "localHttpServer": {
- "running": false,
- "configured": false,
- "port": 8080
- },
- "executionTime": 6642.150056908686,
- "dscpValue": 0,
- "bytesOut": 19950055,
- "enabled": false,
- "httpsServer": {
- "running": false,
- "configured": false,
- "port": 443
- },
- "corsOrigins": [],
- "hitCount": 17318,
- "vrf": "default",
- "urls": [],
- "lastHitTime": 1484142997.146127,
- "unixSocketServer": {
- "running": false,
- "configured": false
- },
- "requestCount": 17153,
- "commandCount": 59298,
- "bytesIn": 3189628
-}
-
diff --git a/test/units/modules/network/eos/fixtures/eos_eapi_show_vrf.text b/test/units/modules/network/eos/fixtures/eos_eapi_show_vrf.text
deleted file mode 100644
index b320bdc63a..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_eapi_show_vrf.text
+++ /dev/null
@@ -1,11 +0,0 @@
-Maximum number of vrfs allowed: 14
- Vrf RD Protocols State Interfaces
---------- ----------- --------------- -------------------- --------------------
- mgmt 1:101 ipv4,ipv6 v4:no routing,
- v6:no routing
-
- test 1:100 ipv4,ipv6 v4:routing, Ethernet5, Ethernet6
- v6:no routing
-
-
-
diff --git a/test/units/modules/network/eos/fixtures/eos_interfaces_config.cfg b/test/units/modules/network/eos/fixtures/eos_interfaces_config.cfg
deleted file mode 100644
index 8cd6f1fc00..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_interfaces_config.cfg
+++ /dev/null
@@ -1,5 +0,0 @@
-interface Ethernet1
- description "Interface 1"
-interface Ethernet2
-interface Management1
- description "Management interface"
diff --git a/test/units/modules/network/eos/fixtures/eos_l2_interfaces_config.cfg b/test/units/modules/network/eos/fixtures/eos_l2_interfaces_config.cfg
deleted file mode 100644
index 08f75d18db..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_l2_interfaces_config.cfg
+++ /dev/null
@@ -1,12 +0,0 @@
-interface Ethernet1
- switchport access vlan 20
-!
-interface Ethernet2
- switchport trunk native vlan 20
- switchport mode trunk
-!
-interface Management1
- ip address dhcp
- ipv6 address auto-config
-!
-
diff --git a/test/units/modules/network/eos/fixtures/eos_lacp_config.cfg b/test/units/modules/network/eos/fixtures/eos_lacp_config.cfg
deleted file mode 100644
index 729ece989a..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_lacp_config.cfg
+++ /dev/null
@@ -1 +0,0 @@
-lacp system-priority 10
diff --git a/test/units/modules/network/eos/fixtures/eos_lacp_interfaces_config.cfg b/test/units/modules/network/eos/fixtures/eos_lacp_interfaces_config.cfg
deleted file mode 100644
index 452e2a9f90..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_lacp_interfaces_config.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-interface Ethernet1
- lacp port-priority 30
-interface Ethernet2
- lacp rate fast
diff --git a/test/units/modules/network/eos/fixtures/eos_logging_config.cfg b/test/units/modules/network/eos/fixtures/eos_logging_config.cfg
deleted file mode 100644
index 192835906c..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_logging_config.cfg
+++ /dev/null
@@ -1,6 +0,0 @@
-!
-logging host 175.16.0.10
-logging console warnings
-logging buffered 50000 informational
-logging facility local7
-!
diff --git a/test/units/modules/network/eos/fixtures/eos_static_routes_config.cfg b/test/units/modules/network/eos/fixtures/eos_static_routes_config.cfg
deleted file mode 100644
index 6ec815d7dc..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_static_routes_config.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-ip route 10.1.1.0/24 Management1
-ip route vrf testvrf 120.1.1.0/24 Ethernet1 23
-ipv6 route 1000:10::/64 Ethernet1 67 tag 98
diff --git a/test/units/modules/network/eos/fixtures/eos_static_routes_config1.cfg b/test/units/modules/network/eos/fixtures/eos_static_routes_config1.cfg
deleted file mode 100644
index db829ee8c1..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_static_routes_config1.cfg
+++ /dev/null
@@ -1 +0,0 @@
-ip route 10.1.1.0/24 Management1
diff --git a/test/units/modules/network/eos/fixtures/eos_system_config.cfg b/test/units/modules/network/eos/fixtures/eos_system_config.cfg
deleted file mode 100644
index 08837ec406..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_system_config.cfg
+++ /dev/null
@@ -1,12 +0,0 @@
-!
-hostname switch01
-ip domain lookup source-interface Management1
-ip name-server vrf mgmt 8.8.4.4
-ip name-server vrf default 8.8.8.8
-ip domain-name eng.ansible.com
-ip domain-list ansible.com
-ip domain-list ops.ansible.com
-!
-vrf definition mgmt
-!
-vrf definition test
diff --git a/test/units/modules/network/eos/fixtures/eos_user_config.cfg b/test/units/modules/network/eos/fixtures/eos_user_config.cfg
deleted file mode 100644
index 76d7695378..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_user_config.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-username admin role network-admin secret 5 $1$mdQIUxjg$3t3lzBpfKfITKvFm1uEIY.
-username ansible role network-admin secret 5 $1$3yWSXiIi$VdzV59ChiurrNdGxlDeAW/
diff --git a/test/units/modules/network/eos/fixtures/eos_vlan_config.cfg b/test/units/modules/network/eos/fixtures/eos_vlan_config.cfg
deleted file mode 100644
index 25d26a3602..0000000000
--- a/test/units/modules/network/eos/fixtures/eos_vlan_config.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-vlan_id 10
- name ten
diff --git a/test/units/modules/network/eos/test_eos_acl_interfaces.py b/test/units/modules/network/eos/test_eos_acl_interfaces.py
deleted file mode 100644
index f0e28d177c..0000000000
--- a/test/units/modules/network/eos/test_eos_acl_interfaces.py
+++ /dev/null
@@ -1,285 +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.eos import eos_acl_interfaces
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosAclInterfacesModule(TestEosModule):
- module = eos_acl_interfaces
-
- def setUp(self):
- super(TestEosAclInterfacesModule, 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.eos.providers.providers.CliProvider.edit_config'
- )
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch(
- 'ansible.module_utils.network.eos.facts.acl_interfaces.acl_interfaces.Acl_interfacesFacts.get_device_data'
- )
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosAclInterfacesModule, 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', filename=None):
- if filename is None:
- filename = 'eos_acl_interfaces_config.cfg'
-
- def load_from_file(*args, **kwargs):
- output = load_fixture(filename)
- return output
-
- self.execute_show_command.side_effect = load_from_file
-
- def test_eos_acl_interfaces_merged(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv401",
- direction="in"),
- dict(name="aclv402",
- direction="out")
- ]),
- dict(afi="ipv6",
- acls=[
- dict(name="aclv601",
- direction="in")
- ])
- ]),
- dict(name="GigabitEthernet0/1",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv401",
- direction="in")
- ])
- ])
- ], state="merged"))
- commands = ['interface GigabitEthernet0/0', 'ip access-group aclv401 in',
- 'ip access-group aclv402 out', 'ipv6 access-group aclv601 in', 'interface GigabitEthernet0/1',
- 'ip access-group aclv401 in']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acl_interfaces_merged_idempotent(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv404",
- direction="in"),
- ]),
- dict(afi="ipv6",
- acls=[dict(name="aclv601", direction="out")])
- ]),
- dict(name="GigabitEthernet0/1",
- access_groups=[
- dict(afi="ipv6",
- acls=[dict(name="aclv601", direction="in")])
- ])
- ], state="merged"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_acl_interfaces_replaced(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv401",
- direction="in"),
- dict(name="aclv402",
- direction="out")
- ]),
- ])
- ], state="replaced"))
- commands = ['interface GigabitEthernet0/0', 'no ip access-group aclv404 in',
- 'no ipv6 access-group aclv601 out', 'ip access-group aclv402 out',
- 'ip access-group aclv401 in']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acl_interfaces_replaced_idempotent(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv404",
- direction="in"),
- ]),
- dict(afi="ipv6",
- acls=[dict(name="aclv601", direction="out")])
- ]),
- ], state="replaced"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_acl_interfaces_overridden(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv401",
- direction="in"),
- dict(name="aclv402",
- direction="out")
- ]),
- ])
- ], state="overridden"))
- commands = ['interface GigabitEthernet0/0', 'no ip access-group aclv404 in',
- 'no ipv6 access-group aclv601 out', 'ip access-group aclv402 out',
- 'ip access-group aclv401 in', 'interface GigabitEthernet0/1',
- 'no ipv6 access-group aclv601 in']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acl_interfaces_overridden_idempotent(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv404",
- direction="in"),
- ]),
- dict(afi="ipv6",
- acls=[dict(name="aclv601", direction="out")])
- ]),
- dict(name="GigabitEthernet0/1",
- access_groups=[
- dict(afi="ipv6",
- acls=[
- dict(name="aclv601",
- direction="in")
- ])
- ])
- ], state="overridden"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_acl_interfaces_deletedafi(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv6")])
- ], state="deleted"))
- commands = ['interface GigabitEthernet0/0', 'no ipv6 access-group aclv601 out']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acl_interfaces_deletedint(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0")
- ], state="deleted"))
- commands = ['interface GigabitEthernet0/0', 'no ipv6 access-group aclv601 out',
- 'no ip access-group aclv404 in']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acl_interfaces_deletedacl(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv404",
- direction="in"),
- ]),
- ])
- ], state="deleted"))
- commands = ['interface GigabitEthernet0/0', 'no ip access-group aclv404 in']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acl_interfaces_gathered(self):
- set_module_args(
- dict(state="gathered"))
- result = self.execute_module(changed=False, filename='eos_acl_interfaces_config.cfg')
- gathered_list = [{'access_groups': [{'acls': [{'direction': 'in', 'name': 'aclv404'}], 'afi': 'ipv4'},
- {'acls': [{'direction': 'out', 'name': 'aclv601'}], 'afi': 'ipv6'}],
- 'name': 'GigabitEthernet0/0'},
- {'access_groups': [{'acls': [{'direction': 'in', 'name': 'aclv601'}], 'afi': 'ipv6'}],
- 'name': 'GigabitEthernet0/1'}]
- self.assertEqual(gathered_list, result['gathered'])
-
- def test_eos_acl_interfaces_parsed(self):
- set_module_args(
- dict(running_config="interface GigabitEthernet0/0\nipv6 access-group aclv601 out\nip access-group aclv404 in",
- state="parsed"))
- result = self.execute_module(changed=False)
- parsed_list = [{'access_groups': [{'acls': [{'direction': 'in', 'name': 'aclv404'}], 'afi': 'ipv4'},
- {'acls': [{'direction': 'out', 'name': 'aclv601'}], 'afi': 'ipv6'}],
- 'name': 'GigabitEthernet0/0'}]
- self.assertEqual(parsed_list, result['parsed'])
-
- def test_eos_acl_interfaces_rendered(self):
- set_module_args(
- dict(config=[
- dict(name="GigabitEthernet0/0",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv401",
- direction="in"),
- dict(name="aclv402",
- direction="out")
- ]),
- dict(afi="ipv6",
- acls=[dict(name="aclv601", direction="in")])
- ]),
- dict(name="GigabitEthernet0/1",
- access_groups=[
- dict(afi="ipv4",
- acls=[
- dict(name="aclv401",
- direction="in")
- ])
- ])
- ], state="rendered"))
- commands = ['interface GigabitEthernet0/0', 'ip access-group aclv401 in',
- 'ip access-group aclv402 out', 'ipv6 access-group aclv601 in', 'interface GigabitEthernet0/1',
- 'ip access-group aclv401 in']
- result = self.execute_module(changed=False)
- self.assertEqual(sorted(result['rendered']), sorted(commands), result['rendered'])
diff --git a/test/units/modules/network/eos/test_eos_acls.py b/test/units/modules/network/eos/test_eos_acls.py
deleted file mode 100644
index 6a0947d2d2..0000000000
--- a/test/units/modules/network/eos/test_eos_acls.py
+++ /dev/null
@@ -1,278 +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.eos import eos_acls
-from ansible.module_utils.network.eos.config.acls.acls import add_commands
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-import itertools
-
-
-class TestEosAclsModule(TestEosModule):
- module = eos_acls
-
- def setUp(self):
- super(TestEosAclsModule, 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.eos.providers.providers.CliProvider.edit_config'
- )
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch(
- 'ansible.module_utils.network.eos.facts.acls.acls.AclsFacts.get_device_data'
- )
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosAclsModule, 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', filename=None):
- if filename is None:
- filename = 'eos_acls_config.cfg'
-
- def load_from_file(*args, **kwargs):
- output = load_fixture(filename)
- return output
-
- self.execute_show_command.side_effect = load_from_file
-
- def test_eos_acls_merged(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv6",
- acls=[
- dict(name="test2",
- standard="true",
- aces=[
- dict(sequence="10",
- grant="permit",
- protocol="ospf",
- source=dict(subnet_address="30.2.0.0/8"),
- destination=dict(any="true"),
- log="true")
- ])
- ])
- ], state="merged"))
- commands = ['ipv6 access-list standard test2', '10 permit ospf 30.2.0.0/8 any log']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acls_merged_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1",
- aces=[
- dict(sequence="35",
- grant="deny",
- protocol="tcp",
- source=dict(subnet_address="20.0.0.0/8"),
- destination=dict(any="true"),
- log="true"),
- dict(grant="permit",
- source=dict(any="true"),
- destination=dict(any="true"),
- protocol=6)
- ])
- ])
- ], state="merged"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_acls_replaced(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1",
- aces=[
- dict(sequence="10",
- grant="permit",
- protocol="ospf",
- source=dict(subnet_address="30.2.0.0/8"),
- destination=dict(any="true"),
- log="true")
- ])
- ])
- ], state="replaced"))
- commands = ['ip access-list test1', 'no 35', 'no 45', '10 permit ospf 30.2.0.0/8 any log']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acls_replaced_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1",
- aces=[
- dict(sequence="35",
- grant="deny",
- protocol="tcp",
- source=dict(subnet_address="20.0.0.0/8"),
- destination=dict(any="true"),
- log="true"),
- dict(grant="permit",
- source=dict(any="true"),
- destination=dict(any="true"),
- sequence="45",
- protocol="tcp")
- ])
- ])
- ], state="replaced"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_acls_overridden(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1",
- aces=[
- dict(sequence="10",
- grant="permit",
- protocol="ospf",
- source=dict(subnet_address="30.2.0.0/8"),
- destination=dict(any="true"),
- log="true")
- ])
- ])
- ], state="overridden"))
- commands = ['ip access-list test1', 'no 35', 'no 45', 'ip access-list test1', '10 permit ospf 30.2.0.0/8 any log']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acls_overridden_idempotent(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1",
- aces=[
- dict(sequence="35",
- grant="deny",
- protocol="tcp",
- source=dict(subnet_address="20.0.0.0/8"),
- destination=dict(any="true"),
- log="true"),
- dict(grant="permit",
- source=dict(any="true"),
- destination=dict(any="true"),
- sequence="45",
- protocol="tcp")
- ])
- ])
- ], state="overridden"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_acls_deletedaces(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1",
- aces=[
- dict(grant="permit",
- sequence="45",
- source=dict(any="true"),
- destination=dict(any="true"),
- protocol=6)
- ])
- ])
- ], state="deleted"))
- commands = ['ip access-list test1', 'no 45']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acls_deletedacls(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1")
- ])
- ], state="deleted"))
- commands = ['no ip access-list test1']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acls_deletedafis(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4")
- ], state="deleted"))
- commands = ['no ip access-list test1']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_acls_gathered(self):
- set_module_args(
- dict(config=[],
- state="gathered"))
- result = self.execute_module(changed=False, filename='eos_acls_config.cfg')
- commands = []
- for gathered_cmds in result['gathered']:
- cfg = add_commands(gathered_cmds)
- commands.append(cfg)
- commands = list(itertools.chain(*commands))
- config_commands = ['ip access-list test1', '35 deny tcp 20.0.0.0/8 any log', '45 permit tcp any any']
- self.assertEqual(sorted(config_commands), sorted(commands), result['gathered'])
-
- def test_eos_acls_rendered(self):
- set_module_args(
- dict(config=[
- dict(afi="ipv4",
- acls=[
- dict(name="test1",
- aces=[
- dict(grant="permit",
- sequence="45",
- source=dict(any="true"),
- destination=dict(any="true"),
- protocol=6)
- ])
- ])
- ], state="rendered"))
- commands = ['ip access-list test1', '45 permit tcp any any']
- result = self.execute_module(changed=False)
- self.assertEqual(sorted(result['rendered']), sorted(commands), result['rendered'])
-
- def test_eos_acls_parsed(self):
- set_module_args(
- dict(running_config="ipv6 access-list test2\n 10 permit icmpv6 host 10.2.33.1 any ttl eq 25",
- state="parsed"))
- commands = ['ipv6 access-list test2', '10 permit icmpv6 host 10.2.33.1 any ttl eq 25']
- result = self.execute_module(changed=False)
- parsed_commands = []
- for cmds in result['parsed']:
- cfg = add_commands(cmds)
- parsed_commands.append(cfg)
- parsed_commands = list(itertools.chain(*parsed_commands))
- self.assertEqual(sorted(parsed_commands), sorted(commands), result['parsed'])
diff --git a/test/units/modules/network/eos/test_eos_banner.py b/test/units/modules/network/eos/test_eos_banner.py
deleted file mode 100644
index 611aff6dc5..0000000000
--- a/test/units/modules/network/eos/test_eos_banner.py
+++ /dev/null
@@ -1,85 +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.eos import eos_banner
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-CLI = dict(transport="cli")
-EAPI = dict(transport="eapi")
-
-
-class TestEosBannerModule(TestEosModule):
-
- module = eos_banner
-
- def setUp(self):
- super(TestEosBannerModule, self).setUp()
-
- self.mock_run_commands = patch('ansible.modules.network.eos.eos_banner.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- self.mock_load_config = patch('ansible.modules.network.eos.eos_banner.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestEosBannerModule, self).tearDown()
-
- self.mock_run_commands.stop()
- self.mock_load_config.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- if transport == 'cli':
- self.run_commands.return_value = [load_fixture('eos_banner_show_banner.txt').strip()]
- else:
- self.run_commands.return_value = [{'loginBanner': load_fixture('eos_banner_show_banner.txt').strip()}]
-
- self.load_config.return_value = dict(diff=None, session='session')
-
- def test_eos_banner_create_with_cli_transport(self):
- set_module_args(dict(banner='login', text='test\nbanner\nstring', provider=CLI))
- commands = ['banner login', 'test', 'banner', 'string', 'EOF']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_banner_remove_with_cli_transport(self):
- set_module_args(dict(banner='login', state='absent', provider=CLI))
- commands = ['no banner login']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_banner_create_with_eapi_transport(self):
- set_module_args(dict(banner='login', text='test\nbanner\nstring', provider=EAPI))
- commands = ['banner login']
- inputs = ['test\nbanner\nstring']
- self.execute_module(changed=True, commands=commands, inputs=inputs, transport='eapi')
-
- def test_eos_banner_remove_with_eapi_transport(self):
- set_module_args(dict(banner='login', state='absent', provider=EAPI))
- commands = ['no banner login']
- self.execute_module(changed=True, commands=commands, transport='eapi')
-
- def test_eos_banner_nochange_with_cli_transport(self):
- banner_text = load_fixture('eos_banner_show_banner.txt').strip()
- set_module_args(dict(banner='login', text=banner_text, provider=CLI))
- self.execute_module()
-
- def test_eos_banner_nochange_with_eapi_transport(self):
- banner_text = load_fixture('eos_banner_show_banner.txt').strip()
- set_module_args(dict(banner='login', text=banner_text, provider=EAPI))
- self.execute_module(transport='eapi')
diff --git a/test/units/modules/network/eos/test_eos_bgp.py b/test/units/modules/network/eos/test_eos_bgp.py
deleted file mode 100644
index d39f80feeb..0000000000
--- a/test/units/modules/network/eos/test_eos_bgp.py
+++ /dev/null
@@ -1,197 +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.eos.providers.cli.config.bgp.process import Provider
-from ansible.modules.network.eos import eos_bgp
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestFrrBgpModule(TestEosModule):
- module = eos_bgp
-
- def setUp(self):
- super(TestFrrBgpModule, self).setUp()
- self._bgp_config = load_fixture('eos_bgp_config.cfg')
-
- def test_eos_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', 'router-id 192.0.2.2', 'exit'])
-
- def test_eos_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_eos_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_eos_bgp_neighbor(self):
- obj = Provider(params=dict(config=dict(bgp_as=64496, neighbors=[dict(neighbor='198.51.100.12', remote_as=64498)],
- networks=None, address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, ['router bgp 64496', 'neighbor 198.51.100.12 remote-as 64498', 'exit'])
-
- def test_eos_bgp_neighbor_idempotent(self):
- neighbors = [dict(neighbor='198.51.100.102', remote_as=64498, timers=dict(keepalive=300, holdtime=360)),
- dict(neighbor='203.0.113.5', remote_as=64511, maximum_prefix=500)]
- obj = Provider(params=dict(config=dict(bgp_as=64496, neighbors=neighbors, networks=None, address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_eos_bgp_network(self):
- obj = Provider(
- params=dict(config=dict(bgp_as=64496, networks=[dict(prefix='203.0.113.0', masklen=24, route_map='RMAP_1')],
- address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(sorted(commands), sorted(['router bgp 64496', 'network 203.0.113.0/24 route-map RMAP_1', 'exit']))
-
- def test_eos_bgp_network_idempotent(self):
- obj = Provider(
- params=dict(config=dict(bgp_as=64496, networks=[dict(prefix='192.0.2.0', masklen=27, route_map='RMAP_1'),
- dict(prefix='198.51.100.0', masklen=24, route_map='RMAP_2')],
- address_family=None),
- operation='merge'))
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_eos_bgp_redistribute(self):
- rd_1 = dict(protocol='rip', route_map='RMAP_1')
-
- config = dict(bgp_as=64496, redistribute=[rd_1], networks=None, address_family=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- cmd = ['router bgp 64496', 'redistribute rip route-map RMAP_1', 'exit']
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_eos_bgp_redistribute_idempotent(self):
- rd_1 = dict(protocol='ospf', route_map='RMAP_1')
- config = dict(bgp_as=64496, redistribute=[rd_1], networks=None, address_family=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_eos_bgp_address_family_neighbors(self):
- af_nbr_1 = dict(neighbor='198.51.100.104', default_originate=True, activate=True)
- af_nbr_2 = dict(neighbor='198.51.100.105', activate=True, weight=30, graceful_restart=True)
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', 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', 'neighbor 198.51.100.104 activate',
- 'neighbor 198.51.100.104 default-originate', 'neighbor 198.51.100.105 weight 30',
- 'neighbor 198.51.100.105 activate', 'neighbor 198.51.100.105 graceful-restart', 'exit', 'exit']
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_eos_bgp_address_family_neighbors_idempotent(self):
- af_nbr_1 = dict(neighbor='198.51.100.102', activate=True, graceful_restart=True, default_originate=True, weight=25)
- af_nbr_2 = dict(neighbor='192.0.2.111', activate=True, default_originate=True)
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', neighbors=[af_nbr_1, af_nbr_2])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_eos_bgp_address_family_networks(self):
- net = dict(prefix='203.0.113.128', masklen=26, route_map='RMAP_1')
- net2 = dict(prefix='203.0.113.192', masklen=26, route_map='RMAP_2')
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv4', 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', 'network 203.0.113.128/26 route-map RMAP_1',
- 'network 203.0.113.192/26 route-map RMAP_2', 'exit', 'exit']
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_eos_bgp_address_family_networks_idempotent(self):
- net = dict(prefix='2001:db8:8000::', masklen=34, route_map=None)
- net2 = dict(prefix='2001:db8:c000::', masklen=34, route_map=None)
-
- config = dict(bgp_as=64496, address_family=[dict(afi='ipv6', networks=[net, net2])],
- networks=None)
-
- obj = Provider(params=dict(config=config, operation='merge'))
-
- commands = obj.render(self._bgp_config)
- self.assertEqual(commands, [])
-
- def test_eos_bgp_operation_override(self):
- net_1 = dict(prefix='2001:0db8:0800::', masklen=38, route_map='RMAP_1')
- net_2 = dict(prefix='2001:0db8:1c00::', masklen=38, route_map='RMAP_2')
- nbr_1 = dict(neighbor='203.0.113.111', remote_as=64511, update_source='Ethernet2')
- nbr_2 = dict(neighbor='203.0.113.120', remote_as=64511, timers=dict(keepalive=300, holdtime=360))
- af_nbr_1 = dict(neighbor='203.0.113.111', activate=True)
- af_nbr_2 = dict(neighbor='203.0.113.120', activate=True, default_originate=True)
-
- af_1 = dict(afi='ipv4', neighbors=[af_nbr_1, af_nbr_2])
- af_2 = dict(afi='ipv6', 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 203.0.113.111 remote-as 64511',
- 'neighbor 203.0.113.111 update-source Ethernet2', 'neighbor 203.0.113.120 remote-as 64511',
- 'neighbor 203.0.113.120 timers 300 360', 'address-family ipv4',
- 'neighbor 203.0.113.111 activate', 'neighbor 203.0.113.120 default-originate', 'neighbor 203.0.113.120 activate',
- 'exit', 'address-family ipv6', 'network 2001:0db8:0800::/38 route-map RMAP_1',
- 'network 2001:0db8:1c00::/38 route-map RMAP_2',
- 'exit', 'exit']
-
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_eos_bgp_operation_replace(self):
- net = dict(prefix='203.0.113.0', masklen=27, route_map='RMAP_1')
- net2 = dict(prefix='192.0.2.32', masklen=29, route_map='RMAP_2')
- net_3 = dict(prefix='2001:db8:8000::', masklen=34, route_map=None)
- net_4 = dict(prefix='2001:db8:c000::', masklen=34, route_map=None)
-
- af_1 = dict(afi='ipv4', networks=[net, net2])
- af_2 = dict(afi='ipv6', networks=[net_3, net_4])
-
- 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', 'network 203.0.113.0/27 route-map RMAP_1',
- 'network 192.0.2.32/29 route-map RMAP_2', 'no network 192.0.2.0/27', 'no network 198.51.100.0/24',
- 'exit', 'exit']
-
- self.assertEqual(sorted(commands), sorted(cmd))
-
- def test_eos_bgp_operation_replace_with_new_as(self):
- nbr = dict(neighbor='203.0.113.124', remote_as=64496, update_source='Ethernet3')
-
- config = dict(bgp_as=64497, neighbors=[nbr], networks=None, address_family=None)
- obj = Provider(params=dict(config=config, operation='replace'))
- commands = obj.render(self._bgp_config)
-
- cmd = ['no router bgp 64496', 'router bgp 64497', 'neighbor 203.0.113.124 remote-as 64496',
- 'neighbor 203.0.113.124 update-source Ethernet3', 'exit']
-
- self.assertEqual(sorted(commands), sorted(cmd))
diff --git a/test/units/modules/network/eos/test_eos_command.py b/test/units/modules/network/eos/test_eos_command.py
deleted file mode 100644
index da4ce25838..0000000000
--- a/test/units/modules/network/eos/test_eos_command.py
+++ /dev/null
@@ -1,107 +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.eos import eos_command
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosCommandModule(TestEosModule):
-
- module = eos_command
-
- def setUp(self):
- super(TestEosCommandModule, self).setUp()
- self.mock_run_commands = patch('ansible.modules.network.eos.eos_command.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- def tearDown(self):
- super(TestEosCommandModule, self).tearDown()
- self.mock_run_commands.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- 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(' ', '_')
- filename = 'eos_command_%s.txt' % filename
- output.append(load_fixture(filename))
- return output
-
- self.run_commands.side_effect = load_from_file
-
- def test_eos_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('Arista'))
-
- def test_eos_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('Arista'))
-
- def test_eos_command_wait_for(self):
- wait_for = 'result[0] contains "Arista vEOS"'
- set_module_args(dict(commands=['show version'], wait_for=wait_for))
- self.execute_module()
-
- def test_eos_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_eos_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_eos_command_match_any(self):
- wait_for = ['result[0] contains "Arista"',
- 'result[0] contains "test string"']
- set_module_args(dict(commands=['show version'], wait_for=wait_for, match='any'))
- self.execute_module()
-
- def test_eos_command_match_all(self):
- wait_for = ['result[0] contains "Arista"',
- 'result[0] contains "Software image"']
- set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all'))
- self.execute_module()
-
- def test_eos_command_match_all_failure(self):
- wait_for = ['result[0] contains "Arista"',
- '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/eos/test_eos_config.py b/test/units/modules/network/eos/test_eos_config.py
deleted file mode 100644
index 98f3dbf6d0..0000000000
--- a/test/units/modules/network/eos/test_eos_config.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, MagicMock
-from ansible.modules.network.eos import eos_config
-from ansible.plugins.cliconf.eos import Cliconf
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosConfigModule(TestEosModule):
-
- module = eos_config
-
- def setUp(self):
- super(TestEosConfigModule, self).setUp()
- self.mock_get_config = patch('ansible.modules.network.eos.eos_config.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_get_connection = patch('ansible.modules.network.eos.eos_config.get_connection')
- self.get_connection = self.mock_get_connection.start()
-
- self.mock_load_config = patch('ansible.modules.network.eos.eos_config.load_config')
- self.load_config = self.mock_load_config.start()
- self.mock_run_commands = patch('ansible.modules.network.eos.eos_config.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- self.mock_supports_sessions = patch('ansible.plugins.cliconf.eos.Cliconf.supports_sessions')
- self.supports_sessions = self.mock_supports_sessions.start()
- self.mock_supports_sessions.return_value = True
-
- self.conn = self.get_connection()
- self.conn.edit_config = MagicMock()
-
- self.cliconf_obj = Cliconf(MagicMock())
- self.running_config = load_fixture('eos_config_config.cfg')
-
- def tearDown(self):
- super(TestEosConfigModule, self).tearDown()
- self.mock_get_config.stop()
- self.mock_load_config.stop()
- self.mock_get_connection.stop()
- self.mock_supports_sessions.stop()
-
- def load_fixtures(self, commands=None, transport='cli'):
- self.get_config.return_value = load_fixture('eos_config_config.cfg')
- self.load_config.return_value = dict(diff=None, session='session')
-
- def test_eos_config_no_change(self):
- lines = ['hostname localhost']
- config = '\n'.join(lines)
- args = dict(lines=lines)
- set_module_args(args)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(config, config))
- self.execute_module()
-
- def test_eos_config_src(self):
- src = load_fixture('eos_config_candidate.cfg')
- args = dict(src=src)
- set_module_args(args)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff(src, self.running_config))
- result = self.execute_module(changed=True)
- config = ['hostname switch01', 'interface Ethernet1',
- 'description test interface', 'no shutdown', 'ip routing']
- self.assertEqual(sorted(config), sorted(result['commands']), result['commands'])
-
- def test_eos_config_lines(self):
- lines = ['hostname switch01', 'ip domain-name eng.ansible.com']
- args = dict(lines=lines)
- set_module_args(args)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- result = self.execute_module(changed=True)
- config = ['hostname switch01']
-
- self.assertEqual(sorted(config), sorted(result['commands']), result['commands'])
-
- def test_eos_config_before(self):
- lines = ['hostname switch01', 'ip domain-name eng.ansible.com']
- before = ['before command']
- args = dict(lines=lines,
- before=before)
- set_module_args(args)
-
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- result = self.execute_module(changed=True)
- config = ['before command', 'hostname switch01']
- self.assertEqual(sorted(config), sorted(result['commands']), result['commands'])
- self.assertEqual('before command', result['commands'][0])
-
- def test_eos_config_after(self):
- lines = ['hostname switch01', 'ip domain-name eng.ansible.com']
- args = dict(lines=lines,
- after=['after command'])
-
- set_module_args(args)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(lines), self.running_config))
- result = self.execute_module(changed=True)
- config = ['after command', 'hostname switch01']
-
- self.assertEqual(sorted(config), sorted(result['commands']), result['commands'])
- self.assertEqual('after command', result['commands'][-1])
-
- def test_eos_config_parents(self):
- lines = ['ip address 1.2.3.4/5', 'no shutdown']
- parents = ['interface Ethernet10']
- args = dict(lines=lines, parents=parents)
- candidate = parents + lines
- set_module_args(args)
- self.conn.get_diff = MagicMock(return_value=self.cliconf_obj.get_diff('\n'.join(candidate), self.running_config))
-
- result = self.execute_module(changed=True)
- config = ['interface Ethernet10', 'ip address 1.2.3.4/5', 'no shutdown']
-
- self.assertEqual(config, result['commands'], result['commands'])
-
- def test_eos_config_src_and_lines_fails(self):
- args = dict(src='foo', lines='foo')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_eos_config_match_exact_requires_lines(self):
- args = dict(match='exact')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_eos_config_match_strict_requires_lines(self):
- args = dict(match='strict')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_eos_config_replace_block_requires_lines(self):
- args = dict(replace='block')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_eos_config_replace_config_requires_src(self):
- args = dict(replace='config')
- set_module_args(args)
- self.execute_module(failed=True)
-
- def test_eos_config_backup_returns__backup__(self):
- args = dict(backup=True)
- set_module_args(args)
- result = self.execute_module()
- self.assertIn('__backup__', result)
-
- def test_eos_config_save_when(self):
- mock_run_commands = patch('ansible.modules.network.eos.eos_config.run_commands')
- run_commands = mock_run_commands.start()
-
- run_commands.return_value = [load_fixture('eos_config_config.cfg'),
- load_fixture('eos_config_config.cfg')]
-
- args = dict(save_when='modified')
- set_module_args(args)
- self.execute_module()
-
- run_commands.return_value = [load_fixture('eos_config_config.cfg'),
- load_fixture('eos_config_config_updated.cfg')]
-
- args = dict(save_when='modified')
- set_module_args(args)
- self.execute_module(changed=True)
-
- mock_run_commands.stop()
-
- def test_eos_config_save_changed_true(self):
- commands = ['hostname foo', 'interface GigabitEthernet0/0', 'no ip address']
- set_module_args(dict(save_when='changed', lines=commands))
- self.execute_module(changed=True)
- self.assertEqual(self.run_commands.call_count, 1)
- self.assertEqual(self.get_config.call_count, 1)
- self.assertEqual(self.load_config.call_count, 1)
- args = self.run_commands.call_args[0][1][0]['command']
- self.assertIn('copy running-config startup-config', args)
-
- def test_eos_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.load_config.call_count, 0)
-
- def test_eos_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.load_config.call_count, 0)
- args = self.run_commands.call_args[0][1][0]['command']
- self.assertIn('copy running-config startup-config', args)
diff --git a/test/units/modules/network/eos/test_eos_eapi.py b/test/units/modules/network/eos/test_eos_eapi.py
deleted file mode 100644
index 09ff08cdf2..0000000000
--- a/test/units/modules/network/eos/test_eos_eapi.py
+++ /dev/null
@@ -1,162 +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.eos import eos_eapi
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosEapiModule(TestEosModule):
-
- module = eos_eapi
-
- def setUp(self):
- super(TestEosEapiModule, self).setUp()
-
- self.mock_run_commands = patch('ansible.modules.network.eos.eos_eapi.run_commands')
- self.run_commands = self.mock_run_commands.start()
-
- self.mock_load_config = patch('ansible.modules.network.eos.eos_eapi.load_config')
- self.load_config = self.mock_load_config.start()
-
- self.mock_verify_state = patch('ansible.modules.network.eos.eos_eapi.verify_state')
- self.verify_state = self.mock_verify_state.start()
-
- self.command_fixtures = {}
-
- def tearDown(self):
- super(TestEosEapiModule, self).tearDown()
-
- self.mock_run_commands.stop()
- self.mock_load_config.stop()
-
- # hack for older version of mock
- # should be using patch.stopall() but CI is still failing
- try:
- self.mock_verify_state.stop()
- except RuntimeError:
- pass
-
- def load_fixtures(self, commands=None, transport='eapi'):
- def run_commands(module, commands, **kwargs):
- output = list()
- for cmd in commands:
- output.append(load_fixture(self.command_fixtures[cmd]))
- return output
-
- self.run_commands.side_effect = run_commands
- self.load_config.return_value = dict(diff=None, session='session')
-
- def start_configured(self, *args, **kwargs):
- self.command_fixtures = {
- 'show vrf': 'eos_eapi_show_vrf.text',
- 'show management api http-commands | json': 'eos_eapi_show_mgmt.json'
- }
- return self.execute_module(*args, **kwargs)
-
- def start_unconfigured(self, *args, **kwargs):
- self.command_fixtures = {
- 'show vrf': 'eos_eapi_show_vrf.text',
- 'show management api http-commands | json': 'eos_eapi_show_mgmt_unconfigured.json'
- }
- return self.execute_module(*args, **kwargs)
-
- def test_eos_eapi_http_enable(self):
- set_module_args(dict(http=True))
- commands = ['management api http-commands', 'protocol http port 80',
- 'no shutdown']
- self.start_unconfigured(changed=True, commands=commands)
-
- def test_eos_eapi_http_disable(self):
- set_module_args(dict(http=False))
- commands = ['management api http-commands', 'no protocol http']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_http_port(self):
- set_module_args(dict(http_port=81))
- commands = ['management api http-commands', 'protocol http port 81']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_http_invalid(self):
- set_module_args(dict(http_port=80000))
- self.start_unconfigured(failed=True)
-
- def test_eos_eapi_https_enable(self):
- set_module_args(dict(https=True))
- commands = ['management api http-commands', 'protocol https port 443',
- 'no shutdown']
- self.start_unconfigured(changed=True, commands=commands)
-
- def test_eos_eapi_https_disable(self):
- set_module_args(dict(https=False))
- commands = ['management api http-commands', 'no protocol https']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_https_port(self):
- set_module_args(dict(https_port=8443))
- commands = ['management api http-commands', 'protocol https port 8443']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_local_http_enable(self):
- set_module_args(dict(local_http=True))
- commands = ['management api http-commands', 'protocol http localhost port 8080',
- 'no shutdown']
- self.start_unconfigured(changed=True, commands=commands)
-
- def test_eos_eapi_local_http_disable(self):
- set_module_args(dict(local_http=False))
- commands = ['management api http-commands', 'no protocol http localhost']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_local_http_port(self):
- set_module_args(dict(local_http_port=81))
- commands = ['management api http-commands', 'protocol http localhost port 81']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_vrf(self):
- set_module_args(dict(vrf='test'))
- commands = ['management api http-commands', 'no shutdown', 'vrf test', 'no shutdown']
- self.start_unconfigured(changed=True, commands=commands)
-
- def test_eos_eapi_change_from_default_vrf(self):
- set_module_args(dict(vrf='test'))
- commands = ['management api http-commands', 'vrf test', 'no shutdown']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_default(self):
- set_module_args(dict())
- self.start_configured(changed=False, commands=[])
-
- def test_eos_eapi_vrf_missing(self):
- set_module_args(dict(vrf='missing'))
- self.start_unconfigured(failed=True)
-
- def test_eos_eapi_state_absent(self):
- set_module_args(dict(state='stopped'))
- commands = ['management api http-commands', 'shutdown']
- self.start_configured(changed=True, commands=commands)
-
- def test_eos_eapi_state_failed(self):
- self.mock_verify_state.stop()
- set_module_args(dict(state='stopped', timeout=1))
- result = self.start_configured(failed=True)
- 'timeout expired before eapi running state changed' in result['msg']
diff --git a/test/units/modules/network/eos/test_eos_interfaces.py b/test/units/modules/network/eos/test_eos_interfaces.py
deleted file mode 100644
index 41adb74105..0000000000
--- a/test/units/modules/network/eos/test_eos_interfaces.py
+++ /dev/null
@@ -1,181 +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.eos import eos_interfaces
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosInterfacesModule(TestEosModule):
- module = eos_interfaces
-
- def setUp(self):
- super(TestEosInterfacesModule, 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.eos.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.eos.facts.interfaces.interfaces.InterfacesFacts.get_device_data')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosInterfacesModule, 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('eos_interfaces_config.cfg')
- self.execute_show_command.side_effect = load_from_file
-
- def test_eos_interfaces_merged(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet3",
- description="Ethernet_3"
- )], state="merged"
- ))
- commands = ['interface Ethernet3', 'description Ethernet_3']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_interfaces_merged_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- description="Interface 1"
- )], state="merged"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_interfaces_replaced(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet3",
- description="Ethernet_3",
- mtu=1000
- )], state="replaced"
- ))
- commands = ['interface Ethernet3', 'description Ethernet_3', 'mtu 1000']
- self.execute_module(changed=True, commands=commands)
-
- # Bug : 63805
- # def test_eos_interfaces_replaced_idempotent(self):
- # set_module_args(dict(
- # config=[dict(
- # name="Ethernet1",
- # description="Interface 1"
- # )], state="replaced"
- # ))
- # self.execute_module(changed=False, commands=[])
-
- def test_eos_interfaces_delete(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- )], state="deleted"
- ))
- commands = ['interface Ethernet1', 'no description', 'no shutdown']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_interfaces_speed_forced(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- description="Interface_1",
- speed="forced 40g",
- duplex="full"
- )], state="replaced"
- ))
- commands = ['interface Ethernet1', 'description Interface_1', 'speed forced 40gfull', 'no shutdown']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_interfaces_speed_full(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- description="Interface_1",
- speed="1000g",
- duplex="full"
- )], state="replaced"
- ))
- commands = ['interface Ethernet1', 'description Interface_1', 'speed 1000gfull', 'no shutdown']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_interfaces_speed_auto(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- description="Interface_1",
- speed="auto",
- duplex="full"
- )], state="replaced"
- ))
- commands = ['interface Ethernet1', 'description Interface_1', 'speed auto', 'no shutdown']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_interfaces_speed_half(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- description="Interface_1",
- speed="1000g",
- duplex="half"
- )], state="replaced"
- ))
- commands = ['interface Ethernet1', 'description Interface_1', 'speed 1000ghalf', 'no shutdown']
- self.execute_module(changed=True, commands=commands)
-
- # Bug # 63760
- # def test_eos_interfaces_overridden(self):
- # set_module_args(dict(
- # config=[dict(
- # name="Ethernet3",
- # description="Ethernet_3",
- # mtu=1000
- # ),
- # dict(
- # name="Ethernet1",
- # description="Ethernet 1"
- # )], state="overridden"
- # ))
- # commands = ['interface Ethernet3', 'description Ethernet_3', 'mtu 1000', 'interface Ethernet1',
- # 'description Ethernet 1', 'interface Management1', 'no description', 'no ip address']
- # self.execute_module(changed=True, commands=commands)
-
- # def test_eos_interfaces_overridden_idempotent(self):
- # set_module_args(dict(
- # config=[dict(
- # name="Ethernet1",
- # description="Interface 1"
- # ),
- # dict(
- # name="Ethernet2",
- # ),
- # dict(
- # name="Management 1",
- # description="Management interface"
- # )], state="overridden"
- # ))
- # self.execute_module(changed=False, commands=[])
diff --git a/test/units/modules/network/eos/test_eos_l2_interfaces.py b/test/units/modules/network/eos/test_eos_l2_interfaces.py
deleted file mode 100644
index 9c548e9594..0000000000
--- a/test/units/modules/network/eos/test_eos_l2_interfaces.py
+++ /dev/null
@@ -1,150 +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.eos import eos_l2_interfaces
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosL2InterfacesModule(TestEosModule):
- module = eos_l2_interfaces
-
- def setUp(self):
- super(TestEosL2InterfacesModule, 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.eos.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.eos.facts.l2_interfaces.l2_interfaces.L2_interfacesFacts.get_device_data')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosL2InterfacesModule, 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('eos_l2_interfaces_config.cfg')
- self.execute_show_command.side_effect = load_from_file
-
- def test_eos_l2_interfaces_merged(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- trunk=dict(native_vlan=10)
- ), dict(
- name="Ethernet2",
- access=dict(vlan=30),
- )], state="merged"
- ))
- commands = ['interface Ethernet1', 'switchport trunk native vlan 10',
- 'interface Ethernet2', 'switchport access vlan 30']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_l2_interfaces_merged_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- trunk=dict(native_vlan=20)
- ), dict(
- name="Ethernet1",
- access=dict(vlan=20),
- )], state="merged"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_l2_interfaces_replaced(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- mode="trunk",
- trunk=dict(native_vlan=50)
- ), dict(
- name="Ethernet3",
- access=dict(vlan=30),
- )], state="replaced"
- ))
- commands = ['interface Ethernet2',
- 'switchport trunk native vlan 50',
- 'interface Ethernet3',
- 'switchport access vlan 30']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_l2_interfaces_replaced_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- mode="trunk",
- trunk=dict(native_vlan=20),
- ), dict(
- name="Ethernet1",
- access=dict(vlan=20),
- )], state="replaced"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_l2_interfaces_overridden(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- mode="trunk",
- trunk=dict(native_vlan=50)
- )], state="overridden"
- ))
- commands = ['interface Ethernet2',
- 'switchport trunk native vlan 50',
- 'interface Ethernet1',
- 'no switchport access vlan'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_l2_interfaces_overridden_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- mode="trunk",
- trunk=dict(native_vlan=20)
- ), dict(
- name="Ethernet1",
- access=dict(vlan=20),
- )], state="overridden"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_l2_interfaces_deleted(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- mode="trunk",
- trunk=dict(native_vlan=20)
- ), dict(
- name="Ethernet1",
- access=dict(vlan=20),
- )], state="deleted"
- ))
- commands = ['interface Ethernet2', 'no switchport mode', 'no switchport trunk native vlan',
- 'interface Ethernet1', 'no switchport access vlan']
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/eos/test_eos_lacp.py b/test/units/modules/network/eos/test_eos_lacp.py
deleted file mode 100644
index ce19e66ccf..0000000000
--- a/test/units/modules/network/eos/test_eos_lacp.py
+++ /dev/null
@@ -1,106 +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.eos import eos_lacp
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosLacpInterfacesModule(TestEosModule):
- module = eos_lacp
-
- def setUp(self):
- super(TestEosLacpInterfacesModule, 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.eos.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.eos.facts.lacp.lacp.LacpFacts.get_device_data')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosLacpInterfacesModule, 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('eos_lacp_config.cfg')
- self.execute_show_command.side_effect = load_from_file
-
- def test_eos_lacp_default(self):
- set_module_args(dict(
- config=dict(
- system=dict(priority=50)
- )
- ))
- commands = ['lacp system-priority 50']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_lacp_default_idempotent(self):
- set_module_args(dict(
- config=dict(
- system=dict(priority=10)
- )
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_lacp_merged(self):
- set_module_args(dict(
- config=dict(
- system=dict(priority=50)
- ), state="merged"
- ))
- commands = ['lacp system-priority 50']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_lacp_merged_idempotent(self):
- set_module_args(dict(
- config=dict(
- system=dict(priority=10)
- ), state="merged"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_l3_interfaces_replaced(self):
- set_module_args(dict(
- config=dict(
- system=dict(priority=20)
- ), state="replaced"
- ))
- commands = ['lacp system-priority 20']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_l3_interfaces_replaced_idempotent(self):
- set_module_args(dict(
- config=dict(
- system=dict(priority=10)
- ), state="replaced"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_l3_interfaces_deleted(self):
- set_module_args(dict(state="deleted"))
- commands = ['no lacp system-priority']
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/eos/test_eos_lacp_interfaces.py b/test/units/modules/network/eos/test_eos_lacp_interfaces.py
deleted file mode 100644
index 1beeac69a8..0000000000
--- a/test/units/modules/network/eos/test_eos_lacp_interfaces.py
+++ /dev/null
@@ -1,148 +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.eos import eos_lacp_interfaces
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosLacpInterfacesModule(TestEosModule):
- module = eos_lacp_interfaces
-
- def setUp(self):
- super(TestEosLacpInterfacesModule, 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.eos.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.eos.facts.lacp_interfaces.lacp_interfaces.Lacp_interfacesFacts.get_device_data')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosLacpInterfacesModule, 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('eos_lacp_interfaces_config.cfg')
- self.execute_show_command.side_effect = load_from_file
-
- def test_eos_lacp_interfaces_default(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- port_priority=45,
- rate="normal"
- )]
- ))
- commands = ['interface Ethernet1', 'lacp port-priority 45', 'lacp rate normal']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_lacp_interfaces_default_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- rate="fast"
- )]
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_lacp_interfaces_merged(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- port_priority=45,
- rate="normal"
- ), dict(
- name="Ethernet2",
- rate="normal"
- )], state="merged"
- ))
- commands = ['interface Ethernet1', 'lacp port-priority 45', 'lacp rate normal',
- 'interface Ethernet2', 'lacp rate normal']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_lacp_interfaces_merged_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- rate="fast"
- )], state="merged"
- ))
- self.execute_module(changed=False, commands=[])
-
- # Bug #64453
- # def test_eos_lacp_interfaces_replaced(self):
- # set_module_args(dict(
- # config=[dict(
- # name="Ethernet1",
- # port_priority=45,
- # rate="normal"
- # )], state="replaced"
- # ))
- # commands = ['interface Ethernet1', 'lacp port-priority 45', 'lacp rate normal']
- # self.execute_module(changed=True, commands=commands)
-
- def test_eos_lacp_interfaces_replaced_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- rate="fast"
- )], state="replaced"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_lacp_interfaces_overridden(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- port_priority=45,
- rate="normal"
- )], state="overridden"
- ))
- commands = ['interface Ethernet1', 'lacp port-priority 45', 'lacp rate normal',
- 'interface Ethernet2', 'no lacp port-priority', 'no lacp rate']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_lacp_interfaces_overridden_idempotent(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet1",
- port_priority=30
- ), dict(
- name="Ethernet2",
- rate="fast"
- )], state="overridden"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_lacp_interfaces_deleted(self):
- set_module_args(dict(
- config=[dict(
- name="Ethernet2",
- )], state="deleted"
- ))
- commands = ['interface Ethernet2', 'no lacp rate']
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/eos/test_eos_logging.py b/test/units/modules/network/eos/test_eos_logging.py
deleted file mode 100644
index f6be40b4f4..0000000000
--- a/test/units/modules/network/eos/test_eos_logging.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 ansible.modules.network.eos import eos_logging
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosLoggingModule(TestEosModule):
-
- module = eos_logging
-
- def setUp(self):
- super(TestEosLoggingModule, self).setUp()
- self._log_config = load_fixture('eos_logging_config.cfg')
-
- self.mock_get_config = patch('ansible.modules.network.eos.eos_logging.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.eos.eos_logging.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestEosLoggingModule, 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('eos_logging_config.cfg')
- self.load_config.return_value = dict(diff=None, session='session')
-
- def test_eos_setup_host_logging_idempotenet(self):
- set_module_args(dict(dest='host', name='175.16.0.10', state='present'))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_setup_host_logging(self):
- set_module_args(dict(dest='host', name='175.16.0.1', state='present'))
- commands = ['logging host 175.16.0.1']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_buffer_size_outofrange(self):
- set_module_args(dict(dest='buffered', size=5))
- result = self.execute_module(failed=True)
- self.assertEqual(result['msg'], "size must be between 10 and 2147483647")
-
- def test_eos_buffer_size_datatype(self):
- set_module_args(dict(dest='buffered', size='ten'))
- result = self.execute_module(failed=True)
- self.assertIn("we were unable to convert to int", result['msg'])
-
- def test_eos_buffer_size(self):
- set_module_args(dict(dest='buffered', size=5000))
- commands = ['logging buffered 5000']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_buffer_size_idempotent(self):
- set_module_args(dict(dest='buffered', size=50000, level='informational'))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_facilty(self):
- set_module_args(dict(facility='local2'))
- commands = ['logging facility local2']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_facility_idempotent(self):
- set_module_args(dict(facility='local7'))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_level(self):
- set_module_args(dict(dest='console', level='critical'))
- commands = ['logging console critical']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_level_idempotent(self):
- set_module_args(dict(dest='console', level='warnings'))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_logging_state_absent(self):
- set_module_args(dict(dest='host', name='175.16.0.10', state='absent'))
- commands = ['no logging host 175.16.0.10']
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/eos/test_eos_static_routes.py b/test/units/modules/network/eos/test_eos_static_routes.py
deleted file mode 100644
index ce7c0c437b..0000000000
--- a/test/units/modules/network/eos/test_eos_static_routes.py
+++ /dev/null
@@ -1,308 +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.eos import eos_static_routes
-from ansible.module_utils.network.eos.config.static_routes.static_routes import add_commands
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-import itertools
-
-
-class TestEosStaticRoutesModule(TestEosModule):
- module = eos_static_routes
-
- def setUp(self):
- super(TestEosStaticRoutesModule, 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.eos.providers.providers.CliProvider.edit_config'
- )
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch(
- 'ansible.module_utils.network.eos.facts.static_routes.static_routes.Static_routesFacts.get_device_data'
- )
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosStaticRoutesModule, 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', filename=None):
- if filename is None:
- filename = 'eos_static_routes_config.cfg'
-
- def load_from_file(*args, **kwargs):
- output = load_fixture(filename)
- return output
-
- self.execute_show_command.side_effect = load_from_file
-
- def test_eos_static_routes_merged(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv6",
- routes=[
- dict(dest="1200:10::/64",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=55)
- ])
- ])
- ])
- ], state="merged"))
- commands = ['ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_static_routes_merged_idempotent(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv4",
- routes=[
- dict(dest="120.1.1.0/24",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=23)
- ])
- ])
- ])
- ], state="merged"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_static_routes_default(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv6",
- routes=[
- dict(dest="1200:10::/64",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=55)
- ])
- ])
- ])
- ]))
- commands = ['ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_static_routes_default_idempotent(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv4",
- routes=[
- dict(dest="120.1.1.0/24",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=23)
- ])
- ])
- ])
- ]))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_static_routes_replaced(self):
- set_module_args(
- dict(config=[
- dict(address_families=[
- dict(afi="ipv6",
- routes=[
- dict(dest="1000:10::/64",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=55)
- ])
- ])
- ])
- ], state="replaced"))
- commands = [
- 'ipv6 route 1000:10::/64 Ethernet1 55',
- 'no ipv6 route 1000:10::/64 Ethernet1 67 tag 98'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_static_routes_replaced_idempotent(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv4",
- routes=[
- dict(dest="120.1.1.0/24",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=23)
- ])
- ])
- ])
- ], state="replaced"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_static_routes_overridden(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv6",
- routes=[
- dict(dest="1200:10::/64",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=55)
- ])
- ])
- ])
- ], state="overridden"))
- commands = [
- 'ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55',
- 'no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23',
- 'no ip route 10.1.1.0/24 Management1',
- 'no ipv6 route 1000:10::/64 Ethernet1 67 tag 98'
- ]
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_static_routes_overridden_idempotent(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv4",
- routes=[
- dict(dest="120.1.1.0/24",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=23)
- ])
- ])
- ]),
- dict(address_families=[
- dict(afi="ipv4",
- routes=[
- dict(dest="10.1.1.0/24",
- next_hops=[
- dict(interface="Management1")
- ])
- ])
- ]),
- dict(address_families=[
- dict(afi="ipv6",
- routes=[
- dict(dest="1000:10::/64",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=67,
- tag=98)
- ])
- ])
- ])
- ], state="overridden"))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_static_routes_deletedvrf(self):
- set_module_args(dict(config=[dict(vrf="testvrf", )], state="deleted"))
- commands = ['no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_static_routes_deletedroute(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv4", routes=[dict(dest="120.1.1.0/24")])
- ])
- ], state="deleted"))
- commands = ['no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23']
-
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_static_routes_deletedafi(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf", address_families=[dict(afi="ipv4")])
- ], state="deleted"))
- commands = ['no ip route vrf testvrf 120.1.1.0/24 Ethernet1 23']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_static_routes_gathered(self):
- set_module_args(
- dict(config=[],
- state="gathered"))
- result = self.execute_module(changed=False, filename='eos_static_routes_config.cfg')
- commands = []
- for gathered_cmds in result['gathered']:
- cfg = add_commands(gathered_cmds)
- commands.append(cfg)
- commands = list(itertools.chain(*commands))
- config_commands = ['ip route 10.1.1.0/24 Management1', 'ipv6 route 1000:10::/64 Ethernet1 67 tag 98',
- 'ip route vrf testvrf 120.1.1.0/24 Ethernet1 23']
- self.assertEqual(sorted(config_commands), sorted(commands), result['gathered'])
-
- def test_eos_static_routes_rendered(self):
- set_module_args(
- dict(config=[
- dict(vrf="testvrf",
- address_families=[
- dict(afi="ipv6",
- routes=[
- dict(dest="1200:10::/64",
- next_hops=[
- dict(interface="Ethernet1",
- admin_distance=55)
- ])
- ])
- ])
- ], state="rendered"))
- commands = ['ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55']
- result = self.execute_module(changed=False)
- self.assertEqual(sorted(result['rendered']), sorted(commands), result['rendered'])
-
- def test_eos_static_routes_parsed(self):
- set_module_args(
- dict(running_config="ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55",
- state="parsed"))
- commands = ['ipv6 route vrf testvrf 1200:10::/64 Ethernet1 55']
- result = self.execute_module(changed=False)
- parsed_commands = []
- for cmds in result['parsed']:
- cfg = add_commands(cmds)
- parsed_commands.append(cfg)
- parsed_commands = list(itertools.chain(*parsed_commands))
- self.assertEqual(sorted(parsed_commands), sorted(commands), result['parsed'])
diff --git a/test/units/modules/network/eos/test_eos_system.py b/test/units/modules/network/eos/test_eos_system.py
deleted file mode 100644
index 3dfb4ca523..0000000000
--- a/test/units/modules/network/eos/test_eos_system.py
+++ /dev/null
@@ -1,110 +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.eos import eos_system
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosSystemModule(TestEosModule):
-
- module = eos_system
-
- def setUp(self):
- super(TestEosSystemModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.eos.eos_system.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.eos.eos_system.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestEosSystemModule, 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('eos_system_config.cfg')
- self.load_config.return_value = dict(diff=None, session='session')
-
- def test_eos_system_hostname_changed(self):
- set_module_args(dict(hostname='foo'))
- commands = ['hostname foo']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_system_domain_name(self):
- set_module_args(dict(domain_name='test.com'))
- commands = ['ip domain-name test.com']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_system_domain_list(self):
- set_module_args(dict(domain_list=['ansible.com', 'redhat.com']))
- commands = ['no ip domain-list ops.ansible.com',
- 'ip domain-list redhat.com']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_system_lookup_source(self):
- set_module_args(dict(lookup_source=['Ethernet1']))
- commands = ['no ip domain lookup source-interface Management1',
- 'ip domain lookup source-interface Ethernet1']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_system_lookup_source_complex(self):
- lookup_source = [{'interface': 'Management1', 'vrf': 'mgmt'},
- {'interface': 'Ethernet1'}]
- set_module_args(dict(lookup_source=lookup_source))
- commands = ['no ip domain lookup source-interface Management1',
- 'ip domain lookup vrf mgmt source-interface Management1',
- 'ip domain lookup source-interface Ethernet1']
- self.execute_module(changed=True, commands=commands)
-
- # def test_eos_system_name_servers(self):
- # name_servers = ['8.8.8.8', '8.8.4.4']
- # set_module_args(dict(name_servers=name_servers))
- # commands = ['ip name-server 8.8.4.4',
- # 'no ip name-server vrf mgmt 8.8.4.4']
- # self.execute_module(changed=True, commands=commands)
-
- # def rest_eos_system_name_servers_complex(self):
- # name_servers = dict(server='8.8.8.8', vrf='test')
- # set_module_args(dict(name_servers=name_servers))
- # commands = ['ip name-server vrf test 8.8.8.8',
- # 'no ip name-server vrf default 8.8.8.8',
- # 'no ip name-server vrf mgmt 8.8.4.4']
- # self.execute_module(changed=True, commands=commands)
-
- def test_eos_system_state_absent(self):
- set_module_args(dict(state='absent'))
- commands = ['no ip domain-name', 'no hostname']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_system_no_change(self):
- set_module_args(dict(hostname='switch01', domain_name='eng.ansible.com'))
- commands = []
- self.execute_module(commands=commands)
-
- def test_eos_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/eos/test_eos_user.py b/test/units/modules/network/eos/test_eos_user.py
deleted file mode 100644
index cf539c21c1..0000000000
--- a/test/units/modules/network/eos/test_eos_user.py
+++ /dev/null
@@ -1,100 +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.eos import eos_user
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosUserModule(TestEosModule):
-
- module = eos_user
-
- def setUp(self):
- super(TestEosUserModule, self).setUp()
-
- self.mock_get_config = patch('ansible.modules.network.eos.eos_user.get_config')
- self.get_config = self.mock_get_config.start()
-
- self.mock_load_config = patch('ansible.modules.network.eos.eos_user.load_config')
- self.load_config = self.mock_load_config.start()
-
- def tearDown(self):
- super(TestEosUserModule, 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('eos_user_config.cfg')
- self.load_config.return_value = dict(diff=None, session='session')
-
- def test_eos_user_create(self):
- set_module_args(dict(name='test', nopassword=True))
- commands = ['username test nopassword']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_user_delete(self):
- set_module_args(dict(name='ansible', state='absent'))
- commands = ['no username ansible']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_user_password(self):
- set_module_args(dict(name='ansible', configured_password='test'))
- commands = ['username ansible secret test']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_user_privilege(self):
- set_module_args(dict(name='ansible', privilege=15, configured_password='test'))
- result = self.execute_module(changed=True)
- self.assertIn('username ansible privilege 15', result['commands'])
-
- def test_eos_user_privilege_invalid(self):
- set_module_args(dict(name='ansible', privilege=25, configured_password='test'))
- self.execute_module(failed=True)
-
- def test_eos_user_purge(self):
- set_module_args(dict(purge=True))
- commands = ['no username ansible']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_user_role(self):
- set_module_args(dict(name='ansible', role='test', configured_password='test'))
- result = self.execute_module(changed=True)
- self.assertIn('username ansible role test', result['commands'])
-
- def test_eos_user_sshkey(self):
- set_module_args(dict(name='ansible', sshkey='test'))
- commands = ['username ansible sshkey test']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_user_update_password_changed(self):
- set_module_args(dict(name='test', configured_password='test', update_password='on_create'))
- commands = ['username test secret test']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_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_eos_user_update_password_always(self):
- set_module_args(dict(name='ansible', configured_password='test', update_password='always'))
- commands = ['username ansible secret test']
- self.execute_module(changed=True, commands=commands)
diff --git a/test/units/modules/network/eos/test_eos_vlans.py b/test/units/modules/network/eos/test_eos_vlans.py
deleted file mode 100644
index 63f4d38d14..0000000000
--- a/test/units/modules/network/eos/test_eos_vlans.py
+++ /dev/null
@@ -1,172 +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.eos import eos_vlans
-from units.modules.utils import set_module_args
-from .eos_module import TestEosModule, load_fixture
-
-
-class TestEosVlansModule(TestEosModule):
- module = eos_vlans
-
- def setUp(self):
- super(TestEosVlansModule, 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.eos.providers.providers.CliProvider.edit_config')
- self.edit_config = self.mock_edit_config.start()
-
- self.mock_execute_show_command = patch('ansible.module_utils.network.eos.config.vlans.vlans.Vlans.get_vlans_facts')
- self.execute_show_command = self.mock_execute_show_command.start()
-
- def tearDown(self):
- super(TestEosVlansModule, 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'):
- file_cmd = load_fixture('eos_vlan_config.cfg').split()
- file_cmd_dict = {}
- for i in range(0, len(file_cmd), 2):
- if file_cmd[i] == 'vlan_id':
- y = int(file_cmd[i + 1])
- else:
- y = file_cmd[i + 1]
- file_cmd_dict.update({file_cmd[i]: y})
- self.execute_show_command.return_value = [file_cmd_dict]
-
- def test_eos_vlan_default(self):
- self.execute_show_command.return_value = []
- set_module_args(dict(
- config=[dict(
- vlan_id=30,
- name="thirty"
- )]
- ))
- commands = ['vlan 30', 'name thirty']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_vlan_default_idempotent(self):
- self.execute_show_command.return_value = load_fixture('eos_vlan_config.cfg')
- set_module_args(dict(
- config=[dict(
- vlan_id=10,
- name="ten"
- )]
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_vlan_merged(self):
- self.execute_show_command.return_value = []
- set_module_args(dict(
- config=[dict(
- vlan_id=30,
- name="thirty"
- )], state="merged"
- ))
- commands = ['vlan 30', 'name thirty']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_vlan_merged_idempotent(self):
- self.execute_show_command.return_value = load_fixture('eos_vlan_config.cfg')
- set_module_args(dict(
- config=[dict(
- vlan_id=10,
- name="ten"
- )], state="merged"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_vlan_replaced(self):
- self.execute_show_command.return_value = []
- set_module_args(dict(
- config=[dict(
- vlan_id=10,
- name="tenreplaced",
- state="suspend"
- )], state="replaced"
- ))
- commands = ['vlan 10', 'name tenreplaced', 'state suspend']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_vlan_replaced_idempotent(self):
- self.execute_show_command.return_value = load_fixture('eos_vlan_config.cfg')
- set_module_args(dict(
- config=[dict(
- vlan_id=10,
- name="ten"
- )], state="replaced"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_vlan_overridden(self):
- self.execute_show_command.return_value = []
- set_module_args(dict(
- config=[dict(
- vlan_id=30,
- name="thirty",
- state="suspend"
- )], state="overridden"
- ))
- commands = ['no vlan 10', 'vlan 30', 'name thirty', 'state suspend']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_vlan_overridden_idempotent(self):
- self.execute_show_command.return_value = load_fixture('eos_vlan_config.cfg')
- set_module_args(dict(
- config=[dict(
- vlan_id=10,
- name="ten"
- )], state="overridden"
- ))
- self.execute_module(changed=False, commands=[])
-
- def test_eos_vlan_deleted(self):
- set_module_args(dict(
- config=[dict(
- vlan_id=10,
- name="ten",
- )], state="deleted"
- ))
- commands = ['no vlan 10']
- self.execute_module(changed=True, commands=commands)
-
- def test_eos_vlan_id_datatype(self):
- set_module_args(dict(
- config=[dict(
- vlan_id="thirty"
- )]
- ))
- result = self.execute_module(failed=True)
- self.assertIn("we were unable to convert to int", result['msg'])
-
- def test_eos_vlan_state_datatype(self):
- set_module_args(dict(
- config=[dict(
- vlan_id=30,
- state=10
- )]
- ))
- result = self.execute_module(failed=True)
- self.assertIn("value of state must be one of: active, suspend", result['msg'])