1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-10 22:15:05 +00:00

Move modules and module_utils unit tests to correct place (#81)

* Move modules and module_utils unit tests to correct place.

* Update ignore.txt

* Fix imports.

* Fix typos.

* Fix more typos.
This commit is contained in:
Felix Fontein 2020-03-31 10:42:38 +02:00 committed by GitHub
parent ab3c2120fb
commit be191cce6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1170 changed files with 732 additions and 751 deletions

View file

@ -0,0 +1,126 @@
# Copyright (C) 2017 Lenovo, Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import json
import tempfile
from ansible_collections.community.general.tests.unit.compat import unittest
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible.module_utils import basic
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 AnsibleExitJson(Exception):
pass
class AnsibleFailJson(Exception):
pass
class TestCnosModule(unittest.TestCase):
def setUp(self):
super(TestCnosModule, self).setUp()
self.test_log = tempfile.mkstemp(prefix='ansible-test-cnos-module-', suffix='.log')[1]
self.mock_sleep = patch('time.sleep')
self.mock_sleep.start()
def tearDown(self):
super(TestCnosModule, self).tearDown()
self.mock_sleep.stop()
os.remove(self.test_log)
def execute_module(self, failed=False, changed=False, commands=None,
sort=True, defaults=False):
self.load_fixtures(commands)
if failed:
result = self.failed()
self.assertTrue(result['failed'], result)
else:
result = self.changed(changed)
self.assertEqual(result['changed'], changed, result)
if commands is not None:
if sort:
self.assertEqual(sorted(commands), sorted(result['commands']),
result['commands'])
else:
self.assertEqual(commands, result['commands'],
result['commands'])
return result
def failed(self):
def fail_json(*args, **kwargs):
kwargs['failed'] = True
raise AnsibleFailJson(kwargs)
with patch.object(basic.AnsibleModule, 'fail_json', fail_json):
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):
def exit_json(*args, **kwargs):
if 'changed' not in kwargs:
kwargs['changed'] = False
raise AnsibleExitJson(kwargs)
with patch.object(basic.AnsibleModule, 'exit_json', exit_json):
with self.assertRaises(AnsibleExitJson) as exc:
self.module.main()
result = exc.exception.args[0]
self.assertEqual(result['changed'], changed, result)
return result
def load_fixtures(self, commands=None):
pass

View file

@ -0,0 +1,3 @@
this is a sample
mulitline banner
used for testing

View file

@ -0,0 +1,24 @@
!
router bgp 33
router-id 1.2.3.4
bestpath always-compare-med
cluster-id 1.2.3.4
confederation identifier 333
enforce-first-as
bgp as-local-count 33
bestpath compare-confed-aspath
maxas-limit 333
graceful-restart-helper
graceful-restart stalepath-time 333
timers bgp 333 3333
address-family ipv4 unicast
synchronization
network 0.0.0.0 backdoor
network 0.0.0.0 backdoor
dampening 13 233 333 15 33
neighbor 10.241.107.40 remote-as 13
bfd
address-family ipv4 unicast
next-hop-self
!

View file

@ -0,0 +1,337 @@
!
version "10.8.0.42"
!
hostname ip10-241-107-39
!
banner motd NMS India CNOS
banner motd NMS India CNOS G8272
!
clock timezone EDT 0 0
!
logging console 7
vrf context management
ip route 0.0.0.0/0 10.241.107.1
!
!
port-channel load-balance ethernet destination-mac
port-channel load-balance ethernet source-interface
feature telnet
ip domain-name labs.lenovo.com vrf management
ip domain-list labs.lenovo.com vrf management
ip name-server 10.241.104.120 vrf management
ip name-server 10.240.0.10 vrf management
ip host ip10-241-107-39.labs.lenovo.com 10.241.107.39 vrf management
ip host ip10-241-107-39 10.241.107.39 vrf management
ip domain-name labs.lenovo.com vrf default
ip domain-list labs.lenovo.com vrf default
ip name-server 10.240.0.10 vrf default
ip name-server 10.241.104.120 vrf default
ip host ip10-241-107-39.labs.lenovo.com 10.241.107.39 vrf default
ip host ip10-241-107-39 10.241.107.39 vrf default
ntp server 173.230.154.254 prefer
ntp server 97.127.86.33 prefer
ntp server 129.250.35.250 prefer
ntp server 174.136.103.130 prefer
ntp server 69.10.161.7 prefer
ntp server 96.226.123.196 prefer
ntp server 104.238.179.130 prefer
ntp server 108.61.73.244 prefer
ntp server 208.75.89.4 prefer
snmp-server community public group network-operator
snmp-server community private group network-admin
snmp-server contact Ralph
username admin role network-admin password encrypted $6$bJoWyEu/$9pzSgFPAKGRm1stpTCEl3I39htbjxiFCfhqiHag1NQiKHv/IiLQ2lYW0V3p7p72SgSmVHp38em9P9R/EdePpk/
logging server 10.241.107.231
logging server 10.241.107.222
feature restApi
ovsdb pki ovsdb_mgmt vrf management
ovsdb pki ovsdb_default vrf default
lacp system-priority 32769
vlag tier-id 313
vlag priority 1313
vlag isl port-channel 100
vlag hlthchk keepalive-attempts 5
vlag hlthchk peer-ip 1.2.3.4
vlag auto-recovery 266
vlag startup-delay 323
vlag enable
vlag instance 1 port-channel 1003
vlag instance 1 enable
vlag instance 2 port-channel 20
vlag instance 2 enable
vlag instance 12 port-channel 23
vlag instance 33 port-channel 333
vlag instance 33 enable
spanning-tree mode mst
telemetry heartbeat enabled interval 15
!
policy-map type control-plane copp-system-policy
class type control-plane copp-s-pvst-bpdu
police pps 500
class type control-plane copp-s-ecp
police pps 3000
class type control-plane copp-s-igmp
police pps 3000
!
vlan 1-2
no flood ipv4
!
vlan 3
!
vlan 5
!
vlan 12
!
vlan 13
name dave
!
vlan dot1q tag native egress-only
!
interface Ethernet1/1
description Link 1 to LP21
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
channel-group 33 mode on
!
interface Ethernet1/2
description Link 2 to LP21
channel-group 1001 mode active
!
interface Ethernet1/3
description Link 1 to LP22
switchport mode trunk
channel-group 1003 mode active
!
interface Ethernet1/4
description Link 2 to LP22
switchport mode trunk
channel-group 1004 mode active
!
interface Ethernet1/5
description Link 1 to LP23
no switchport
ip address 20.131.1.1/30
!
interface Ethernet1/6
description Link 2 to LP23
no switchport
ip address 20.131.2.1/30
!
interface Ethernet1/7
description Link 1 to LP24
no switchport
ip address 20.141.1.1/30
!
interface Ethernet1/8
description Link 2 to LP24
no switchport
ip address 20.141.2.1/30
!
interface Ethernet1/9
!
interface Ethernet1/10
!
interface Ethernet1/11
no switchport
mtu 1402
ip address 1.1.1.2/8
!
!
interface Ethernet1/12
ip address 100.10.10.10/24
mtu 1402
no switchport
!
interface Ethernet1/13
description test string
no switchport
ip address 10.241.107.54/24
vrrp 254
address 10.241.107.55
priority 254
no shutdown
ip arp timeout 1500
!
interface Ethernet1/14
!
interface Ethernet1/15
!
interface Ethernet1/16
!
interface Ethernet1/17
!
interface Ethernet1/18
!
interface Ethernet1/19
!
interface Ethernet1/20
!
interface Ethernet1/21
!
interface Ethernet1/22
!
interface Ethernet1/23
channel-group 11 mode active
lacp port-priority 32769
!
interface Ethernet1/24
!
interface Ethernet1/25
!
interface Ethernet1/26
!
interface Ethernet1/27
!
interface Ethernet1/28
!
interface Ethernet1/29
!
interface Ethernet1/30
!
interface Ethernet1/31
!
interface Ethernet1/32
!
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
!
interface Ethernet1/34
!
interface Ethernet1/35
!
interface Ethernet1/36
!
interface Ethernet1/37
!
interface Ethernet1/38
!
interface Ethernet1/39
!
interface Ethernet1/40
!
interface Ethernet1/41
!
interface Ethernet1/42
!
interface Ethernet1/43
!
interface Ethernet1/44
ip address 6.7.8.9 255.255.255.0
description test string
shutdown
!
interface Ethernet1/45
!
interface Ethernet1/46
!
interface Ethernet1/47
!
interface Ethernet1/48
!
interface Ethernet1/49
!
interface Ethernet1/50
!
interface Ethernet1/51
!
interface Ethernet1/52
!
interface Ethernet1/53
!
interface Ethernet1/54
!
interface loopback0
no switchport
!
interface mgmt0
no switchport
vrf member management
no ip address dhcp
ip address 10.241.107.39/24
no ipv6 address dhcp
!
interface Vlan1
no switchport
!
interface port-channel1
!
interface port-channel2
!
interface port-channel11
lacp min-links 2
!
interface port-channel13
switchport mode trunk
!
interface port-channel17
switchport mode trunk
!
interface port-channel20
!
interface port-channel33
description Hentammoo
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
spanning-tree mst 33-35 cost 33
spanning-tree bpduguard enable
!
interface port-channel100
switchport mode trunk
!
interface port-channel1001
!
interface port-channel1002
!
interface port-channel1003
switchport mode trunk
!
interface port-channel1004
switchport mode trunk
!
router bgp 33
router-id 1.2.3.4
bestpath always-compare-med
cluster-id 1.2.3.4
confederation identifier 333
enforce-first-as
bgp as-local-count 33
bestpath compare-confed-aspath
maxas-limit 333
graceful-restart-helper
graceful-restart stalepath-time 333
timers bgp 333 3333
address-family ipv4 unicast
synchronization
network 0.0.0.0 backdoor
dampening 13 233 333 15 33
neighbor 10.241.107.40 remote-as 13
bfd
address-family ipv4 unicast
next-hop-self
!
route-map anil permit 10
!
ip arp timeout 1000
!
line con 0
line vty 0
exec-timeout 90 0
line vty 1 39
!
!
!
end

View file

@ -0,0 +1,6 @@
!
hostname foo
!
interface ethernet 1/13
speed 10000
!

View file

@ -0,0 +1,36 @@
!
hostname ip10-241-107-39
!
interface Ethernet1/33
description anil
microburst-detection enable threshold 25
lldp tlv-select max-frame-size
lacp port-priority 33
!
interface Ethernet1/44
!
interface Ethernet1/10
no switchport
ip address 10.241.108.10/24
vrrp 202
address 10.241.108.20
shutdown
!
interface Ethernet1/11
no switchport
mtu 1402
ip address 1.1.1.2/8
!
interface port-channel20
!
interface port-channel33
description Hentammoo
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
spanning-tree mst 33-35 cost 33
spanning-tree bpduguard enable
!
interface Ethernet1/9
!

View file

@ -0,0 +1,9 @@
!
logging logfile anil 4 size 10485760
logging level vlan 4
logging server 1.2.3.4 facility local0
logging server 1.2.34.5 port 34
logging server 1.2.3.5 4 facility local2 port 23
logging server anil 5
logging server tapas 4 facility local2 port 23
!

View file

@ -0,0 +1,3 @@
ip route 1.2.3.4/32 1.2.34.5
ip route 10.241.106.0/24 Ethernet1/13 10.241.107.1 113 tag 1013 description anil
ip route 10.8.0.0/14 15.16.17.18

View file

@ -0,0 +1,11 @@
hostname lenovo
ip route 1.2.0.0/24 Null0 255
ip route 1.2.3.4/31 Ethernet1/44 1.2.3.1
ip route 1.2.3.4/32 1.2.34.5
ip route 10.241.106.0/24 Ethernet1/13 10.241.107.1 113 tag 1013 description anil
ip route 10.241.106.4/32 1.2.3.5 tag 333 description anillll
ip route 10.241.106.4/32 1.3.56.7
ip route 10.241.107.0/24 10.241.107.1
ip route 10.241.107.1/32 Ethernet1/33 10.241.107.2 100 tag 111 description anil

View file

@ -0,0 +1,8 @@
User:admin
role: network-admin
User:ansible
role: network-operator
no password set. Local login not allowed
this user is created by remote authentication
Remote login through RADIUS/TACACS+ is possible

View file

@ -0,0 +1,63 @@
Global State : enabled
VRRP active/active mode : enabled
vLAG system MAC : 08:17:f4:c3:de:38
ISL Information:
PCH Ifindex State Previous State
-------+-----------+-----------+---------------------------------
33 100033 Down Down
Mis-Match Information:
Local Peer
-------------+---------------------------+-----------------------
Match Result : Mis-match Mis-match
Tier ID : 313 0
System Type : G8272
OS Version : 10.8.x.x 0.0.x.x
Role Information:
Local Peer
-------------+---------------------------+-----------------------
Admin Role : Primary Unselected
Oper Role : Primary Unselected
Priority : 1313 0
System MAC : a4:8c:db:33:bc:01 00:00:00:00:00:00
Consistency Checking Information:
State : enabled
Strict Mode : enabled
Final Result : pass
FDB refresh Information:
FDB is doing refresh with below setting:
FDB refresh is configured
Bridge FDB aging timer is 1800 second(s)
FDB synchronization Information:
FDB is NOT being synchronized.
Auto Recovery Interval 266s (Finished)
Startup Delay Interval 323s (Finished)
Health Check Information:
Health check Peer IP Address: 1.2.3.4
Health check Local IP Address: 0.0.0.0
Health check retry interval: 133 seconds
Health check number of keepalive attempts: 13
Health check keepalive interval: 131 seconds
Health check status: DOWN
Peer Gateway State : enabled
VLAG instance 1 : enabled
Instance Information
PCH ifindex State Previous State Cons Res
----------+-----------+--------------+-----------------+--------
1003 101003 Down Down pass
VLAG instance 33 : enabled
Instance Information
PCH ifindex State Previous State Cons Res
----------+-----------+--------------+-----------------+--------
333 0 Down Down pass

View file

@ -0,0 +1,77 @@
Flags:
u - untagged egress traffic for this VLAN
t - tagged egress traffic for this VLAN
d - auto-provisioned VLAN
h - static and auto-provisioned VLAN
VLAN Name Status IPMC FLOOD Ports
======== ================================ ======= ========== ===================
1 default ACTIVE IPv6
po1(u)
po2(u)
po11(u)
po12(u)
po13(u)
po14(u)
po15(u)
po17(u)
po20(u)
po100(u)
po1001(u)
po1002(u)
po1003(u)
po1004(u)
Ethernet1/2(u)
Ethernet1/3(u)
Ethernet1/4(u)
Ethernet1/9(u)
Ethernet1/10(u)
Ethernet1/11(u)
Ethernet1/14(u)
Ethernet1/15(u)
Ethernet1/16(u)
Ethernet1/17(u)
Ethernet1/18(u)
Ethernet1/19(u)
Ethernet1/20(u)
Ethernet1/21(u)
Ethernet1/22(u)
Ethernet1/23(u)
Ethernet1/24(u)
Ethernet1/25(u)
Ethernet1/26(u)
Ethernet1/27(u)
Ethernet1/28(u)
Ethernet1/29(u)
Ethernet1/30(u)
Ethernet1/31(u)
Ethernet1/32(u)
Ethernet1/33(u)
Ethernet1/34(u)
Ethernet1/35(u)
Ethernet1/36(u)
Ethernet1/37(u)
Ethernet1/38(u)
Ethernet1/39(u)
Ethernet1/40(u)
Ethernet1/41(u)
Ethernet1/42(u)
Ethernet1/43(u)
Ethernet1/44(u)
Ethernet1/45(u)
Ethernet1/46(u)
Ethernet1/47(u)
Ethernet1/48(u)
Ethernet1/49(u)
Ethernet1/50(u)
Ethernet1/51(u)
Ethernet1/52(u)
Ethernet1/53(u)
Ethernet1/54(u)
2 VLAN0002 ACTIVE IPv6
3 VLAN0003 ACTIVE IPv4,IPv6
5 VLAN0005 ACTIVE IPv4,IPv6
12 VLAN0012 ACTIVE IPv4,IPv6
13 anil ACTIVE IPv4,IPv6

View file

@ -0,0 +1,176 @@
Maximum number of vrfs allowed: 65
VRF default, FIB ID 0
Router ID: 20.141.2.1 (automatic)
RD 0:0
Interfaces:
Vlan1
Vlan2
Vlan13
loopback0
Ethernet1/5
Ethernet1/6
Ethernet1/7
Ethernet1/8
Ethernet1/9
Ethernet1/11
Ethernet1/12
Ethernet1/13
Ethernet1/44
po1
po2
po3
po4
po6
po7
po8
po9
po10
po11
po12
po13
po14
po15
po16
po17
po18
po19
po21
po22
po23
po24
po25
po26
po27
po28
po29
po30
po31
po32
po33
po34
po35
po36
po37
po38
po39
po40
po41
po42
po43
po44
po45
po46
po47
po48
po49
po50
po51
po52
po53
po54
po55
po56
po57
po58
po59
po60
po61
po62
po63
po64
po65
po66
po67
po1001
po1002
po1003
po1004
Ethernet1/1
Ethernet1/2
Ethernet1/3
Ethernet1/4
Ethernet1/10
Ethernet1/14
Ethernet1/15
Ethernet1/16
Ethernet1/17
Ethernet1/18
Ethernet1/19
Ethernet1/20
Ethernet1/21
Ethernet1/22
Ethernet1/23
Ethernet1/24
Ethernet1/25
Ethernet1/26
Ethernet1/27
Ethernet1/28
Ethernet1/29
Ethernet1/30
Ethernet1/31
Ethernet1/32
Ethernet1/34
Ethernet1/35
Ethernet1/36
Ethernet1/37
Ethernet1/38
Ethernet1/39
Ethernet1/40
Ethernet1/41
Ethernet1/42
Ethernet1/43
Ethernet1/45
Ethernet1/46
Ethernet1/47
Ethernet1/48
Ethernet1/49
Ethernet1/50
Ethernet1/51
Ethernet1/52
Ethernet1/53
Ethernet1/54
!
VRF management, FIB ID 1
Router ID: 10.241.107.39 (automatic)
RD 0:0
Interfaces:
mgmt0
!
VRF test, FIB ID 2
Router ID is not set
RD 1:201
Interfaces:
Ethernet1/33
!
VRF test1, FIB ID 3
Router ID is not set
RD 1:202
Interfaces:
loopback1
loopback2
loopback3
loopback4
loopback5
loopback6
!
VRF test2, FIB ID 4
Router ID is not set
RD 0:0
Interfaces:
!
VRF test3, FIB ID 5
Router ID is not set
RD 1:203
Interfaces:
!
VRF test4, FIB ID 6
Router ID is not set
RD 1:204
Interfaces:
!
VRF test5, FIB ID 7
Router ID is not set
RD 1:205
Interfaces:
!

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,92 @@
--------------------------------------------------------------------------------
Ethernet PVID Type Mode Status Reason Speed Port
Interface NVLAN Ch#
--------------------------------------------------------------------------------
Ethernet1/1 33 eth access down Link not connected 10000 33
Ethernet1/2 1 eth access down Link not connected 10000 1001
Ethernet1/3 1 eth trunk down Link not connected 10000 1003
Ethernet1/4 1 eth trunk down Link not connected 10000 1004
Ethernet1/5 -- eth routed down Link not connected 10000 --
Ethernet1/6 -- eth routed down Link not connected 10000 --
Ethernet1/7 -- eth routed down Link not connected 10000 --
Ethernet1/8 -- eth routed down Link not connected 10000 --
Ethernet1/9 1 eth access down Link not connected 10000 --
Ethernet1/10 1 eth access down Link not connected 10000 --
Ethernet1/11 -- eth routed down Link not connected 10000 --
Ethernet1/12 -- eth routed down Link not connected 10000 --
Ethernet1/13 -- eth routed down Link not connected 10000 --
Ethernet1/14 1 eth access down Link not connected 10000 --
Ethernet1/15 1 eth access down Link not connected 10000 --
Ethernet1/16 1 eth access down Link not connected 10000 --
Ethernet1/17 1 eth access down Link not connected 10000 --
Ethernet1/18 1 eth access down Link not connected 10000 --
Ethernet1/19 1 eth access down Link not connected 10000 --
Ethernet1/20 1 eth access down Link not connected 10000 --
Ethernet1/21 1 eth access down Link not connected 10000 --
Ethernet1/22 1 eth access down Link not connected 10000 --
Ethernet1/23 1 eth access down Link not connected 10000 11
Ethernet1/24 1 eth access down Link not connected 10000 --
Ethernet1/25 1 eth access down Link not connected 10000 --
Ethernet1/26 1 eth access down Link not connected 10000 --
Ethernet1/27 1 eth access down Link not connected 10000 --
Ethernet1/28 1 eth access down Link not connected 10000 --
Ethernet1/29 1 eth access down Link not connected 10000 --
Ethernet1/30 1 eth access down Link not connected 10000 --
Ethernet1/31 1 eth access down Link not connected 10000 --
Ethernet1/32 1 eth access down Link not connected 10000 --
Ethernet1/33 33 eth access down Link not connected 10000 --
Ethernet1/34 1 eth access down Link not connected 10000 --
Ethernet1/35 1 eth access down Link not connected 10000 --
Ethernet1/36 1 eth access down Link not connected 10000 --
Ethernet1/37 1 eth access down Link not connected 10000 --
Ethernet1/38 1 eth access down Link not connected 10000 --
Ethernet1/39 1 eth access down Link not connected 10000 --
Ethernet1/40 1 eth access down Link not connected 10000 --
Ethernet1/41 1 eth access down Link not connected 10000 --
Ethernet1/42 1 eth access down Link not connected 10000 --
Ethernet1/43 1 eth access down Link not connected 10000 --
Ethernet1/44 1 eth access down Link not connected 10000 --
Ethernet1/45 1 eth access down Link not connected 10000 --
Ethernet1/46 1 eth access down Link not connected 10000 --
Ethernet1/47 1 eth access down Link not connected 10000 --
Ethernet1/48 1 eth access down Link not connected 10000 --
Ethernet1/49 1 eth access down Link not connected 40000 --
Ethernet1/50 1 eth access down Link not connected 40000 --
Ethernet1/51 1 eth access down Link not connected 40000 --
Ethernet1/52 1 eth access down Link not connected 40000 --
Ethernet1/53 1 eth access down Link not connected 40000 --
Ethernet1/54 1 eth access down Link not connected 40000 --
--------------------------------------------------------------------------------
Port-channel PVID Type Mode Status Reason Speed Protocol
Interface NVLAN
--------------------------------------------------------------------------------
po1 1 eth access down No link up members NA none
po2 1 eth access down No link up members NA none
po11 1 eth access down No link up members NA lacp
po13 1 eth trunk down No link up members NA none
po17 1 eth trunk down No link up members NA none
po20 1 eth access down No link up members NA none
po33 33 eth access down No link up members NA none
po100 1 eth trunk down No link up members NA none
po1001 1 eth access down No link up members NA lacp
po1002 1 eth access down No link up members NA none
po1003 1 eth trunk down No link up members NA lacp
po1004 1 eth trunk down No link up members NA lacp
--------------------------------------------------------------------------------
Port VRF Status IP Address Speed MTU
--------------------------------------------------------------------------------
mgmt0 management up 10.241.107.39 1000 1500
-------------------------------------------------------------------------------
Interface Secondary VLAN(Type) Status Reason
-------------------------------------------------------------------------------
Vlan1 -- down VLAN is down
--------------------------------------------------------------------------------
Interface Status Description
--------------------------------------------------------------------------------
loopback0 up --
loopback3 up --

View file

@ -0,0 +1,13 @@
Interface Ethernet1/33
Switchport : enabled
Switchport mode : access
Ingress filter : enable
Tag Ingress PVID : disabled
Acceptable frame types : all
Default/Native Vlan : 1
Configured Vlans : 1
Enabled Vlans : 1
Egress-Tagged Vlans : None
Private-VLAN : Disabled
Private-VLAN Port Type : None
Primary/Secondary VLAN : None/None

View file

@ -0,0 +1,14 @@
Interface Ethernet1/45
Switchport : enabled
Switchport mode : access
Ingress filter : enable
Tag Ingress PVID : disabled
Acceptable frame types : all
Default/Native Vlan : 1
Configured Vlans : 1
Enabled Vlans : 1
Egress-Tagged Vlans : None
Private-VLAN : Disabled
Private-VLAN Port Type : None
Primary/Secondary VLAN : None/None

View file

@ -0,0 +1,72 @@
--------------------------------------------------------------------------------
Interface Mac-Address Burn-in Mac-Address
--------------------------------------------------------------------------------
Ethernet1/1 a48c.db33.bc02 a48c.db33.bc02
Ethernet1/2 a48c.db33.bc03 a48c.db33.bc03
Ethernet1/3 a48c.db33.bc04 a48c.db33.bc04
Ethernet1/4 a48c.db33.bc05 a48c.db33.bc05
Ethernet1/5 a48c.db33.bc01 a48c.db33.bc06
Ethernet1/6 a48c.db33.bc01 a48c.db33.bc07
Ethernet1/7 a48c.db33.bc01 a48c.db33.bc08
Ethernet1/8 a48c.db33.bc01 a48c.db33.bc09
Ethernet1/9 a48c.db33.bc0a a48c.db33.bc0a
Ethernet1/10 a48c.db33.bc0b a48c.db33.bc0b
Ethernet1/11 a48c.db33.bc01 a48c.db33.bc0c
Ethernet1/12 a48c.db33.bc01 a48c.db33.bc0d
Ethernet1/13 a48c.db33.bc01 a48c.db33.bc0e
Ethernet1/14 a48c.db33.bc0f a48c.db33.bc0f
Ethernet1/15 a48c.db33.bc10 a48c.db33.bc10
Ethernet1/16 a48c.db33.bc11 a48c.db33.bc11
Ethernet1/17 a48c.db33.bc12 a48c.db33.bc12
Ethernet1/18 a48c.db33.bc13 a48c.db33.bc13
Ethernet1/19 a48c.db33.bc14 a48c.db33.bc14
Ethernet1/20 a48c.db33.bc15 a48c.db33.bc15
Ethernet1/21 a48c.db33.bc16 a48c.db33.bc16
Ethernet1/22 a48c.db33.bc17 a48c.db33.bc17
Ethernet1/23 a48c.db33.bc18 a48c.db33.bc18
Ethernet1/24 a48c.db33.bc19 a48c.db33.bc19
Ethernet1/25 a48c.db33.bc1a a48c.db33.bc1a
Ethernet1/26 a48c.db33.bc1b a48c.db33.bc1b
Ethernet1/27 a48c.db33.bc1c a48c.db33.bc1c
Ethernet1/28 a48c.db33.bc1d a48c.db33.bc1d
Ethernet1/29 a48c.db33.bc1e a48c.db33.bc1e
Ethernet1/30 a48c.db33.bc1f a48c.db33.bc1f
Ethernet1/31 a48c.db33.bc20 a48c.db33.bc20
Ethernet1/32 a48c.db33.bc21 a48c.db33.bc21
Ethernet1/33 a48c.db33.bc22 a48c.db33.bc22
Ethernet1/34 a48c.db33.bc23 a48c.db33.bc23
Ethernet1/35 a48c.db33.bc24 a48c.db33.bc24
Ethernet1/36 a48c.db33.bc25 a48c.db33.bc25
Ethernet1/37 a48c.db33.bc26 a48c.db33.bc26
Ethernet1/38 a48c.db33.bc27 a48c.db33.bc27
Ethernet1/39 a48c.db33.bc28 a48c.db33.bc28
Ethernet1/40 a48c.db33.bc29 a48c.db33.bc29
Ethernet1/41 a48c.db33.bc2a a48c.db33.bc2a
Ethernet1/42 a48c.db33.bc2b a48c.db33.bc2b
Ethernet1/43 a48c.db33.bc2c a48c.db33.bc2c
Ethernet1/44 a48c.db33.bc2d a48c.db33.bc2d
Ethernet1/45 a48c.db33.bc2e a48c.db33.bc2e
Ethernet1/46 a48c.db33.bc2f a48c.db33.bc2f
Ethernet1/47 a48c.db33.bc30 a48c.db33.bc30
Ethernet1/48 a48c.db33.bc31 a48c.db33.bc31
Ethernet1/49 a48c.db33.bc32 a48c.db33.bc32
Ethernet1/50 a48c.db33.bc33 a48c.db33.bc33
Ethernet1/51 a48c.db33.bc34 a48c.db33.bc34
Ethernet1/52 a48c.db33.bc35 a48c.db33.bc35
Ethernet1/53 a48c.db33.bc36 a48c.db33.bc36
Ethernet1/54 a48c.db33.bc37 a48c.db33.bc37
mgmt0 a48c.db33.bc00 a48c.db33.bc00
po1 0e00.0000.0001 (not set)
po2 0e00.0000.0002 (not set)
po11 a48c.db33.bc18 (not set)
po13 0e00.0000.0003 (not set)
po17 0e00.0000.0004 (not set)
po20 0e00.0000.0005 (not set)
po33 a48c.db33.bc02 (not set)
po100 0e00.0000.0006 (not set)
po1001 a48c.db33.bc03 (not set)
po1002 0e00.0000.0007 (not set)
po1003 a48c.db33.bc04 (not set)
po1004 a48c.db33.bc05 (not set)
Vlan1 a48c.db33.bc01 (not set)

View file

@ -0,0 +1,74 @@
--------------------------------------------------------------------------------
Port Name Status Vlan Duplex Speed Type
--------------------------------------------------------------------------------
Ethernet1/1 Link 1 to LP21 notconnec 33 full 10000 eth
Ethernet1/2 Link 2 to LP21 notconnec 1 full 10000 eth
Ethernet1/3 Link 1 to LP22 notconnec trunk full 10000 eth
Ethernet1/4 Link 2 to LP22 notconnec trunk full 10000 eth
Ethernet1/5 Link 1 to LP23 notconnec routed full 10000 eth
Ethernet1/6 Link 2 to LP23 notconnec routed full 10000 eth
Ethernet1/7 Link 1 to LP24 notconnec routed full 10000 eth
Ethernet1/8 Link 2 to LP24 notconnec routed full 10000 eth
Ethernet1/9 -- notconnec 1 full 10000 eth
Ethernet1/10 -- notconnec 1 full 10000 eth
Ethernet1/11 -- notconnec routed full 10000 eth
Ethernet1/12 -- notconnec routed full 10000 eth
Ethernet1/13 -- notconnec routed full 10000 eth
Ethernet1/14 -- notconnec 1 full 10000 eth
Ethernet1/15 -- notconnec 1 full 10000 eth
Ethernet1/16 -- notconnec 1 full 10000 eth
Ethernet1/17 -- notconnec 1 full 10000 eth
Ethernet1/18 -- notconnec 1 full 10000 eth
Ethernet1/19 -- notconnec 1 full 10000 eth
Ethernet1/20 -- notconnec 1 full 10000 eth
Ethernet1/21 -- notconnec 1 full 10000 eth
Ethernet1/22 -- notconnec 1 full 10000 eth
Ethernet1/23 -- notconnec 1 full 10000 eth
Ethernet1/24 -- notconnec 1 full 10000 eth
Ethernet1/25 -- notconnec 1 full 10000 eth
Ethernet1/26 -- notconnec 1 full 10000 eth
Ethernet1/27 -- notconnec 1 full 10000 eth
Ethernet1/28 -- notconnec 1 full 10000 eth
Ethernet1/29 -- notconnec 1 full 10000 eth
Ethernet1/30 -- notconnec 1 full 10000 eth
Ethernet1/31 -- notconnec 1 full 10000 eth
Ethernet1/32 -- notconnec 1 full 10000 eth
Ethernet1/33 Hentammoo notconnec 33 full 10000 eth
Ethernet1/34 -- notconnec 1 full 10000 eth
Ethernet1/35 -- notconnec 1 full 10000 eth
Ethernet1/36 -- notconnec 1 full 10000 eth
Ethernet1/37 -- notconnec 1 full 10000 eth
Ethernet1/38 -- notconnec 1 full 10000 eth
Ethernet1/39 -- notconnec 1 full 10000 eth
Ethernet1/40 -- notconnec 1 full 10000 eth
Ethernet1/41 -- notconnec 1 full 10000 eth
Ethernet1/42 -- notconnec 1 full 10000 eth
Ethernet1/43 -- notconnec 1 full 10000 eth
Ethernet1/44 -- notconnec 1 full 10000 eth
Ethernet1/45 -- notconnec 1 full 10000 eth
Ethernet1/46 -- notconnec 1 full 10000 eth
Ethernet1/47 -- notconnec 1 full 10000 eth
Ethernet1/48 -- notconnec 1 full 10000 eth
Ethernet1/49 -- notconnec 1 full 40000 eth
Ethernet1/50 -- notconnec 1 full 40000 eth
Ethernet1/51 -- notconnec 1 full 40000 eth
Ethernet1/52 -- notconnec 1 full 40000 eth
Ethernet1/53 -- notconnec 1 full 40000 eth
Ethernet1/54 -- notconnec 1 full 40000 eth
po1 -- notconnec 1 full NA eth
po2 -- notconnec 1 full NA eth
po11 -- notconnec 1 full NA eth
po13 -- notconnec trunk full NA eth
po17 -- notconnec trunk full NA eth
po20 -- notconnec 1 full NA eth
po33 Hentammoo notconnec 33 full NA eth
po100 -- notconnec trunk full NA eth
po1001 -- notconnec 1 full NA eth
po1002 -- notconnec 1 full NA eth
po1003 -- notconnec trunk full NA eth
po1004 -- notconnec trunk full NA eth
mgmt0 -- connected routed full 1000 eth
loopback0 -- connected routed half NA eth
loopback3 -- connected routed half NA eth
Vlan1 -- notconnec routed auto NA --

View file

@ -0,0 +1,10 @@
Interface IP-Address Admin-Status Link-Status VRF
Ethernet1/5 20.131.1.1 up down default
Ethernet1/6 20.131.2.1 up down default
Ethernet1/7 20.141.1.1 up down default
Ethernet1/8 20.141.2.1 up down default
Ethernet1/11 1.1.1.2 up down default
Ethernet1/12 100.10.10.10 up down default
Ethernet1/13 10.241.107.54 up down default
mgmt0 10.241.107.39 up up management

View file

@ -0,0 +1,5 @@
Interface IPv6 Address/Link-local Address Admin-Status Link-Status VRF
loopback0 fe80::200:ff:fe00:0 up up default
loopback3 fe80::200:ff:fe00:0 up up default
mgmt0 fe80::a68c:dbff:fe33:bc00 up up management

View file

@ -0,0 +1,8 @@
Capability codes:
(R) Router, (B) Bridge, (T) Telephone, (C) DOCSIS Cable Device
(W) WLAN Access Point, (P) Repeater, (S) Station, (O) Other
Device ID Local Intf Hold-time Capability Port ID
INDIA-LAB-1-C3750X.l... mgmt0 120 BR Gi1/0/30
Total entries displayed: 1

View file

@ -0,0 +1,38 @@
PID MemAlloc StkSize RSSMem LibMem StackBase/Ptr Process
----- -------- ---------- ------- ------- ------------------ ----------
1 6204 8388608 12312 5380 bff01bc0/bff01590 nsm
4 2608 8388608 5264 5312 bfa92080/bfa91ab0 ospfd
7 14152 8388608 5924 5284 bfaa7250/bfaa6c20 hostpd
10 2092 8388608 4652 5312 bfafcbf0/bfafc620 mribd
11 2024 8388608 3108 5284 bfb7c650/bfb7c080 pimd
14 2016 8388608 4896 5312 bff0ff10/bff0f940 lacpd
17 48608 8388608 36200 5312 bfc10e30/bfc10830 mstpd
24 2520 8388608 5340 5312 bf90ad00/bf90a730 onmd
26 228628 8388608 77312 5376 bfb34e10/bfb34830 hsl
28 2020 8388608 4784 5312 bff3c410/bff3be10 oam
39 21396 8388608 8184 5312 bf9b1a50/bf9b1460 vrrpd
40 2480 8388608 4064 5336 bfe5f020/bfe5ea20 ndd
42 2860 8388608 5672 5364 bfe83aa0/bfe83470 ribd
44 3528 8388608 7140 5328 bf90b720/bf90b110 bgpd
45 1772 8388608 4404 5312 bf9fc250/bf9fbc80 hostmibd
46 39564 8388608 25632 5428 bfe30db0/bfe30780 l2mribd
62 1876 8388608 3920 5312 bf81c210/bf81bc40 sysmgr
63 94380 8388608 13804 5292 bfcb67d0/bfcb61d0 nwvd
64 1920 8388608 5664 5676 bfc28470/bfc27ea0 ovsdbd
65 96548 8388608 55168 5292 bfdbcf80/bfdbc980 vlagd
66 1756 8388608 3808 5284 bfa15ab0/bfa154e0 slpd
71 2116 8388608 5880 10076 bfe8abd0/bfe8a600 npad
72 2220 8388608 5452 7936 bf9e6da0/bf9e67d0 hscd
73 1920 8388608 2760 5284 bfbc6cd0/bfbc6700 dhcpsnpd
74 58620 8388608 16168 9956 bfe1af70/bfe1a970 telemetryd
75 1756 8388608 3456 5284 bfb21da0/bfb217d0 securityd
76 2152 8388608 4216 5284 bfc36900/bfc36330 l2fd
77 1920 8388608 3876 5284 bf91e480/bf91dec0 sflowd
78 1888 8388608 3772 5284 bffd10c0/bffd0af0 qosd
69 70520 8388608 5584 5260 bfca0980/bfca0490 platform_mgr
70 26828 8388608 2116 2040 bfce09c0/bfce0440 service_mgr
total used free shared buff/cache available
Mem: 4081464 442136 3144092 153168 495236 3452732
Swap: 0 0 0

View file

@ -0,0 +1,331 @@
!
version "10.8.0.42"
!
hostname ip10-241-107-39
!
banner motd NMS India CNOS
banner motd NMS India CNOS G8272
!
clock timezone EDT 0 0
!
logging console 7
vrf context management
ip route 0.0.0.0/0 10.241.107.1
!
!
port-channel load-balance ethernet destination-mac
port-channel load-balance ethernet source-interface
feature telnet
ip domain-name labs.lenovo.com vrf management
ip domain-list labs.lenovo.com vrf management
ip name-server 10.241.104.120 vrf management
ip name-server 10.240.0.10 vrf management
ip host ip10-241-107-39.labs.lenovo.com 10.241.107.39 vrf management
ip host ip10-241-107-39 10.241.107.39 vrf management
ip domain-name labs.lenovo.com vrf default
ip domain-list labs.lenovo.com vrf default
ip name-server 10.240.0.10 vrf default
ip name-server 10.241.104.120 vrf default
ip host ip10-241-107-39.labs.lenovo.com 10.241.107.39 vrf default
ip host ip10-241-107-39 10.241.107.39 vrf default
ntp server 173.230.154.254 prefer
ntp server 97.127.86.33 prefer
ntp server 129.250.35.250 prefer
ntp server 174.136.103.130 prefer
ntp server 69.10.161.7 prefer
ntp server 96.226.123.196 prefer
ntp server 104.238.179.130 prefer
ntp server 108.61.73.244 prefer
ntp server 208.75.89.4 prefer
snmp-server community public group network-operator
snmp-server community private group network-admin
snmp-server contact Ralph
username admin role network-admin password encrypted $6$bJoWyEu/$9pzSgFPAKGRm1stpTCEl3I39htbjxiFCfhqiHag1NQiKHv/IiLQ2lYW0V3p7p72SgSmVHp38em9P9R/EdePpk/
logging server 10.241.107.231
logging server 10.241.107.222
feature restApi
ovsdb pki ovsdb_mgmt vrf management
ovsdb pki ovsdb_default vrf default
lacp system-priority 32769
vlag tier-id 313
vlag priority 1313
vlag isl port-channel 100
vlag hlthchk keepalive-attempts 5
vlag hlthchk peer-ip 1.2.3.4
vlag auto-recovery 266
vlag startup-delay 323
vlag enable
vlag instance 1 port-channel 1003
vlag instance 1 enable
vlag instance 2 port-channel 20
vlag instance 2 enable
vlag instance 12 port-channel 23
vlag instance 33 port-channel 333
vlag instance 33 enable
spanning-tree mode mst
telemetry heartbeat enabled interval 15
!
policy-map type control-plane copp-system-policy
class type control-plane copp-s-pvst-bpdu
police pps 500
class type control-plane copp-s-ecp
police pps 3000
class type control-plane copp-s-igmp
police pps 3000
!
vlan 1-2
no flood ipv4
!
vlan 3
!
vlan 5
!
vlan 12
!
vlan 13
name dave
!
vlan dot1q tag native egress-only
!
interface Ethernet1/1
description Link 1 to LP21
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
channel-group 33 mode on
!
interface Ethernet1/2
description Link 2 to LP21
channel-group 1001 mode active
!
interface Ethernet1/3
description Link 1 to LP22
switchport mode trunk
channel-group 1003 mode active
!
interface Ethernet1/4
description Link 2 to LP22
switchport mode trunk
channel-group 1004 mode active
!
interface Ethernet1/5
description Link 1 to LP23
no switchport
ip address 20.131.1.1/30
!
interface Ethernet1/6
description Link 2 to LP23
no switchport
ip address 20.131.2.1/30
!
interface Ethernet1/7
description Link 1 to LP24
no switchport
ip address 20.141.1.1/30
!
interface Ethernet1/8
description Link 2 to LP24
no switchport
ip address 20.141.2.1/30
!
interface Ethernet1/9
!
interface Ethernet1/10
!
interface Ethernet1/11
no switchport
mtu 1402
ip address 1.1.1.2/8
!
interface Ethernet1/12
no switchport
ip address 100.10.10.10/24
!
interface Ethernet1/13
no switchport
ip address 10.241.107.54/24
vrrp 254
address 10.241.107.55
priority 254
no shutdown
ip arp timeout 1500
!
interface Ethernet1/14
!
interface Ethernet1/15
!
interface Ethernet1/16
!
interface Ethernet1/17
!
interface Ethernet1/18
!
interface Ethernet1/19
!
interface Ethernet1/20
!
interface Ethernet1/21
!
interface Ethernet1/22
!
interface Ethernet1/23
channel-group 11 mode active
lacp port-priority 32769
!
interface Ethernet1/24
!
interface Ethernet1/25
!
interface Ethernet1/26
!
interface Ethernet1/27
!
interface Ethernet1/28
!
interface Ethernet1/29
!
interface Ethernet1/30
!
interface Ethernet1/31
!
interface Ethernet1/32
!
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
!
interface Ethernet1/34
!
interface Ethernet1/35
!
interface Ethernet1/36
!
interface Ethernet1/37
!
interface Ethernet1/38
!
interface Ethernet1/39
!
interface Ethernet1/40
!
interface Ethernet1/41
!
interface Ethernet1/42
!
interface Ethernet1/43
!
interface Ethernet1/44
!
interface Ethernet1/45
!
interface Ethernet1/46
!
interface Ethernet1/47
!
interface Ethernet1/48
!
interface Ethernet1/49
!
interface Ethernet1/50
!
interface Ethernet1/51
!
interface Ethernet1/52
!
interface Ethernet1/53
!
interface Ethernet1/54
!
interface loopback0
no switchport
!
interface mgmt0
no switchport
vrf member management
no ip address dhcp
ip address 10.241.107.39/24
no ipv6 address dhcp
!
interface Vlan1
no switchport
!
interface port-channel1
!
interface port-channel2
!
interface port-channel11
lacp min-links 2
!
interface port-channel13
switchport mode trunk
!
interface port-channel17
switchport mode trunk
!
interface port-channel20
!
interface port-channel33
description Hentammoo
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
spanning-tree mst 33-35 cost 33
spanning-tree bpduguard enable
!
interface port-channel100
switchport mode trunk
!
interface port-channel1001
!
interface port-channel1002
!
interface port-channel1003
switchport mode trunk
!
interface port-channel1004
switchport mode trunk
!
router bgp 33
router-id 1.2.3.4
bestpath always-compare-med
cluster-id 1.2.3.4
confederation identifier 333
enforce-first-as
bgp as-local-count 33
bestpath compare-confed-aspath
maxas-limit 333
graceful-restart-helper
graceful-restart stalepath-time 333
timers bgp 333 3333
address-family ipv4 unicast
synchronization
network 0.0.0.0 backdoor
dampening 13 233 333 15 33
neighbor 10.241.107.40 remote-as 13
bfd
address-family ipv4 unicast
next-hop-self
!
route-map anil permit 10
!
ip arp timeout 1000
!
line con 0
line vty 0
exec-timeout 90 0
line vty 1 39
!
!
!
end

View file

@ -0,0 +1,13 @@
Interface Ethernet1/33
Switchport : enabled
Switchport mode : access
Ingress filter : enable
Tag Ingress PVID : disabled
Acceptable frame types : all
Default/Native Vlan : 1
Configured Vlans : 1
Enabled Vlans : 1
Egress-Tagged Vlans : None
Private-VLAN : Disabled
Private-VLAN Port Type : None
Primary/Secondary VLAN : None/None

View file

@ -0,0 +1,14 @@
Interface Ethernet1/45
Switchport : enabled
Switchport mode : access
Ingress filter : enable
Tag Ingress PVID : disabled
Acceptable frame types : all
Default/Native Vlan : 1
Configured Vlans : 1
Enabled Vlans : 1
Egress-Tagged Vlans : None
Private-VLAN : Disabled
Private-VLAN Port Type : None
Primary/Secondary VLAN : None/None

View file

@ -0,0 +1,331 @@
!
version "10.8.0.42"
!
hostname ip10-241-107-39
!
banner motd NMS India CNOS
banner motd NMS India CNOS G8272
!
clock timezone EDT 0 0
!
logging console 7
vrf context management
ip route 0.0.0.0/0 10.241.107.1
!
!
port-channel load-balance ethernet destination-mac
port-channel load-balance ethernet source-interface
feature telnet
ip domain-name labs.lenovo.com vrf management
ip domain-list labs.lenovo.com vrf management
ip name-server 10.241.104.120 vrf management
ip name-server 10.240.0.10 vrf management
ip host ip10-241-107-39.labs.lenovo.com 10.241.107.39 vrf management
ip host ip10-241-107-39 10.241.107.39 vrf management
ip domain-name labs.lenovo.com vrf default
ip domain-list labs.lenovo.com vrf default
ip name-server 10.240.0.10 vrf default
ip name-server 10.241.104.120 vrf default
ip host ip10-241-107-39.labs.lenovo.com 10.241.107.39 vrf default
ip host ip10-241-107-39 10.241.107.39 vrf default
ntp server 173.230.154.254 prefer
ntp server 97.127.86.33 prefer
ntp server 129.250.35.250 prefer
ntp server 174.136.103.130 prefer
ntp server 69.10.161.7 prefer
ntp server 96.226.123.196 prefer
ntp server 104.238.179.130 prefer
ntp server 108.61.73.244 prefer
ntp server 208.75.89.4 prefer
snmp-server community public group network-operator
snmp-server community private group network-admin
snmp-server contact Ralph
username admin role network-admin password encrypted $6$bJoWyEu/$9pzSgFPAKGRm1stpTCEl3I39htbjxiFCfhqiHag1NQiKHv/IiLQ2lYW0V3p7p72SgSmVHp38em9P9R/EdePpk/
logging server 10.241.107.231
logging server 10.241.107.222
feature restApi
ovsdb pki ovsdb_mgmt vrf management
ovsdb pki ovsdb_default vrf default
lacp system-priority 32769
vlag tier-id 313
vlag priority 1313
vlag isl port-channel 100
vlag hlthchk keepalive-attempts 5
vlag hlthchk peer-ip 1.2.3.4
vlag auto-recovery 266
vlag startup-delay 323
vlag enable
vlag instance 1 port-channel 1003
vlag instance 1 enable
vlag instance 2 port-channel 20
vlag instance 2 enable
vlag instance 12 port-channel 23
vlag instance 33 port-channel 333
vlag instance 33 enable
spanning-tree mode mst
telemetry heartbeat enabled interval 15
!
policy-map type control-plane copp-system-policy
class type control-plane copp-s-pvst-bpdu
police pps 500
class type control-plane copp-s-ecp
police pps 3000
class type control-plane copp-s-igmp
police pps 3000
!
vlan 1-2
no flood ipv4
!
vlan 3
!
vlan 5
!
vlan 12
!
vlan 13
name dave
!
vlan dot1q tag native egress-only
!
interface Ethernet1/1
description Link 1 to LP21
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
channel-group 33 mode on
!
interface Ethernet1/2
description Link 2 to LP21
channel-group 1001 mode active
!
interface Ethernet1/3
description Link 1 to LP22
switchport mode trunk
channel-group 1003 mode active
!
interface Ethernet1/4
description Link 2 to LP22
switchport mode trunk
channel-group 1004 mode active
!
interface Ethernet1/5
description Link 1 to LP23
no switchport
ip address 20.131.1.1/30
!
interface Ethernet1/6
description Link 2 to LP23
no switchport
ip address 20.131.2.1/30
!
interface Ethernet1/7
description Link 1 to LP24
no switchport
ip address 20.141.1.1/30
!
interface Ethernet1/8
description Link 2 to LP24
no switchport
ip address 20.141.2.1/30
!
interface Ethernet1/9
!
interface Ethernet1/10
!
interface Ethernet1/11
no switchport
mtu 1402
ip address 1.1.1.2/8
!
interface Ethernet1/12
no switchport
ip address 100.10.10.10/24
!
interface Ethernet1/13
no switchport
ip address 10.241.107.54/24
vrrp 254
address 10.241.107.55
priority 254
no shutdown
ip arp timeout 1500
!
interface Ethernet1/14
!
interface Ethernet1/15
!
interface Ethernet1/16
!
interface Ethernet1/17
!
interface Ethernet1/18
!
interface Ethernet1/19
!
interface Ethernet1/20
!
interface Ethernet1/21
!
interface Ethernet1/22
!
interface Ethernet1/23
channel-group 11 mode active
lacp port-priority 32769
!
interface Ethernet1/24
!
interface Ethernet1/25
!
interface Ethernet1/26
!
interface Ethernet1/27
!
interface Ethernet1/28
!
interface Ethernet1/29
!
interface Ethernet1/30
!
interface Ethernet1/31
!
interface Ethernet1/32
!
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
!
interface Ethernet1/34
!
interface Ethernet1/35
!
interface Ethernet1/36
!
interface Ethernet1/37
!
interface Ethernet1/38
!
interface Ethernet1/39
!
interface Ethernet1/40
!
interface Ethernet1/41
!
interface Ethernet1/42
!
interface Ethernet1/43
!
interface Ethernet1/44
!
interface Ethernet1/45
!
interface Ethernet1/46
!
interface Ethernet1/47
!
interface Ethernet1/48
!
interface Ethernet1/49
!
interface Ethernet1/50
!
interface Ethernet1/51
!
interface Ethernet1/52
!
interface Ethernet1/53
!
interface Ethernet1/54
!
interface loopback0
no switchport
!
interface mgmt0
no switchport
vrf member management
no ip address dhcp
ip address 10.241.107.39/24
no ipv6 address dhcp
!
interface Vlan1
no switchport
!
interface port-channel1
!
interface port-channel2
!
interface port-channel11
lacp min-links 2
!
interface port-channel13
switchport mode trunk
!
interface port-channel17
switchport mode trunk
!
interface port-channel20
!
interface port-channel33
description Hentammoo
load-interval counter 2 33
switchport access vlan 33
storm-control broadcast level 12.50
mtu 66
spanning-tree mst 33-35 cost 33
spanning-tree bpduguard enable
!
interface port-channel100
switchport mode trunk
!
interface port-channel1001
!
interface port-channel1002
!
interface port-channel1003
switchport mode trunk
!
interface port-channel1004
switchport mode trunk
!
router bgp 33
router-id 1.2.3.4
bestpath always-compare-med
cluster-id 1.2.3.4
confederation identifier 333
enforce-first-as
bgp as-local-count 33
bestpath compare-confed-aspath
maxas-limit 333
graceful-restart-helper
graceful-restart stalepath-time 333
timers bgp 333 3333
address-family ipv4 unicast
synchronization
network 0.0.0.0 backdoor
dampening 13 233 333 15 33
neighbor 10.241.107.40 remote-as 13
bfd
address-family ipv4 unicast
next-hop-self
!
route-map anil permit 10
!
ip arp timeout 1000
!
line con 0
line vty 0
exec-timeout 90 0
line vty 1 39
!
!
!
end

View file

@ -0,0 +1,62 @@
*** show boot ***
Current ZTP State: Enable
Current FLASH software:
active image: version 10.8.0.42, downloaded 09:40:15 EDT Mon May 7 2018
standby image: version 10.7.0.6, downloaded 11:02:12 EDT Thu Mar 29 2018
Uboot: version 10.7.0.6, downloaded 11:02:14 EDT Thu Mar 29 2018
ONIE: empty
Currently set to boot software active image
Current port mode: default mode
Next boot port mode: default mode
Currently scheduled reboot time: none
*** show env fan detail ***
Total Fan: 8
+--------+-----+-----------------+---------------+-------+--------+
| Module | Fan | Name | Air-Flow | Speed | Speed |
| Number | ID | | Direction | (%) | (RPM) |
+--------+-----+-----------------+---------------+-------+--------+
01 01 Fan1 Front-to-Back 23 4023
01 02 Fan2 Front-to-Back 23 4285
02 03 Fan3 Front-to-Back 23 4032
02 04 Fan4 Front-to-Back 23 4147
03 05 Fan5 Front-to-Back 23 4192
03 06 Fan6 Front-to-Back 23 4397
04 07 Fan7 Front-to-Back 23 4153
04 08 Fan8 Front-to-Back 23 4451
*** show env power ***
Total Power Supplies: 2
+----+-----------------+----------------+-----------------+------------------+
| ID | Name | Manufacturer | Model | State |
+----+-----------------+----------------+-----------------+------------------+
01 Power Supply 1 DELTA XXXXXXXXXX Normal ON
02 Power Supply 2 DELTA XXXXXXXXXX 12V Output Fault
*** show env temperature ***
+----+------------------+----------+--------+
| ID | Name | Temp | State |
| | | (Celsius)| |
+----+------------------+----------+--------+
01 CPU Local 32 OK
02 Ambient 31 OK
03 Hot Spot 47 OK
System Name : G8272
System Description : G8272 ("48x10GE + 6x40GE")
System Model : Lenovo RackSwitch G8272
System VPD Version : 3
System Manufacture Date : 1542 (YYWW)
System Part Number : 00CJ066
System Serial Number : Y052MV59Y052
System FRU Number : 00FM430
System Machine Type Model : 7159-HCV
System Machine Serial Number : MM11945
System Hardware Revision : 1
System Management MAC : A4:8C:DB:33:BC:00
System Software Revision : 10.8.0.42

View file

@ -0,0 +1,19 @@
Lenovo Networking Operating System (NOS) Software
Technical Assistance Center: http://www.lenovo.com
Copyright (C) Lenovo, 2016. All rights reserved.
Software:
Bootloader version: 10.7.0.6
System version: 10.8.0.42
System compile time: May 03 11:06:25 PDT 2018
Hardware:
G8272 ("48x10GE + 6x40GE")
NXP P2020 CPU with 4096 MB of memory
Device name: ip10-241-107-39
Boot Flash: 16 MB
Kernel uptime is 2 day(s), 21 hour(s), 26 minute(s), 14 second(s)
Last Reset Reason: Reset by CLI reload command

View file

@ -0,0 +1,97 @@
VLAN Name Status IPMC FLOOD Ports
======== ================================ ======= ========== ===================
1 default ACTIVE IPv6
po1(u)
po2(u)
po11(u)
po12(u)
po13(t)
po14(u)
po15(u)
po17(t)
po20(u)
po100(t)
po1001(u)
po1002(u)
po1003(t)
po1004(t)
Ethernet1/2(u)
Ethernet1/3(t)
Ethernet1/4(t)
Ethernet1/9(u)
Ethernet1/10(u)
Ethernet1/14(u)
Ethernet1/15(u)
Ethernet1/16(u)
Ethernet1/17(u)
Ethernet1/18(u)
Ethernet1/19(u)
Ethernet1/20(u)
Ethernet1/21(u)
Ethernet1/22(u)
Ethernet1/23(u)
Ethernet1/24(u)
Ethernet1/25(u)
Ethernet1/26(u)
Ethernet1/27(u)
Ethernet1/28(u)
Ethernet1/29(u)
Ethernet1/30(u)
Ethernet1/31(u)
Ethernet1/32(u)
Ethernet1/33(u)
Ethernet1/34(u)
Ethernet1/35(u)
Ethernet1/36(u)
Ethernet1/37(u)
Ethernet1/38(u)
Ethernet1/39(u)
Ethernet1/40(u)
Ethernet1/41(u)
Ethernet1/42(u)
Ethernet1/43(u)
Ethernet1/44(u)
Ethernet1/45(u)
Ethernet1/46(u)
Ethernet1/47(u)
Ethernet1/48(u)
Ethernet1/49(u)
Ethernet1/50(u)
Ethernet1/51(u)
Ethernet1/52(u)
Ethernet1/53(u)
Ethernet1/54(u)
2 VLAN0002 ACTIVE IPv6
po13(t)
po17(t)
po100(t)
po1003(t)
po1004(t)
Ethernet1/3(t)
Ethernet1/4(t)
3 VLAN0003 ACTIVE IPv4,IPv6
po13(t)
po17(t)
po100(t)
po1003(t)
po1004(t)
Ethernet1/3(t)
Ethernet1/4(t)
12 VLAN0012 ACTIVE IPv4,IPv6
po13(t)
po17(t)
po100(t)
po1003(t)
po1004(t)
Ethernet1/3(t)
Ethernet1/4(t)
13 anil ACTIVE IPv4,IPv6
po13(t)
po17(t)
po100(t)
po1003(t)
po1004(t)
Ethernet1/3(t)
Ethernet1/4(t)

View file

@ -0,0 +1,62 @@
# 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 ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_banner
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosBannerModule(TestCnosModule):
module = cnos_banner
def setUp(self):
super(TestCnosBannerModule, self).setUp()
self.mock_exec_command = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_banner.exec_command')
self.exec_command = self.mock_exec_command.start()
self.mock_load_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_banner.load_config')
self.load_config = self.mock_load_config.start()
def tearDown(self):
super(TestCnosBannerModule, self).tearDown()
self.mock_exec_command.stop()
self.mock_load_config.stop()
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('cnos_banner_show_banner.txt').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_cnos_banner_create(self):
for banner_type in ('login', 'motd'):
set_module_args(dict(banner=banner_type, text='test\nbanner\nstring'))
commands = ['banner {0} test'.format(banner_type), 'banner {0} banner'.format(banner_type), 'banner {0} string'.format(banner_type)]
self.execute_module(changed=True, commands=commands)
def test_cnos_banner_remove(self):
set_module_args(dict(banner='login', state='absent'))
commands = ['no banner login']
self.execute_module(changed=True, commands=commands)
def test_cnos_banner_nochange(self):
banner_text = load_fixture('cnos_banner_show_banner.txt').strip()
set_module_args(dict(banner='login', text=banner_text))
self.execute_module()

View file

@ -0,0 +1,95 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_bgp
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosBgpModule(TestCnosModule):
module = cnos_bgp
def setUp(self):
super(TestCnosBgpModule, self).setUp()
self.mock_run_cnos_commands = patch('ansible_collections.community.general.plugins.module_utils.network.cnos.cnos.run_cnos_commands')
self.run_cnos_commands = self.mock_run_cnos_commands.start()
def tearDown(self):
super(TestCnosBgpModule, self).tearDown()
self.mock_run_cnos_commands.stop()
def load_fixtures(self, commands=None, transport='cli'):
self.run_cnos_commands.return_value = [load_fixture('cnos_bgp_config.cfg')]
def test_bgp_neighbor(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'asNum': '33',
'bgpArg1': 'neighbor', 'bgpArg2': '10.241.107.40',
'bgpArg3': '13', 'bgpArg4': 'address-family',
'bgpArg5': 'ipv4', 'bgpArg6': 'next-hop-self'})
result = self.execute_module(changed=True)
expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_bgp_dampening(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'asNum': '33',
'bgpArg1': 'address-family', 'bgpArg2': 'ipv4',
'bgpArg3': 'dampening', 'bgpArg4': '13',
'bgpArg5': '233', 'bgpArg6': '333',
'bgpArg7': '15', 'bgpArg8': '33'})
result = self.execute_module(changed=True)
expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_bgp_network(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'asNum': '33',
'bgpArg1': 'address-family', 'bgpArg2': 'ipv4',
'bgpArg3': 'network', 'bgpArg4': '1.2.3.4/5',
'bgpArg5': 'backdoor'})
result = self.execute_module(changed=True)
expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_bgp_clusterid(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'asNum': '33',
'bgpArg1': 'cluster-id', 'bgpArg2': '10.241.107.40'})
result = self.execute_module(changed=True)
expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_bgp_graceful_restart(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'asNum': '33',
'bgpArg1': 'graceful-restart', 'bgpArg2': '333'})
result = self.execute_module(changed=True)
expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_bgp_routerid(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'asNum': '33',
'bgpArg1': 'router-id', 'bgpArg2': '1.2.3.4'})
result = self.execute_module(changed=True)
expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_bgp_vrf(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'asNum': '33',
'bgpArg1': 'vrf'})
result = self.execute_module(changed=True)
expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result)

View file

@ -0,0 +1,104 @@
# Copyright (C) 2017 Lenovo, 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 ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_command
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosCommandModule(TestCnosModule):
module = cnos_command
def setUp(self):
super(TestCnosCommandModule, self).setUp()
self.mock_run_commands = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_command.run_commands')
self.run_commands = self.mock_run_commands.start()
def tearDown(self):
super(TestCnosCommandModule, self).tearDown()
self.mock_run_commands.stop()
def load_fixtures(self, commands=None):
def load_from_file(*args, **kwargs):
module, commands = args
output = list()
for item in commands:
try:
command = item
except ValueError:
command = 'show version'
filename = str(command).replace(' ', '_')
output.append(load_fixture(filename))
return output
self.run_commands.side_effect = load_from_file
def test_cnos_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('Lenovo Networking Operating System (NOS) Software'))
def test_cnos_command_multiple(self):
set_module_args(dict(commands=['show version', 'show running-config']))
result = self.execute_module()
self.assertEqual(len(result['stdout']), 2)
self.assertTrue(result['stdout'][0].startswith('Lenovo Networking Operating System (NOS) Software'))
def test_cnos_command_wait_for(self):
wait_for = 'result[0] contains "Lenovo Networking Operating System (NOS) Software"'
set_module_args(dict(commands=['show version'], wait_for=wait_for))
self.execute_module()
def test_cnos_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_cnos_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_cnos_command_match_any(self):
wait_for = ['result[0] contains "Lenovo Networking Operating System (NOS) Software"',
'result[0] contains "test string"']
set_module_args(dict(commands=['show version'], wait_for=wait_for, match='any'))
self.execute_module()
def test_cnos_command_match_all(self):
wait_for = ['result[0] contains "Lenovo Networking Operating System (NOS) Software"',
'result[0] contains "Lenovo"']
set_module_args(dict(commands=['show version'], wait_for=wait_for, match='all'))
self.execute_module()
def test_cnos_command_match_all_failure(self):
wait_for = ['result[0] contains "Lenovo ENOS"',
'result[0] contains "test string"']
commands = ['show version', 'show run']
set_module_args(dict(commands=commands, wait_for=wait_for, match='all'))
self.execute_module(failed=True)

View file

@ -0,0 +1,125 @@
#
# (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 ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_config
from .cnos_module import TestCnosModule, load_fixture
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
class TestCnosConfigModule(TestCnosModule):
module = cnos_config
def setUp(self):
self.patcher_get_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_config.get_config')
self.mock_get_config = self.patcher_get_config.start()
self.patcher_exec_command = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_config.load_config')
self.mock_exec_command = self.patcher_exec_command.start()
def tearDown(self):
self.patcher_get_config.stop()
self.patcher_exec_command.stop()
def load_fixtures(self, commands=None):
config_file = 'cnos_config_config.cfg'
self.mock_get_config.return_value = load_fixture(config_file)
self.mock_exec_command.return_value = 'dummy diff'
def test_cnos_config_unchanged(self):
src = load_fixture('cnos_config_config.cfg')
set_module_args(dict(src=src))
self.execute_module()
def test_cnos_config_src(self):
src = load_fixture('cnos_config_src.cfg')
set_module_args(dict(src=src))
commands = ['hostname foo', 'interface ethernet 1/13',
'speed 10000']
self.execute_module(changed=True, commands=commands)
def test_cnos_config_backup(self):
set_module_args(dict(backup=True))
result = self.execute_module()
self.assertIn('__backup__', result)
def test_cnos_config_lines_wo_parents(self):
set_module_args(dict(lines=['hostname foo']))
commands = ['hostname foo']
self.execute_module(changed=True, commands=commands)
def test_cnos_config_lines_w_parents(self):
set_module_args(dict(lines=['shutdown'], parents=['interface ethernet 1/13']))
commands = ['interface ethernet 1/13', 'shutdown']
self.execute_module(changed=True, commands=commands)
def test_cnos_config_before(self):
set_module_args(dict(lines=['hostname foo'], before=['test1', 'test2']))
commands = ['test1', 'test2', 'hostname foo']
self.execute_module(changed=True, commands=commands, sort=False)
def test_cnos_config_after(self):
set_module_args(dict(lines=['hostname foo'], after=['test1', 'test2']))
commands = ['hostname foo', 'test1', 'test2']
self.execute_module(changed=True, commands=commands, sort=False)
def test_cnos_config_before_after_no_change(self):
set_module_args(dict(lines=['hostname ip10-241-107-39'],
before=['test1', 'test2'],
after=['test2', 'test3']))
self.execute_module()
def test_cnos_config_config(self):
config = 'hostname localhost'
set_module_args(dict(lines=['hostname ip10-241-107-39'], config=config))
commands = ['hostname ip10-241-107-39']
self.execute_module(changed=True, commands=commands)
def test_cnos_config_replace_block(self):
lines = ['description test string', 'test string']
parents = ['interface ethernet 1/13']
set_module_args(dict(lines=lines, replace='block', parents=parents))
commands = parents + lines
self.execute_module(changed=True, commands=commands)
def test_cnos_config_match_none(self):
lines = ['ip address 1.2.3.4 255.255.255.0', 'description test string']
parents = ['interface ethernet 1/13']
set_module_args(dict(lines=lines, parents=parents, match='none'))
commands = parents + lines
self.execute_module(changed=True, commands=commands, sort=False)
def test_cnos_config_match_strict(self):
lines = ['ip address 100.10.10.10/24', 'no switchport']
parents = ['interface Ethernet1/12']
set_module_args(dict(lines=lines, parents=parents, match='strict'))
commands = parents + ['no switchport']
self.execute_module(changed=True, commands=commands, sort=False)
def test_cnos_config_match_exact(self):
lines = ['ip address 1.2.3.4 255.255.255.0', 'description test string',
'no shutdown']
parents = ['interface ethernet 1/13']
set_module_args(dict(lines=lines, parents=parents, match='exact'))
commands = parents + lines
self.execute_module(changed=True, commands=commands, sort=False)

View file

@ -0,0 +1,82 @@
# (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 ansible_collections.community.general.tests.unit.compat.mock import patch
from .cnos_module import TestCnosModule, load_fixture
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_facts
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
class TestCnosFacts(TestCnosModule):
module = cnos_facts
def setUp(self):
super(TestCnosFacts, self).setUp()
self.mock_run_commands = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_facts.run_commands')
self.run_commands = self.mock_run_commands.start()
def tearDown(self):
super(TestCnosFacts, self).tearDown()
self.mock_run_commands.stop()
def load_fixtures(self, commands=None):
def load_from_file(*args, **kwargs):
module, commands = args
output = list()
for item in commands:
try:
obj = json.loads(item)
command = obj['command']
except ValueError:
command = item
filename = str(command).replace(' ', '_')
filename = filename.replace('/', '7')
output.append(load_fixture(filename))
return output
self.run_commands.side_effect = load_from_file
def test_cnos_facts_gather_subset_default(self):
set_module_args(dict())
result = self.execute_module()
ansible_facts = result['ansible_facts']
self.assertIn('hardware', ansible_facts['ansible_net_gather_subset'])
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('interfaces', ansible_facts['ansible_net_gather_subset'])
self.assertEqual('ip10-241-107-39', ansible_facts['ansible_net_hostname'])
self.assertIn('Ethernet1/1', ansible_facts['ansible_net_interfaces'].keys())
self.assertEqual(3985.8046875, ansible_facts['ansible_net_memtotal_mb'])
self.assertEqual(3070.40234375, ansible_facts['ansible_net_memfree_mb'])
def test_cnos_facts_gather_subset_config(self):
set_module_args({'gather_subset': 'config'})
result = self.execute_module()
ansible_facts = result['ansible_facts']
self.assertIn('default', ansible_facts['ansible_net_gather_subset'])
self.assertIn('config', ansible_facts['ansible_net_gather_subset'])
self.assertEqual('ip10-241-107-39', ansible_facts['ansible_net_hostname'])
self.assertIn('ansible_net_config', ansible_facts)

View file

@ -0,0 +1,143 @@
#
# (c) 2018 Red Hat Inc.
# Copyright (C) 2017 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
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_interface
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosInterfaceModule(TestCnosModule):
module = cnos_interface
def setUp(self):
super(TestCnosInterfaceModule, self).setUp()
self._patch_get_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_interface.get_config'
)
self._patch_load_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_interface.load_config'
)
self._patch_exec_command = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_interface.exec_command'
)
self._get_config = self._patch_get_config.start()
self._load_config = self._patch_load_config.start()
self._exec_command = self._patch_exec_command.start()
def tearDown(self):
super(TestCnosInterfaceModule, self).tearDown()
self._patch_get_config.stop()
self._patch_load_config.stop()
self._patch_exec_command.stop()
def load_fixtures(self, commands=None):
config_file = 'cnos_config_config.cfg'
self._get_config.return_value = load_fixture(config_file)
self._load_config.return_value = None
def test_cnos_interface_description(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet1/2',
description='show version'
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface Ethernet1/2',
'description show version',
'duplex auto'
],
'changed': True
}
)
def test_cnos_interface_speed(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet1/2',
speed=1000
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface Ethernet1/2',
'speed 1000',
'duplex auto'
],
'changed': True
}
)
def test_cnos_interface_mtu(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet1/2',
mtu=1548
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface Ethernet1/2',
'duplex auto',
'mtu 1548'
],
'changed': True
}
)
def test_cnos_interface_mtu_out_of_range(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet0/2',
mtu=15000
))
result = self.execute_module(failed=True)
self.assertEqual(
result,
{
'msg': 'mtu must be between 64 and 9216',
'failed': True
}
)
def test_cnos_interface_enabled(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet1/44',
enabled=True
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface Ethernet1/44',
'duplex auto',
'no shutdown'
],
'changed': True
}
)

View file

@ -0,0 +1,155 @@
#
# (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
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_l2_interface
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosL2InterfaceModule(TestCnosModule):
module = cnos_l2_interface
def setUp(self):
super(TestCnosL2InterfaceModule, self).setUp()
self._patch_get_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_l2_interface.get_config'
)
self._patch_load_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_l2_interface.load_config'
)
self._patch_run_commands = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_l2_interface.run_commands'
)
self._get_config = self._patch_get_config.start()
self._load_config = self._patch_load_config.start()
self._run_commands = self._patch_run_commands.start()
self._run_commands.side_effect = self.run_commands_load_fixtures
def run_commands_load_fixtures(self, module, commands, *args, **kwargs):
return self.load_fixtures(
commands,
destination=self._run_commands,
return_values=True
)
def tearDown(self):
super(TestCnosL2InterfaceModule, self).tearDown()
self._patch_get_config.stop()
self._patch_load_config.stop()
self._patch_run_commands.stop()
def load_fixtures(self, commands=None,
destination=None, return_values=False):
side_effects = []
if not destination:
destination = self._get_config
if not commands:
commands = ['cnos_config_config.cfg']
for command in commands:
filename = str(command).replace(' ', '_')
filename = str(filename).replace('/', '_')
side_effects.append(load_fixture(filename))
if return_values is True:
return side_effects
destination.side_effect = side_effects
return None
def test_cnos_l2_interface_access_vlan(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet 1/33',
mode='access',
access_vlan=13,
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface ethernet 1/33',
'switchport access vlan 13'
],
'changed': True,
'warnings': []
}
)
def test_cnos_l2_interface_vlan_does_not_exist(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet 1/33',
mode='access',
access_vlan=10,
))
result = self.execute_module(failed=True)
self.assertEqual(
result,
{
'msg': 'You are trying to configure a VLAN on an interface '
'that\ndoes not exist on the switch yet!',
'failed': True,
'vlan': '10'
}
)
def test_cnos_l2_interface_incorrect_state(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet 1/44',
mode='access',
access_vlan=10,
))
result = self.execute_module(failed=True)
self.assertEqual(
result,
{
'msg': 'Ensure interface is configured to be a L2\nport first '
'before using this module. You can use\nthe cnos_'
'interface module for this.',
'failed': True
}
)
def test_cnos_l2_interface_trunk(self, *args, **kwargs):
set_module_args(dict(
name='Ethernet 1/45',
mode='trunk',
native_vlan='12',
trunk_allowed_vlans='13,12'
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface ethernet 1/45',
'switchport mode trunk',
'switchport trunk allowed vlan 13,12',
'switchport trunk native vlan 12'
],
'changed': True,
'warnings': []
}
)

View file

@ -0,0 +1,79 @@
#
# (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
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_l3_interface
from ansible_collections.community.general.tests.unit.plugins.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_collections.community.general.plugins.modules.network.cnos.cnos_l3_interface.get_config'
)
self._patch_load_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_l3_interface.load_config'
)
self._patch_is_switchport = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_l3_interface.is_switchport'
)
self._get_config = self._patch_get_config.start()
self._load_config = self._patch_load_config.start()
self._is_switchport = self._patch_is_switchport.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
self._is_switchport.return_value = False
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)

View file

@ -0,0 +1,144 @@
#
# (c) 2018 Red Hat Inc.
# Copyright (C) 2017 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
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_linkagg
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosLinkaggModule(TestCnosModule):
module = cnos_linkagg
def setUp(self):
super(TestCnosLinkaggModule, self).setUp()
self._patch_get_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_linkagg.get_config'
)
self._patch_load_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_linkagg.load_config'
)
self._get_config = self._patch_get_config.start()
self._load_config = self._patch_load_config.start()
def tearDown(self):
super(TestCnosLinkaggModule, self).tearDown()
self._patch_get_config.stop()
self._patch_load_config.stop()
def load_fixtures(self, commands=None):
config_file = 'cnos_linkagg_config.cfg'
self._get_config.return_value = load_fixture(config_file)
self._load_config.return_value = None
def test_cnos_linkagg_group_present(self, *args, **kwargs):
set_module_args(dict(
group='10',
state='present'
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface port-channel 10',
'exit'
],
'changed': True
}
)
def test_cnos_linkagg_group_members_active(self, *args, **kwargs):
set_module_args(dict(
group='10',
mode='active',
members=[
'Ethernet 1/33',
'Ethernet 1/44'
]
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface port-channel 10',
'exit',
'interface Ethernet 1/33',
'channel-group 10 mode active',
'interface Ethernet 1/44',
'channel-group 10 mode active'
],
'changed': True
}
)
def test_cnos_linkagg_group_member_removal(self, *args, **kwargs):
set_module_args(dict(
group='20',
mode='active',
members=[
'Ethernet 1/10',
]
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface port-channel 20',
'exit',
'interface Ethernet 1/10',
'channel-group 20 mode active'
],
'changed': True
}
)
def test_cnos_linkagg_group_members_absent(self, *args, **kwargs):
set_module_args(dict(
group='20',
state='absent'
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'no interface port-channel 20'
],
'changed': True
}
)
set_module_args(dict(
group='10',
state='absent'
))
result = self.execute_module(changed=False)
self.assertEqual(
result,
{
'commands': [],
'changed': False
}
)

View file

@ -0,0 +1,101 @@
#
# (c) 2019 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
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_lldp
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosLldpModule(TestCnosModule):
module = cnos_lldp
def setUp(self):
super(TestCnosLldpModule, self).setUp()
self._patch_get_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_lldp.get_config'
)
self._patch_load_config = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_lldp.load_config'
)
self._patch_get_ethernet_range = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_lldp.get_ethernet_range'
)
self._get_config = self._patch_get_config.start()
self._load_config = self._patch_load_config.start()
self._get_ethernet_range = self._patch_get_ethernet_range.start()
def tearDown(self):
super(TestCnosLldpModule, self).tearDown()
self._patch_get_config.stop()
self._patch_load_config.stop()
self._patch_get_ethernet_range.stop()
def load_fixtures(self, commands=None):
config_file = 'cnos_config_config.cfg'
self._get_config.return_value = load_fixture(config_file)
self._load_config.return_value = None
self._get_ethernet_range.return_value = '54'
def test_cnos_lldp_present(self, *args, **kwargs):
set_module_args(dict(
state='present'
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface ethernet 1/1-54',
'lldp receive',
'lldp transmit',
'exit',
'interface mgmt 0',
'lldp receive',
'lldp transmit',
'exit'
],
'changed': True
}
)
def test_cnos_lldp_absent(self, *args, **kwargs):
set_module_args(dict(
state='absent'
))
result = self.execute_module(changed=True)
self.assertEqual(
result,
{
'commands': [
'interface ethernet 1/1-54',
'no lldp receive',
'no lldp transmit',
'exit',
'interface mgmt 0',
'no lldp receive',
'no lldp transmit',
'exit'
],
'changed': True
}
)

View file

@ -0,0 +1,60 @@
#
# (c) 2018 Red Hat Inc.
# Copyright (C) 2017 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
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_logging
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosLoggingModule(TestCnosModule):
module = cnos_logging
def setUp(self):
super(TestCnosLoggingModule, self).setUp()
self.mock_get_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_logging.get_config')
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_logging.load_config')
self.load_config = self.mock_load_config.start()
def tearDown(self):
super(TestCnosLoggingModule, self).tearDown()
self.mock_get_config.stop()
self.mock_load_config.stop()
def load_fixtures(self, commands=None):
self.get_config.return_value = load_fixture('cnos_logging_config.cfg')
self.load_config.return_value = None
def test_cnos_logging_buffer_size_changed_implicit(self):
set_module_args(dict(dest='logfile', name='anil'))
commands = ['logging logfile anil 5 size 10485760']
self.execute_module(changed=True, commands=commands)
def test_cnos_logging_logfile_size_changed_explicit(self):
set_module_args(dict(dest='logfile', name='anil', level='4', size=6000))
commands = ['logging logfile anil 4 size 6000']
self.execute_module(changed=True, commands=commands)

View file

@ -0,0 +1,74 @@
# (c) 2016 Red Hat Inc.
# Copyright (C) 2017 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/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_static_route
from .cnos_module import TestCnosModule, load_fixture
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
class TestCnosStaticRouteModule(TestCnosModule):
module = cnos_static_route
def setUp(self):
super(TestCnosStaticRouteModule, self).setUp()
self.mock_exec_command = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_banner.exec_command')
self.exec_command = self.mock_exec_command.start()
self.mock_load_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_static_route.load_config')
self.load_config = self.mock_load_config.start()
self.mock_get_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_static_route.get_config')
self.get_config = self.mock_get_config.start()
def tearDown(self):
super(TestCnosStaticRouteModule, self).tearDown()
self.mock_exec_command.stop()
self.mock_load_config.stop()
self.mock_get_config.stop()
def load_fixtures(self, commands=None):
self.exec_command.return_value = (0, load_fixture('cnos_static_route.cfg').strip(), None)
self.load_config.return_value = dict(diff=None, session='session')
def test_cnos_static_route_present(self):
set_module_args(dict(prefix='10.241.107.20', mask='255.255.255.0', next_hop='10.241.106.1'))
self.execute_module(changed=True, commands=['ip route 10.241.107.20 255.255.255.0 10.241.106.1 1'])
def test_cnos_static_route_present_no_defaults(self):
set_module_args(dict(prefix='10.241.106.4', mask='255.255.255.0', next_hop='1.2.3.5',
description='testing', admin_distance=100))
self.execute_module(changed=True,
commands=['ip route 10.241.106.4 255.255.255.0 1.2.3.5 100 description testing'])
def test_cnos_static_route_change(self):
set_module_args(dict(prefix='10.10.30.64', mask='255.255.255.0', next_hop='1.2.4.8'))
self.execute_module(changed=True,
commands=['ip route 10.10.30.64 255.255.255.0 1.2.4.8 1'])
def test_cnos_static_route_absent(self):
set_module_args(dict(prefix='10.10.30.12',
mask='255.255.255.0', next_hop='1.2.4.8', state='absent'))
self.execute_module(changed=True,
commands=['no ip route 10.10.30.12 255.255.255.0 1.2.4.8 1'])

View file

@ -0,0 +1,103 @@
#
# (c) 2016 Red Hat Inc.
# Copyright (C) 2017 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/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_system
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosSystemModule(TestCnosModule):
module = cnos_system
def setUp(self):
super(TestCnosSystemModule, self).setUp()
self.mock_get_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_system.get_config')
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_system.load_config')
self.load_config = self.mock_load_config.start()
def tearDown(self):
super(TestCnosSystemModule, self).tearDown()
self.mock_get_config.stop()
self.mock_load_config.stop()
def load_fixtures(self, commands=None, device=''):
self.get_config.return_value = load_fixture('cnos_system_config.cfg')
self.load_config.return_value = None
def test_cnos_system_hostname_changed(self):
set_module_args(dict(hostname='foo'))
commands = ['hostname foo']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_domain_lookup(self):
set_module_args(dict(lookup_enabled=False))
commands = ['no ip domain-lookup']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_missing_vrf(self):
domain_name = dict(name='example.com', vrf='example')
set_module_args(dict(domain_name=domain_name))
self.execute_module(failed=True)
def test_cnos_system_domain_name(self):
set_module_args(dict(domain_name=['example.net']))
commands = ['ip domain-name example.net vrf default']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_domain_name_complex(self):
domain_name = dict(name='example.net', vrf='management')
set_module_args(dict(domain_name=[domain_name]))
commands = ['ip domain-name example.net vrf management']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_domain_search(self):
set_module_args(dict(domain_search=['example.net']))
commands = ['ip domain-list example.net vrf default']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_domain_search_complex(self):
domain_search = dict(name='example.net', vrf='management')
set_module_args(dict(domain_search=[domain_search]))
commands = ['ip domain-list example.net vrf management']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_name_servers(self):
set_module_args(dict(name_servers=['1.2.3.4', '8.8.8.8']))
commands = ['ip name-server 1.2.3.4 vrf default', 'ip name-server 8.8.8.8 vrf default']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_name_servers_complex(self):
name_servers = dict(server='1.2.3.4', vrf='management')
set_module_args(dict(name_servers=[name_servers]))
commands = ['ip name-server 1.2.3.4 vrf management']
self.execute_module(changed=True, commands=commands)
def test_cnos_system_state_absent(self):
set_module_args(dict(state='absent'))
commands = ['no hostname']
self.execute_module(changed=True, commands=commands)

View file

@ -0,0 +1,89 @@
# 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 ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_user
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosUserModule(TestCnosModule):
module = cnos_user
def setUp(self):
super(TestCnosUserModule, self).setUp()
self.mock_get_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_user.get_config')
self.get_config = self.mock_get_config.start()
self.mock_load_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_user.load_config')
self.load_config = self.mock_load_config.start()
self.mock_run_commands = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_user.run_commands')
self.run_commands = self.mock_run_commands.start()
def tearDown(self):
super(TestCnosUserModule, self).tearDown()
self.mock_get_config.stop()
self.mock_load_config.stop()
self.mock_run_commands.stop()
def load_fixtures(self, commands=None, transport='cli'):
self.get_config.return_value = load_fixture('cnos_user_config.cfg')
self.load_config.return_value = dict(diff=None, session='session')
self.run_commands.return_value = [load_fixture('cnos_user_config.cfg')]
def test_cnos_user_create(self):
set_module_args(dict(name='test', configured_password='Anil'))
commands = ['username test', 'username test password Anil']
self.execute_module(changed=True, commands=commands)
def test_cnos_user_delete(self):
set_module_args(dict(name='ansible', state='absent'))
commands = []
self.execute_module(changed=False, commands=commands)
def test_cnos_user_password(self):
set_module_args(dict(name='ansible', configured_password='test'))
commands = ['username ansible', 'username ansible password test']
self.execute_module(changed=True, commands=commands)
def test_cnos_user_purge(self):
set_module_args(dict(purge=True))
commands = ['no username admin\n', 'no username ansible\n']
self.execute_module(changed=True, commands=commands)
def test_cnos_user_role(self):
set_module_args(dict(name='ansible', role='network-admin', configured_password='test'))
result = self.execute_module(changed=True)
self.assertIn('username ansible role network-admin', result['commands'])
def test_cnos_user_sshkey(self):
set_module_args(dict(name='ansible', sshkey='test'))
commands = ['username ansible', 'username ansible sshkey test']
self.execute_module(changed=True, commands=commands)
def test_cnos_user_update_password_changed(self):
set_module_args(dict(name='test', configured_password='test', update_password='on_create'))
commands = ['username test', 'username test password test']
self.execute_module(changed=True, commands=commands)
def test_cnos_user_update_password_always(self):
set_module_args(dict(name='ansible', configured_password='test', update_password='always'))
commands = ['username ansible', 'username ansible password test']
self.execute_module(changed=True, commands=commands)

View file

@ -0,0 +1,51 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_vlag
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosVlagModule(TestCnosModule):
module = cnos_vlag
def setUp(self):
super(TestCnosVlagModule, self).setUp()
self.mock_run_cnos_commands = patch('ansible_collections.community.general.plugins.module_utils.network.cnos.cnos.run_cnos_commands')
self.run_cnos_commands = self.mock_run_cnos_commands.start()
def tearDown(self):
super(TestCnosVlagModule, self).tearDown()
self.mock_run_cnos_commands.stop()
def load_fixtures(self, commands=None, transport='cli'):
self.run_cnos_commands.return_value = [load_fixture('cnos_vlag_config.cfg')]
def test_cnos_vlag_enable(self):
set_module_args({'username': 'admin', 'password': 'admin',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'vlagArg1': 'enable'})
result = self.execute_module(changed=True)
expected_result = 'VLAG configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_vlag_instance(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'vlagArg1': 'instance',
'vlagArg2': '33', 'vlagArg3': '333'})
result = self.execute_module(changed=True)
expected_result = 'VLAG configurations accomplished'
self.assertEqual(result['msg'], expected_result)
def test_cnos_vlag_hlthchk(self):
set_module_args({'username': 'admin', 'password': 'pass',
'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': self.test_log, 'vlagArg1': 'hlthchk',
'vlagArg2': 'keepalive-interval', 'vlagArg3': '131'})
result = self.execute_module(changed=True)
expected_result = 'VLAG configurations accomplished'
self.assertEqual(result['msg'], expected_result)

View file

@ -0,0 +1,206 @@
# (c) 2018 Red Hat Inc.
#
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_vlan
from ansible_collections.community.general.plugins.modules.network.cnos.cnos_vlan import parse_vlan_brief
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosVlanModule(TestCnosModule):
module = cnos_vlan
def setUp(self):
super(TestCnosVlanModule, self).setUp()
self.mock_run_commands = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_vlan.run_commands')
self.run_commands = self.mock_run_commands.start()
self.mock_load_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_vlan.load_config')
self.load_config = self.mock_load_config.start()
def tearDown(self):
super(TestCnosVlanModule, self).tearDown()
self.mock_run_commands.stop()
self.mock_load_config.stop()
def load_fixtures(self, commands=None, transport='cli'):
self.run_commands.return_value = [load_fixture('cnos_vlan_config.cfg')]
self.load_config.return_value = {'diff': None, 'session': 'session'}
def test_cnos_vlan_create(self):
set_module_args({'vlan_id': '3', 'name': 'test', 'state': 'present'})
result = self.execute_module(changed=True)
expected_commands = [
'vlan 3',
'name test',
]
self.assertEqual(result['commands'], expected_commands)
def test_cnos_vlan_id_startwith_9(self):
set_module_args({'vlan_id': '13', 'name': 'anil', 'state': 'present'})
result = self.execute_module(changed=False)
expected_commands = []
self.assertEqual(result['commands'], expected_commands)
def test_cnos_vlan_rename(self):
set_module_args({'vlan_id': '2', 'name': 'test', 'state': 'present'})
result = self.execute_module(changed=True)
expected_commands = [
'vlan 2',
'name test',
]
self.assertEqual(result['commands'], expected_commands)
def test_cnos_vlan_with_interfaces(self):
set_module_args({'vlan_id': '2', 'name': 'vlan2', 'state': 'present',
'interfaces': ['Ethernet1/33', 'Ethernet1/44']})
result = self.execute_module(changed=True)
expected_commands = [
'vlan 2',
'name vlan2',
'vlan 2',
'interface Ethernet1/33',
'switchport mode access',
'switchport access vlan 2',
'vlan 2',
'interface Ethernet1/44',
'switchport mode access',
'switchport access vlan 2',
]
self.assertEqual(result['commands'], expected_commands)
def test_cnos_vlan_with_interfaces_and_newvlan(self):
set_module_args({'vlan_id': '3',
'name': 'vlan3', 'state': 'present',
'interfaces': ['Ethernet1/33', 'Ethernet1/44']})
result = self.execute_module(changed=True)
expected_commands = [
'vlan 3',
'name vlan3',
'vlan 3',
'interface Ethernet1/33',
'switchport mode access',
'switchport access vlan 3',
'vlan 3',
'interface Ethernet1/44',
'switchport mode access',
'switchport access vlan 3',
]
self.assertEqual(result['commands'], expected_commands)
def test_parse_vlan_brief(self):
result = parse_vlan_brief(load_fixture('cnos_vlan_config.cfg'))
obj = [
{
'interfaces': [
'po1',
'po2',
'po11',
'po12',
'po13',
'po14',
'po15',
'po17',
'po20',
'po100',
'po1001',
'po1002',
'po1003',
'po1004',
'Ethernet1/2',
'Ethernet1/3',
'Ethernet1/4',
'Ethernet1/9',
'Ethernet1/10',
'Ethernet1/11',
'Ethernet1/14',
'Ethernet1/15',
'Ethernet1/16',
'Ethernet1/17',
'Ethernet1/18',
'Ethernet1/19',
'Ethernet1/20',
'Ethernet1/21',
'Ethernet1/22',
'Ethernet1/23',
'Ethernet1/24',
'Ethernet1/25',
'Ethernet1/26',
'Ethernet1/27',
'Ethernet1/28',
'Ethernet1/29',
'Ethernet1/30',
'Ethernet1/31',
'Ethernet1/32',
'Ethernet1/33',
'Ethernet1/34',
'Ethernet1/35',
'Ethernet1/36',
'Ethernet1/37',
'Ethernet1/38',
'Ethernet1/39',
'Ethernet1/40',
'Ethernet1/41',
'Ethernet1/42',
'Ethernet1/43',
'Ethernet1/44',
'Ethernet1/45',
'Ethernet1/46',
'Ethernet1/47',
'Ethernet1/48',
'Ethernet1/49',
'Ethernet1/50',
'Ethernet1/51',
'Ethernet1/52',
'Ethernet1/53',
'Ethernet1/54'],
'state': 'ACTIVE',
'name': 'default',
'vlan_id': '1'},
{
'interfaces': [],
'state': 'ACTIVE',
'name': 'VLAN0002',
'vlan_id': '2'},
{
'interfaces': [],
'state': 'ACTIVE',
'name': 'VLAN0003',
'vlan_id': '3'},
{
'interfaces': [],
'state': 'ACTIVE',
'name': 'VLAN0005',
'vlan_id': '5'},
{
'interfaces': [],
'state': 'ACTIVE',
'name': 'VLAN0012',
'vlan_id': '12'},
{
'interfaces': [],
'state': 'ACTIVE',
'name': 'anil',
'vlan_id': '13'}]
self.assertEqual(result, obj)

View file

@ -0,0 +1,78 @@
#
# (c) 2019 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
from ansible_collections.community.general.tests.unit.compat.mock import patch
from ansible_collections.community.general.plugins.modules.network.cnos import cnos_vrf
from ansible_collections.community.general.tests.unit.plugins.modules.utils import set_module_args
from .cnos_module import TestCnosModule, load_fixture
class TestCnosVrfModule(TestCnosModule):
module = cnos_vrf
def setUp(self):
super(TestCnosVrfModule, self).setUp()
self.mock_load_config = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_vrf.load_config')
self.load_config = self.mock_load_config.start()
self.mock_run_commands = patch('ansible_collections.community.general.plugins.modules.network.cnos.cnos_vrf.run_commands')
self.run_commands = self.mock_run_commands.start()
self._patch_is_switchport = patch(
'ansible_collections.community.general.plugins.modules.network.cnos.cnos_vrf.is_switchport'
)
self._is_switchport = self._patch_is_switchport.start()
def tearDown(self):
super(TestCnosVrfModule, self).tearDown()
self.mock_load_config.stop()
self.mock_run_commands.stop()
self._patch_is_switchport.stop()
def load_fixtures(self, commands=None):
config_file = 'cnos_vrf_config.cfg'
self.load_config.return_value = load_fixture(config_file)
self.run_commands.return_value = load_fixture(config_file)
self._is_switchport.return_value = False
def test_cnos_vrf_present(self):
set_module_args(dict(name='test1', state='present'))
self.execute_module(changed=True, commands=['vrf context test1'])
def test_cnos_vrf_present_management(self):
set_module_args(dict(name='management', state='present'))
self.execute_module(changed=True, commands=['vrf context management'])
def test_cnos_vrf_absent_management(self):
set_module_args(dict(name='management', state='absent'))
result = self.execute_module(failed=True)
self.assertEqual(result['msg'], 'Management VRF context cannot be deleted')
def test_cnos_vrf_absent_no_change(self):
set_module_args(dict(name='test1', state='absent'))
self.execute_module(changed=False, commands=[])
def test_cnos_vrf_default(self):
set_module_args(dict(name='default', state='present'))
result = self.execute_module(failed=True)
self.assertEqual(result['msg'], 'VRF context default is reserved')