Lenovo cnos l3interface (#51322)

* Adding cnos_l3_interface module in alignment with others vendors.
This commit is contained in:
Anil Kumar Muraleedharan
2019-02-01 19:47:52 +05:30
committed by Nathaniel Case
parent f3907c977c
commit 004d8b03d4
12 changed files with 898 additions and 7 deletions

View File

@@ -0,0 +1,27 @@
!
version "10.8.0.42"
!
hostname ip10-241-107-39
!
vlan 13
name dave
!
interface Ethernet1/9
ip address 10.201.107.1 255.255.255.0
ipv6 address dead::beaf/64
description Bleh
!
interface Ethernet1/33
description Hentammoo
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
microburst-detection enable threshold 25
lldp tlv-select max-frame-size
lacp port-priority 33
spanning-tree mst 33-35 cost 33
spanning-tree bpduguard enable
!
!
end

View File

@@ -0,0 +1,77 @@
#
# (c) 2018 Lenovo.
#
# 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/>.
#
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import re
import json
from units.compat.mock import patch
from ansible.modules.network.cnos import cnos_l3_interface
from units.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosL3InterfaceModule(TestCnosModule):
module = cnos_l3_interface
def setUp(self):
super(TestCnosL3InterfaceModule, self).setUp()
self._patch_get_config = patch(
'ansible.modules.network.cnos.cnos_l3_interface.get_config'
)
self._patch_load_config = patch(
'ansible.modules.network.cnos.cnos_l3_interface.load_config'
)
self._get_config = self._patch_get_config.start()
self._load_config = self._patch_load_config.start()
def tearDown(self):
super(TestCnosL3InterfaceModule, self).tearDown()
self._patch_get_config.stop()
self._patch_load_config.stop()
def load_fixtures(self, commands=None):
config_file = 'l3_interface_config.cfg'
self._get_config.return_value = load_fixture(config_file)
self._load_config.return_value = None
def test_cnos_l3_interface_ipv4_address(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet 1/35',
ipv4='192.168.4.1/24'
))
commands = [
'interface Ethernet 1/35',
'ip address 192.168.4.1 255.255.255.0'
]
result = self.execute_module(changed=True, commands=commands)
def test_cnos_l3_interface_absent(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet1/9',
state='absent'
))
commands = [
'interface Ethernet1/9',
'no ip address',
'no ipv6 address'
]
result = self.execute_module(changed=True, commands=commands)