mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Mellanox OS name change: MLNXOS changed to ONYX (#34753)
* Mellanox OS name change: MLNXOS changed to ONYX Signed-off-by: Samer Deeb <samerd@mellanox.com> * Fix alphabetical order of modules metadata Signed-off-by: Samer Deeb <samerd@mellanox.com>
This commit is contained in:
committed by
John R Barker
parent
57ff84251e
commit
f8884f12bc
0
test/units/modules/network/onyx/__init__.py
Normal file
0
test/units/modules/network/onyx/__init__.py
Normal file
23
test/units/modules/network/onyx/fixtures/onyx_bgp_show.cfg
Normal file
23
test/units/modules/network/onyx/fixtures/onyx_bgp_show.cfg
Normal file
@@ -0,0 +1,23 @@
|
||||
##
|
||||
## Running database "initial"
|
||||
## Generated at 2018/01/10 23:13:17 +0000
|
||||
## Hostname: r-neo-sw12
|
||||
##
|
||||
|
||||
##
|
||||
## Running-config temporary prefix mode setting
|
||||
##
|
||||
no cli default prefix-modes enable
|
||||
|
||||
##
|
||||
## BGP configuration
|
||||
##
|
||||
protocol bgp
|
||||
router bgp 172 vrf default
|
||||
router bgp 172 vrf default router-id 1.2.3.4 force
|
||||
router bgp 172 vrf default neighbor 10.2.3.4 remote-as 173
|
||||
router bgp 172 vrf default network 172.16.1.0 /24
|
||||
##
|
||||
## Persistent prefix mode setting
|
||||
##
|
||||
cli default prefix-modes enable
|
||||
@@ -0,0 +1,19 @@
|
||||
Product name: MLNX-OS
|
||||
Product release: 3.6.5000
|
||||
Build ID: #1-dev
|
||||
Build date: 2017-11-10 18:14:32
|
||||
Target arch: x86_64
|
||||
Target hw: x86_64
|
||||
Built by: jenkins@cc45f26cd083
|
||||
Version summary: X86_64 3.6.5000 2017-11-10 18:14:32 x86_64
|
||||
|
||||
Product model: x86onie
|
||||
Host ID: 248A073D505C
|
||||
System serial num: \"MT1632X00205\"
|
||||
System UUID: 0b19d6d0-5eca-11e6-8000-7cfe90fadc40
|
||||
|
||||
Uptime: 1d 16h 31m 43.856s
|
||||
CPU load averages: 0.06 / 0.12 / 0.13
|
||||
Number of CPUs: 4
|
||||
System memory: 2597 MB used / 5213 MB free / 7810 MB total
|
||||
Swap: 0 MB used / 0 MB free / 0 MB total
|
||||
115
test/units/modules/network/onyx/fixtures/onyx_config_config.cfg
Normal file
115
test/units/modules/network/onyx/fixtures/onyx_config_config.cfg
Normal file
@@ -0,0 +1,115 @@
|
||||
##
|
||||
## Running database "initial"
|
||||
## Generated at 2017/11/28 17:52:08 +0000
|
||||
## Hostname: ufm-switch16
|
||||
##
|
||||
|
||||
##
|
||||
## Running-config temporary prefix mode setting
|
||||
##
|
||||
no cli default prefix-modes enable
|
||||
|
||||
##
|
||||
## License keys
|
||||
##
|
||||
license install 11223344
|
||||
|
||||
##
|
||||
## MLAG protocol
|
||||
##
|
||||
protocol mlag
|
||||
|
||||
##
|
||||
## Interface Ethernet configuration
|
||||
##
|
||||
interface mlag-port-channel 2
|
||||
interface port-channel 1
|
||||
interface ethernet 1/7-1/8 channel-group 1 mode active
|
||||
interface ethernet 1/32 mlag-channel-group 2 mode on
|
||||
interface mlag-port-channel 2 switchport mode hybrid
|
||||
interface mlag-port-channel 2 no shutdown
|
||||
|
||||
##
|
||||
## LAG configuration
|
||||
##
|
||||
lacp
|
||||
|
||||
##
|
||||
## VLAN configuration
|
||||
##
|
||||
vlan 101
|
||||
vlan 4094
|
||||
interface mlag-port-channel 2 switchport access vlan 101
|
||||
|
||||
##
|
||||
## STP configuration
|
||||
##
|
||||
no spanning-tree
|
||||
|
||||
##
|
||||
## L3 configuration
|
||||
##
|
||||
ip routing vrf default
|
||||
interface vlan 101
|
||||
interface vlan 4094
|
||||
interface vlan 101 ip address 10.0.0.254 255.255.255.0
|
||||
interface vlan 4094 ip address 10.10.10.1 255.255.255.0
|
||||
|
||||
##
|
||||
## Other IP configuration
|
||||
##
|
||||
hostname ufm-switch16
|
||||
|
||||
##
|
||||
## DCBX PFC configuration
|
||||
##
|
||||
dcb priority-flow-control enable force
|
||||
interface ethernet 1/7-1/8 dcb priority-flow-control mode on force
|
||||
interface port-channel 1 dcb priority-flow-control mode on force
|
||||
|
||||
##
|
||||
## LLDP configuration
|
||||
##
|
||||
lldp
|
||||
|
||||
##
|
||||
## MAGP configuration
|
||||
##
|
||||
protocol magp
|
||||
interface vlan 101 magp 102
|
||||
interface vlan 101 magp 102 ip virtual-router address 10.0.0.252
|
||||
interface vlan 101 magp 102 ip virtual-router mac-address 00:00:5E:00:01:01
|
||||
|
||||
##
|
||||
## MLAG configurations
|
||||
##
|
||||
mlag-vip neo-mlag-vip-4094 ip 192.168.1.1 /24 force
|
||||
no mlag shutdown
|
||||
mlag system-mac 00:00:5E:00:01:00
|
||||
interface port-channel 1 ipl 1
|
||||
interface vlan 4094 ipl 1 peer-address 10.10.10.2
|
||||
|
||||
##
|
||||
## AAA remote server configuration
|
||||
##
|
||||
# ldap bind-password ********
|
||||
# radius-server key ********
|
||||
# tacacs-server key ********
|
||||
|
||||
##
|
||||
## Network management configuration
|
||||
##
|
||||
# web proxy auth basic password ********
|
||||
telnet-server enable
|
||||
|
||||
##
|
||||
## X.509 certificates configuration
|
||||
##
|
||||
#
|
||||
# Certificate name system-self-signed, ID 51f545df9722387056f674401f510ff56077800b
|
||||
# (public-cert config omitted since private-key config is hidden)
|
||||
|
||||
##
|
||||
## Persistent prefix mode setting
|
||||
##
|
||||
cli default prefix-modes enable
|
||||
@@ -0,0 +1,3 @@
|
||||
no cli default prefix-modes enable
|
||||
interface mlag-port-channel 2
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"Fec": "auto",
|
||||
"Mac address": "7c:fe:90:e5:ca:3c",
|
||||
"Actual speed": "100 Gbps",
|
||||
"MTU": "1500 bytes(Maximum packet size 1522 bytes)",
|
||||
"header": "Eth1/1",
|
||||
"Admin state": "Enabled",
|
||||
"Operational state": "Down"
|
||||
},
|
||||
{
|
||||
"Fec": "auto",
|
||||
"Mac address": "7c:fe:90:e5:ca:3e",
|
||||
"Actual speed": "100 Gbps",
|
||||
"MTU": "1500 bytes(Maximum packet size 1522 bytes)",
|
||||
"header": "Eth1/2",
|
||||
"Admin state": "Enabled",
|
||||
"Operational state": "Down"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"MGMT": [
|
||||
{
|
||||
"Status": "ready"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"Uptime": "2d 13h 40m 34.992s",
|
||||
"Product model": "x86onie",
|
||||
"Build date": "2017-11-10 18:14:32",
|
||||
"Target arch": "x86_64",
|
||||
"Target hw": "x86_64",
|
||||
"Number of CPUs": "4",
|
||||
"Build ID": "#1-dev",
|
||||
"CPU load averages": "0.21 / 0.07 / 0.06",
|
||||
"Host ID": "248A07B0141C",
|
||||
"System serial num": "MT1708X07233",
|
||||
"System UUID": "03d242b6-1a24-11e7-8000-248a07f55400",
|
||||
"Swap": "0 MB used / 0 MB free / 0 MB total",
|
||||
"Product name": "MLNX-OS",
|
||||
"Built by": "jenkins@cc45f26cd083",
|
||||
"System memory": "2597 MB used / 5213 MB free / 7810 MB total",
|
||||
"Version summary": "X86_64 3.6.5000 2017-11-10 18:14:32 x86_64",
|
||||
"Product release": "3.6.5000"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"Eth1/1": [
|
||||
{
|
||||
"ingress rate": "9000 b/s",
|
||||
"egress pkts/sec": "10",
|
||||
"egress rate": "10000 b/s",
|
||||
"ingress pkts/sec": "10"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
[
|
||||
{
|
||||
"Fec": "auto",
|
||||
"Mac address": "7c:fe:90:f0:54:fc",
|
||||
"60 seconds ingress rate": "0 bits/sec, 0 bytes/sec, 0 packets/sec",
|
||||
"Last clearing of \"show interface\" counters": "Never",
|
||||
"Actual speed": "40 Gbps",
|
||||
"MTU": "1500 bytes(Maximum packet size 1522 bytes)",
|
||||
"header": "Eth1/1",
|
||||
"Telemetry threshold": "Disabled\t TCs: N\\A",
|
||||
"Telemetry threshold level": "N\\A",
|
||||
"Flow-control": "receive off send off",
|
||||
"Forwarding mode": "inherited cut-through",
|
||||
"60 seconds egress rate": "0 bits/sec, 0 bytes/sec, 0 packets/sec",
|
||||
"Last change in operational status": "Never",
|
||||
"Boot delay time": "0 sec",
|
||||
"Description": "N\\A",
|
||||
"Admin state": "Enabled",
|
||||
"Telemetry sampling": "Disabled\t TCs: N\\A",
|
||||
"Operational state": "Down",
|
||||
"Width reduction mode": "Not supported",
|
||||
"Tx": {
|
||||
"error packets": "0",
|
||||
"packets": "0",
|
||||
"bytes": "0",
|
||||
"multicast packets": "0",
|
||||
"unicast packets": "0",
|
||||
"discard packets": "0",
|
||||
"hoq discard packets": "0",
|
||||
"broadcast packets": "0"
|
||||
},
|
||||
"MAC learning mode": "Enabled",
|
||||
"Switchport mode": "access",
|
||||
"Rx": {
|
||||
"error packets": "0",
|
||||
"packets": "0",
|
||||
"bytes": "0",
|
||||
"multicast packets": "0",
|
||||
"unicast packets": "0",
|
||||
"discard packets": "0",
|
||||
"broadcast packets": "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Icmp redirect": "Enabled",
|
||||
"Description": "N/A",
|
||||
"Mac Address": "7C:FE:90:F0:54:C1",
|
||||
"Autostate": "Enabled",
|
||||
"Admin state": "Enabled",
|
||||
"header": "Vlan 10",
|
||||
"MTU": "1500 bytes",
|
||||
"DHCP client": "Disabled",
|
||||
"Operational state": "Up",
|
||||
"VRF": "default",
|
||||
"Arp timeout": "1500 seconds",
|
||||
"Counters": "Disabled"
|
||||
},
|
||||
{
|
||||
"Autostate": "Enabled",
|
||||
"Icmp redirect": "Enabled",
|
||||
"Broadcast address": "10.2.2.255",
|
||||
"Description": "N/A",
|
||||
"Mac Address": "7C:FE:90:F0:54:C1",
|
||||
"Internet Address": "10.2.2.3/24",
|
||||
"Admin state": "Enabled",
|
||||
"header": "Vlan 1002",
|
||||
"MTU": "1500 bytes",
|
||||
"DHCP client": "Disabled",
|
||||
"Operational state": "Down",
|
||||
"VRF": "default",
|
||||
"Arp timeout": "1500 seconds",
|
||||
"Counters": "Disabled"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"Eth1/1": [
|
||||
{
|
||||
"Negotiation": "No-Negotiation",
|
||||
"Operational state": "Down",
|
||||
"Speed": "100 Gbps"
|
||||
}
|
||||
],
|
||||
"Vlan 1002": [
|
||||
{
|
||||
"State": "Down",
|
||||
"Description": "N/A"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"Eth1/11": {
|
||||
"Access vlan": "1",
|
||||
"Allowed vlans": "",
|
||||
"Mode": "access"
|
||||
},
|
||||
"Eth1/10": {
|
||||
"Access vlan": "1",
|
||||
"Allowed vlans": "10",
|
||||
"Mode": "hybrid"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
[
|
||||
{
|
||||
"Broadcast address": "172.3.1.255",
|
||||
"Fec": "auto",
|
||||
"Tx": {
|
||||
"error packets": "0",
|
||||
"packets": "0",
|
||||
"bytes": "0",
|
||||
"multicast packets": "0",
|
||||
"unicast packets": "0",
|
||||
"discard packets": "0",
|
||||
"hoq discard packets": "0",
|
||||
"broadcast packets": "0"
|
||||
},
|
||||
"Rx": {
|
||||
"error packets": "0",
|
||||
"packets": "0",
|
||||
"bytes": "0",
|
||||
"multicast packets": "0",
|
||||
"unicast packets": "0",
|
||||
"discard packets": "0",
|
||||
"broadcast packets": "0"
|
||||
},
|
||||
"header": "Eth1/5",
|
||||
"Arp timeout": "1500 seconds",
|
||||
"Actual speed": "40 Gbps",
|
||||
"60 seconds egress rate": "0 bits/sec, 0 bytes/sec, 0 packets/sec",
|
||||
"Last change in operational status": "Never",
|
||||
"Boot delay time": "0 sec",
|
||||
"Description": "N\\A",
|
||||
"DHCP client": "Disabled",
|
||||
"VRF": "default",
|
||||
"Mac address": "24:8A:07:F5:54:01",
|
||||
"60 seconds ingress rate": "0 bits/sec, 0 bytes/sec, 0 packets/sec",
|
||||
"Last clearing of \"show interface\" counters": "Never",
|
||||
"MTU": "1500 bytes(Maximum packet size 1522 bytes)",
|
||||
"Telemetry threshold": "Disabled\t TCs: N\\A",
|
||||
"Telemetry threshold level": "N\\A",
|
||||
"Flow-control": "receive off send off",
|
||||
"Forwarding mode": "inherited cut-through",
|
||||
"Admin state": "Enabled",
|
||||
"Telemetry sampling": "Disabled\t TCs: N\\A",
|
||||
"IP Address": "172.3.12.4 /24",
|
||||
"Operational state": "Down",
|
||||
"Width reduction mode": "Not supported"
|
||||
},
|
||||
{
|
||||
"Fec": "auto",
|
||||
"Mac address": "24:8a:07:f5:54:0c",
|
||||
"60 seconds ingress rate": "0 bits/sec, 0 bytes/sec, 0 packets/sec",
|
||||
"Last clearing of \"show interface\" counters": "Never",
|
||||
"Actual speed": "40 Gbps",
|
||||
"MTU": "1500 bytes(Maximum packet size 1522 bytes)",
|
||||
"header": "Eth1/6",
|
||||
"Telemetry threshold": "Disabled\t TCs: N\\A",
|
||||
"Telemetry threshold level": "N\\A",
|
||||
"Flow-control": "receive off send off",
|
||||
"Forwarding mode": "inherited cut-through",
|
||||
"60 seconds egress rate": "0 bits/sec, 0 bytes/sec, 0 packets/sec",
|
||||
"Last change in operational status": "Never",
|
||||
"Boot delay time": "0 sec",
|
||||
"Description": "N\\A",
|
||||
"Admin state": "Enabled",
|
||||
"Telemetry sampling": "Disabled\t TCs: N\\A",
|
||||
"Operational state": "Down",
|
||||
"Width reduction mode": "Not supported",
|
||||
"Tx": {
|
||||
"error packets": "0",
|
||||
"packets": "0",
|
||||
"bytes": "0",
|
||||
"multicast packets": "0",
|
||||
"unicast packets": "0",
|
||||
"discard packets": "0",
|
||||
"hoq discard packets": "0",
|
||||
"broadcast packets": "0"
|
||||
},
|
||||
"MAC learning mode": "Enabled",
|
||||
"Switchport mode": "access",
|
||||
"Rx": {
|
||||
"error packets": "0",
|
||||
"packets": "0",
|
||||
"bytes": "0",
|
||||
"multicast packets": "0",
|
||||
"unicast packets": "0",
|
||||
"discard packets": "0",
|
||||
"broadcast packets": "0"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"Autostate": "Enabled",
|
||||
"Icmp redirect": "Enabled",
|
||||
"Broadcast address": "172.3.12.255",
|
||||
"Description": "N/A",
|
||||
"Mac Address": "7C:FE:90:E5:CA:01",
|
||||
"Internet Address": "172.3.12.4/24",
|
||||
"Admin state": "Enabled",
|
||||
"header": "Vlan 1002",
|
||||
"MTU": "1500 bytes",
|
||||
"DHCP client": "Disabled",
|
||||
"Operational state": "Down",
|
||||
"VRF": "default",
|
||||
"Arp timeout": "1500 seconds",
|
||||
"Counters": "Disabled"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"Eth1/1": [
|
||||
{
|
||||
"Receive": "Enabled",
|
||||
"Transmit": "Enabled",
|
||||
"TLVs": "PD, SN, SD, SC, MA, PFC, AP, ETS-C, ETS-R"
|
||||
}
|
||||
],
|
||||
"Eth1/2": [
|
||||
{
|
||||
"Receive": "Disabled",
|
||||
"Transmit": "Disabled",
|
||||
"TLVs": "PD, SN, SD, SC, MA, PFC, AP, ETS-C, ETS-R"
|
||||
}
|
||||
]
|
||||
}
|
||||
14
test/units/modules/network/onyx/fixtures/onyx_lldp_show.cfg
Normal file
14
test/units/modules/network/onyx/fixtures/onyx_lldp_show.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
[
|
||||
{
|
||||
"LLDP": "enabled"
|
||||
},
|
||||
{
|
||||
"Supported capabilities": "B,R",
|
||||
"Chassis sub type": "Mac Address",
|
||||
"header": "Local global configuration",
|
||||
"System Name": "ufm-switch16",
|
||||
"Supported capabilities enabled": "B",
|
||||
"Chassis id": "7c:fe:90:e5:ca:00",
|
||||
"System Description": "Mellanox MSN2700,MLNX-OS,SWv3.6.5000-04"
|
||||
}
|
||||
]
|
||||
18
test/units/modules/network/onyx/fixtures/onyx_magp_show.cfg
Normal file
18
test/units/modules/network/onyx/fixtures/onyx_magp_show.cfg
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"Interface vlan": "1243",
|
||||
"Admin state": "Enabled",
|
||||
"Virtual IP": "10.0.0.43",
|
||||
"header": "MAGP 102",
|
||||
"State": "Init",
|
||||
"Virtual MAC": "01:02:03:04:05:06"
|
||||
},
|
||||
{
|
||||
"Interface vlan": "1200",
|
||||
"Admin state": "Disabled",
|
||||
"Virtual IP": "0.0.0.0",
|
||||
"header": "MAGP 103",
|
||||
"State": "Init",
|
||||
"Virtual MAC": "00:00:00:00:00:00"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"Reload-delay": "30 sec",
|
||||
"Upgrade-timeout": "60 min",
|
||||
"System-mac": "00:00:5E:00:01:4E [Mismatched]",
|
||||
"Admin status": "Disabled",
|
||||
"MLAG Ports Status Summary": {
|
||||
"Active-partial": "0",
|
||||
"Inactive": "0",
|
||||
"Active-full": "0"
|
||||
},
|
||||
"MLAG IPLs Summary": {
|
||||
"1": [
|
||||
{
|
||||
"Local IP address": "10.2.2.3",
|
||||
"Peer IP address": "10.2.2.2",
|
||||
"Operational State": "Down",
|
||||
"Vlan Interface": "1002",
|
||||
"Group Port-Channel": "Po1"
|
||||
}
|
||||
]
|
||||
},
|
||||
"Keepalive-interval": "1 sec",
|
||||
"MLAG Ports Configuration Summary": {
|
||||
"Disabled": "0",
|
||||
"Configured": "0",
|
||||
"Enabled": "0"
|
||||
},
|
||||
"Operational status": "Down"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"MLAG Port-Channel Flags": "D-Down, U-Up, P-Partial UP, S - suspended by MLAG",
|
||||
"Port Flags": {
|
||||
"I": "Individual",
|
||||
"P": "Up in port-channel (members)",
|
||||
"S": "Suspend in port-channel (members)",
|
||||
"D": "Down"
|
||||
},
|
||||
"MLAG Port-Channel Summary": {
|
||||
"1 Mpo33(S)": [
|
||||
{
|
||||
"Local Ports (D/P/S/I)": "Eth1/8(D)",
|
||||
"Peer Ports (D/P/S/I)": "N/A",
|
||||
"Type": "LACP"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
18
test/units/modules/network/onyx/fixtures/onyx_mlag_show.cfg
Normal file
18
test/units/modules/network/onyx/fixtures/onyx_mlag_show.cfg
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"Reload-delay": "30 sec",
|
||||
"Upgrade-timeout": "60 min",
|
||||
"System-mac": "00:00:5E:00:01:4E",
|
||||
"Admin status": "Disabled",
|
||||
"MLAG Ports Status Summary": {
|
||||
"Active-partial": "0",
|
||||
"Inactive": "0",
|
||||
"Active-full": "0"
|
||||
},
|
||||
"Keepalive-interval": "1 sec",
|
||||
"MLAG Ports Configuration Summary": {
|
||||
"Disabled": "0",
|
||||
"Configured": "0",
|
||||
"Enabled": "0"
|
||||
},
|
||||
"Operational status": "Down"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"r-neo-sw12": [
|
||||
{
|
||||
"IP Address": "10.209.26.55",
|
||||
"VIP-State": "standby"
|
||||
}
|
||||
],
|
||||
"r-smg-sw14": [
|
||||
{
|
||||
"IP Address": "10.209.27.172",
|
||||
"VIP-State": "master"
|
||||
}
|
||||
],
|
||||
"MLAG-VIP": {
|
||||
"MLAG VIP address": "10.209.25.107/24",
|
||||
"MLAG group name": "neo-mlag-vip-500",
|
||||
"Active nodes": "2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
OSPF Process ID 2 VRF default
|
||||
Total number of interface: 1
|
||||
Interface Id Area Cost State Neighbors Status
|
||||
Loopback1 0.0.0.0 1 Enabled 0 Up
|
||||
@@ -0,0 +1 @@
|
||||
Routing Process 2 with ID 10.2.3.4 default
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"Eth1/1": [
|
||||
{
|
||||
"PFC admin": "Auto",
|
||||
"PFC oper": "Disabled"
|
||||
}
|
||||
],
|
||||
"Eth1/1/2": [
|
||||
{
|
||||
"PFC admin": "Auto",
|
||||
"PFC oper": "Disabled"
|
||||
}
|
||||
],
|
||||
"Po1": [
|
||||
{
|
||||
"PFC admin": "Auto",
|
||||
"PFC oper": "Disabled"
|
||||
}
|
||||
],
|
||||
"Mpo2": [
|
||||
{
|
||||
"PFC admin": "Auto",
|
||||
"PFC oper": "Disabled"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"Eth1/1": [
|
||||
{
|
||||
"PFC admin": "on",
|
||||
"PFC oper": "Enabled"
|
||||
}
|
||||
],
|
||||
"Eth1/1/2": [
|
||||
{
|
||||
"PFC admin": "on",
|
||||
"PFC oper": "Enabled"
|
||||
}
|
||||
],
|
||||
"Po1": [
|
||||
{
|
||||
"PFC admin": "on",
|
||||
"PFC oper": "Enabled"
|
||||
}
|
||||
],
|
||||
"Mpo2": [
|
||||
{
|
||||
"PFC admin": "on",
|
||||
"PFC oper": "Enabled"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"Flags": {
|
||||
"I": "Individual",
|
||||
"P": "Up in port-channel (members)",
|
||||
"S": "Suspend in port-channel (members)",
|
||||
"U": "Up",
|
||||
"D": "Down"
|
||||
},
|
||||
"1 Po22(D)": [
|
||||
{
|
||||
"Type": "STATIC",
|
||||
"Member Ports": "Eth1/7(D)"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"pim": "disabled",
|
||||
"dhcp-relay": "disabled",
|
||||
"igmp-snooping": "disabled",
|
||||
"lacp": "disabled",
|
||||
"ptp": "disabled",
|
||||
"lldp": "disabled",
|
||||
"isolation-group": "disabled",
|
||||
"bfd": "disabled",
|
||||
"openflow": "disabled",
|
||||
"telemetry": "disabled",
|
||||
"vrrp": "disabled",
|
||||
"spanning-tree": "rst",
|
||||
"mlag": "disabled",
|
||||
"magp": "disabled",
|
||||
"nve": "disabled",
|
||||
"Ethernet": "enabled",
|
||||
"IP L3": "enabled",
|
||||
"ets": "enabled",
|
||||
"sflow": "disabled",
|
||||
"dhcp-relay(v6)": "disabled",
|
||||
"dot1x": "disabled",
|
||||
"bgp": "disabled",
|
||||
"priority-flow-control": "disabled",
|
||||
"ospf": "disabled"
|
||||
}
|
||||
14
test/units/modules/network/onyx/fixtures/onyx_vlan_show.cfg
Normal file
14
test/units/modules/network/onyx/fixtures/onyx_vlan_show.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"1": {
|
||||
"Name": "default",
|
||||
"Ports": "Eth1/1, Eth1/2, Eth1/3, Eth1/4, Eth1/5,\nEth1/6, Eth1/7, Eth1/8, Eth1/9, Eth1/10,\nEth1/11, Eth1/12, Eth1/13, Eth1/14, Eth1/15,\nEth1/16"
|
||||
},
|
||||
"10": {
|
||||
"Name": "test 10",
|
||||
"Ports": ""
|
||||
},
|
||||
"20": {
|
||||
"Name": "test 20",
|
||||
"Ports": ""
|
||||
}
|
||||
}
|
||||
91
test/units/modules/network/onyx/onyx_module.py
Normal file
91
test/units/modules/network/onyx/onyx_module.py
Normal file
@@ -0,0 +1,91 @@
|
||||
# (c) 2016 Red Hat Inc.
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
# Ansible is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Ansible is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase
|
||||
|
||||
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
||||
fixture_data = {}
|
||||
|
||||
|
||||
def load_fixture(name):
|
||||
path = os.path.join(fixture_path, name)
|
||||
|
||||
if path in fixture_data:
|
||||
return fixture_data[path]
|
||||
|
||||
with open(path) as f:
|
||||
data = f.read()
|
||||
|
||||
try:
|
||||
data = json.loads(data)
|
||||
except:
|
||||
pass
|
||||
|
||||
fixture_data[path] = data
|
||||
return data
|
||||
|
||||
|
||||
class TestOnyxModule(ModuleTestCase):
|
||||
|
||||
def execute_module(self, failed=False, changed=False, commands=None, is_updates=False, sort=True, transport='cli'):
|
||||
|
||||
self.load_fixtures(commands, transport=transport)
|
||||
|
||||
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 is_updates:
|
||||
commands_res = result.get('updates')
|
||||
else:
|
||||
commands_res = result.get('commands')
|
||||
if sort:
|
||||
self.assertEqual(sorted(commands), sorted(commands_res), commands_res)
|
||||
else:
|
||||
self.assertEqual(commands, commands_res, commands_res)
|
||||
|
||||
return result
|
||||
|
||||
def failed(self):
|
||||
with self.assertRaises(AnsibleFailJson) as exc:
|
||||
self.module.main()
|
||||
|
||||
result = exc.exception.args[0]
|
||||
self.assertTrue(result['failed'], result)
|
||||
return result
|
||||
|
||||
def changed(self, changed=False):
|
||||
with self.assertRaises(AnsibleExitJson) as exc:
|
||||
self.module.main()
|
||||
|
||||
result = exc.exception.args[0]
|
||||
self.assertEqual(result['changed'], changed, result)
|
||||
return result
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
pass
|
||||
87
test/units/modules/network/onyx/test_onyx_bgp.py
Normal file
87
test/units/modules/network/onyx/test_onyx_bgp.py
Normal file
@@ -0,0 +1,87 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_bgp
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxBgpModule(TestOnyxModule):
|
||||
|
||||
module = onyx_bgp
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxBgpModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_bgp.OnyxBgpModule, "_get_bgp_summary")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxBgpModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'onyx_bgp_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_bgp_no_change(self):
|
||||
neighbor = dict(remote_as=173, neighbor='10.2.3.4')
|
||||
set_module_args(dict(as_number=172, router_id='1.2.3.4',
|
||||
neighbors=[neighbor],
|
||||
networks=['172.16.1.0/24']))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_bgp_remove(self):
|
||||
set_module_args(dict(as_number=172, state='absent'))
|
||||
commands = ['no router bgp 172']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_bgp_change(self):
|
||||
neighbor = dict(remote_as=173, neighbor='10.2.3.4')
|
||||
set_module_args(dict(as_number=174, router_id='1.2.3.4',
|
||||
neighbors=[neighbor]))
|
||||
commands = ['no router bgp 172', 'router bgp 174', 'exit',
|
||||
'router bgp 174 router-id 1.2.3.4 force',
|
||||
'router bgp 174 neighbor 10.2.3.4 remote-as 173']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_bgp_add_neighbor(self):
|
||||
neighbors = [dict(remote_as=173, neighbor='10.2.3.4'),
|
||||
dict(remote_as=175, neighbor='10.2.3.5')]
|
||||
set_module_args(dict(as_number=172, router_id='1.2.3.4',
|
||||
neighbors=neighbors,
|
||||
networks=['172.16.1.0/24']))
|
||||
commands = ['router bgp 172 neighbor 10.2.3.5 remote-as 175']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_bgp_del_neighbor(self):
|
||||
set_module_args(dict(as_number=172,
|
||||
networks=['172.16.1.0/24']))
|
||||
commands = ['router bgp 172 no neighbor 10.2.3.4 remote-as 173']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_bgp_add_network(self):
|
||||
neighbors = [dict(remote_as=173, neighbor='10.2.3.4')]
|
||||
set_module_args(dict(as_number=172, router_id='1.2.3.4',
|
||||
neighbors=neighbors,
|
||||
networks=['172.16.1.0/24', '172.16.2.0/24']))
|
||||
commands = ['router bgp 172 network 172.16.2.0 /24']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_bgp_del_network(self):
|
||||
neighbors = [dict(remote_as=173, neighbor='10.2.3.4')]
|
||||
set_module_args(dict(as_number=172, neighbors=neighbors))
|
||||
commands = ['router bgp 172 no network 172.16.1.0 /24']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
114
test/units/modules/network/onyx/test_onyx_command.py
Normal file
114
test/units/modules/network/onyx/test_onyx_command.py
Normal file
@@ -0,0 +1,114 @@
|
||||
# (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.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_command
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxCommandModule(TestOnyxModule):
|
||||
|
||||
module = onyx_command
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxCommandModule, self).setUp()
|
||||
self.mock_run_commands = patch(
|
||||
'ansible.modules.network.onyx.onyx_command.run_commands')
|
||||
self.run_commands = self.mock_run_commands.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxCommandModule, self).tearDown()
|
||||
self.mock_run_commands.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
def load_from_file(*args, **kwargs):
|
||||
module, commands = args
|
||||
output = list()
|
||||
|
||||
for item in commands:
|
||||
try:
|
||||
obj = json.loads(item['command'])
|
||||
command = obj['command']
|
||||
except ValueError:
|
||||
command = item['command']
|
||||
filename = str(command).replace(' ', '_')
|
||||
filename = 'onyx_command_%s.txt' % filename
|
||||
output.append(load_fixture(filename))
|
||||
return output
|
||||
|
||||
self.run_commands.side_effect = load_from_file
|
||||
|
||||
def test_onyx_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('Product name'))
|
||||
|
||||
def test_onyx_command_multiple(self):
|
||||
set_module_args(dict(commands=['show version', 'show version']))
|
||||
result = self.execute_module()
|
||||
self.assertEqual(len(result['stdout']), 2)
|
||||
self.assertTrue(result['stdout'][0].startswith('Product name'))
|
||||
|
||||
def test_onyx_command_wait_for(self):
|
||||
wait_for = 'result[0] contains "MLNX"'
|
||||
set_module_args(dict(commands=['show version'], wait_for=wait_for))
|
||||
self.execute_module()
|
||||
|
||||
def test_onyx_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_onyx_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_onyx_command_match_any(self):
|
||||
wait_for = ['result[0] contains "MLNX"',
|
||||
'result[0] contains "test string"']
|
||||
set_module_args(dict(
|
||||
commands=['show version'],
|
||||
wait_for=wait_for,
|
||||
match='any'))
|
||||
self.execute_module()
|
||||
|
||||
def test_onyx_command_match_all(self):
|
||||
wait_for = ['result[0] contains "MLNX"',
|
||||
'result[0] contains "Version summary"']
|
||||
set_module_args(
|
||||
dict(commands=['show version'], wait_for=wait_for, match='all'))
|
||||
self.execute_module()
|
||||
|
||||
def test_onyx_command_match_all_failure(self):
|
||||
wait_for = ['result[0] contains "MLNX"',
|
||||
'result[0] contains "test string"']
|
||||
commands = ['show version', 'show version']
|
||||
set_module_args(
|
||||
dict(commands=commands, wait_for=wait_for, match='all'))
|
||||
self.execute_module(failed=True)
|
||||
113
test/units/modules/network/onyx/test_onyx_config.py
Normal file
113
test/units/modules/network/onyx/test_onyx_config.py
Normal file
@@ -0,0 +1,113 @@
|
||||
#
|
||||
# (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.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_config
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxConfigModule(TestOnyxModule):
|
||||
|
||||
module = onyx_config
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxConfigModule, self).setUp()
|
||||
|
||||
self.mock_get_config = patch('ansible.modules.network.onyx.onyx_config.get_config')
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch('ansible.modules.network.onyx.onyx_config.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
self.mock_run_commands = patch('ansible.modules.network.onyx.onyx_config.run_commands')
|
||||
self.run_commands = self.mock_run_commands.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxConfigModule, 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'):
|
||||
config_file = 'onyx_config_config.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_onyx_config_unchanged(self):
|
||||
src = load_fixture('onyx_config_config.cfg')
|
||||
set_module_args(dict(src=src))
|
||||
self.execute_module()
|
||||
|
||||
def test_onyx_config_src(self):
|
||||
src = load_fixture('onyx_config_src.cfg')
|
||||
set_module_args(dict(src=src))
|
||||
commands = [
|
||||
'interface mlag-port-channel 2']
|
||||
self.execute_module(changed=True, commands=commands, is_updates=True)
|
||||
|
||||
def test_onyx_config_backup(self):
|
||||
set_module_args(dict(backup=True))
|
||||
result = self.execute_module()
|
||||
self.assertIn('__backup__', result)
|
||||
|
||||
def test_onyx_config_save(self):
|
||||
set_module_args(dict(save='yes'))
|
||||
self.execute_module(changed=True)
|
||||
self.assertEqual(self.run_commands.call_count, 1)
|
||||
self.assertEqual(self.get_config.call_count, 1)
|
||||
self.assertEqual(self.load_config.call_count, 0)
|
||||
args = self.run_commands.call_args[0][1]
|
||||
self.assertIn('configuration write', args)
|
||||
|
||||
def test_onyx_config_lines_wo_parents(self):
|
||||
set_module_args(dict(lines=['hostname foo']))
|
||||
commands = ['hostname foo']
|
||||
self.execute_module(changed=True, commands=commands, is_updates=True)
|
||||
|
||||
def test_onyx_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, is_updates=True)
|
||||
|
||||
def test_onyx_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, is_updates=True)
|
||||
|
||||
def test_onyx_config_before_after(self):
|
||||
set_module_args(dict(lines=['hostname foo'],
|
||||
before=['test1', 'test2'],
|
||||
after=['test3', 'test4']))
|
||||
commands = ['test1', 'test2', 'hostname foo', 'test3', 'test4']
|
||||
self.execute_module(changed=True, commands=commands, sort=False, is_updates=True)
|
||||
|
||||
def test_onyx_config_config(self):
|
||||
config = 'hostname localhost'
|
||||
set_module_args(dict(lines=['hostname router'], config=config))
|
||||
commands = ['hostname router']
|
||||
self.execute_module(changed=True, commands=commands, is_updates=True)
|
||||
|
||||
def test_onyx_config_match_none(self):
|
||||
lines = ['hostname router']
|
||||
set_module_args(dict(lines=lines, match='none'))
|
||||
self.execute_module(changed=True, commands=lines, is_updates=True)
|
||||
71
test/units/modules/network/onyx/test_onyx_facts.py
Normal file
71
test/units/modules/network/onyx/test_onyx_facts.py
Normal file
@@ -0,0 +1,71 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
from ansible.modules.network.onyx import onyx_facts
|
||||
|
||||
|
||||
class TestOnyxFacts(TestOnyxModule):
|
||||
|
||||
module = onyx_facts
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxFacts, self).setUp()
|
||||
|
||||
self.mock_run_command = patch.object(
|
||||
onyx_facts.FactsBase, "_show_cmd")
|
||||
self.run_command = self.mock_run_command.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxFacts, self).tearDown()
|
||||
|
||||
self.mock_run_command.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport=None):
|
||||
|
||||
def load_from_file(*args, **kwargs):
|
||||
command = args[0]
|
||||
filename = "onyx_facts_%s.cfg" % command
|
||||
filename = filename.replace(' ', '_')
|
||||
filename = filename.replace('/', '7')
|
||||
output = load_fixture(filename)
|
||||
return output
|
||||
|
||||
self.run_command.side_effect = load_from_file
|
||||
|
||||
def test_onyx_facts_version(self):
|
||||
set_module_args(dict(gather_subset='version'))
|
||||
result = self.execute_module()
|
||||
facts = result.get('ansible_facts')
|
||||
self.assertEqual(len(facts), 2)
|
||||
version = facts['ansible_net_version']
|
||||
self.assertEqual(version['Product name'], 'MLNX-OS')
|
||||
|
||||
def test_onyx_facts_modules(self):
|
||||
set_module_args(dict(gather_subset='modules'))
|
||||
result = self.execute_module()
|
||||
facts = result.get('ansible_facts')
|
||||
self.assertEqual(len(facts), 2)
|
||||
modules = facts['ansible_net_modules']
|
||||
self.assertIn("MGMT", modules)
|
||||
|
||||
def test_onyx_facts_interfaces(self):
|
||||
set_module_args(dict(gather_subset='interfaces'))
|
||||
result = self.execute_module()
|
||||
facts = result.get('ansible_facts')
|
||||
self.assertEqual(len(facts), 2)
|
||||
interfaces = facts['ansible_net_interfaces']
|
||||
self.assertEqual(len(interfaces), 2)
|
||||
|
||||
def test_onyx_facts_all(self):
|
||||
set_module_args(dict(gather_subset='all'))
|
||||
result = self.execute_module()
|
||||
facts = result.get('ansible_facts')
|
||||
self.assertEqual(len(facts), 4)
|
||||
120
test/units/modules/network/onyx/test_onyx_interface.py
Normal file
120
test/units/modules/network/onyx/test_onyx_interface.py
Normal file
@@ -0,0 +1,120 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_interface
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxInterfaceModule(TestOnyxModule):
|
||||
|
||||
module = onyx_interface
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxInterfaceModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_interface.OnyxInterfaceModule, "_get_interfaces_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_get_interfaces_status = patch.object(
|
||||
onyx_interface.OnyxInterfaceModule, "_get_interfaces_status")
|
||||
self.get_interfaces_status = self.mock_get_interfaces_status.start()
|
||||
|
||||
self.mock_get_interfaces_rates = patch.object(
|
||||
onyx_interface.OnyxInterfaceModule, "_get_interfaces_rates")
|
||||
self.get_interfaces_rates = self.mock_get_interfaces_rates.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxInterfaceModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'onyx_interfaces_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_mtu_no_change(self):
|
||||
set_module_args(dict(name='Eth1/1', mtu=1500))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_mtu_change(self):
|
||||
set_module_args(dict(name='Eth1/1', mtu=1522))
|
||||
commands = ['interface ethernet 1/1', 'mtu 1522 force', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_speed_no_change(self):
|
||||
set_module_args(dict(name='Eth1/1', speed='40G'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_speed_change(self):
|
||||
set_module_args(dict(name='Eth1/1', speed='100G'))
|
||||
commands = ['interface ethernet 1/1', 'speed 100G force', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mtu_speed_change(self):
|
||||
set_module_args(dict(name='Eth1/1', speed='100G', mtu=1522))
|
||||
commands = ['interface ethernet 1/1', 'speed 100G force',
|
||||
'mtu 1522 force', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_admin_state_no_change(self):
|
||||
set_module_args(dict(name='Eth1/1', enabled=True))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_admin_state_change(self):
|
||||
set_module_args(dict(name='Eth1/1', enabled=False))
|
||||
commands = ['interface ethernet 1/1', 'shutdown', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_add_loopback_if(self):
|
||||
set_module_args(dict(name='Loopback 1', description='Loopback test'))
|
||||
commands = ['interface loopback 1', 'description Loopback test',
|
||||
'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_add_vlan_if(self):
|
||||
set_module_args(dict(name='Vlan 101', description='Vlan test',
|
||||
enabled=True))
|
||||
commands = ['interface vlan 101', 'description Vlan test',
|
||||
'no shutdown', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_remove_vlan_if(self):
|
||||
set_module_args(dict(name='Vlan 1002', state='absent'))
|
||||
commands = ['no interface vlan 1002']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_oper_state_check(self):
|
||||
set_module_args(dict(name='Eth1/1', enabled=True, state='down'))
|
||||
config_file = 'onyx_interfaces_status.cfg'
|
||||
self.get_interfaces_status.return_value = load_fixture(config_file)
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_vlan_oper_state_check(self):
|
||||
set_module_args(dict(name='Vlan 1002', state='down'))
|
||||
config_file = 'onyx_interfaces_status.cfg'
|
||||
self.get_interfaces_status.return_value = load_fixture(config_file)
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_rx_rate_check(self):
|
||||
set_module_args(dict(name='Eth1/1', enabled=True, rx_rate='ge(9000)'))
|
||||
config_file = 'onyx_interfaces_rates.cfg'
|
||||
self.get_interfaces_rates.return_value = load_fixture(config_file)
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_tx_rate_check(self):
|
||||
set_module_args(dict(name='Eth1/1', enabled=True, tx_rate='ge(10000)'))
|
||||
config_file = 'onyx_interfaces_rates.cfg'
|
||||
self.get_interfaces_rates.return_value = load_fixture(config_file)
|
||||
self.execute_module(changed=False)
|
||||
114
test/units/modules/network/onyx/test_onyx_l2_interface.py
Normal file
114
test/units/modules/network/onyx/test_onyx_l2_interface.py
Normal file
@@ -0,0 +1,114 @@
|
||||
#
|
||||
# (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.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_l2_interface
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxInterfaceModule(TestOnyxModule):
|
||||
|
||||
module = onyx_l2_interface
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxInterfaceModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_l2_interface.OnyxL2InterfaceModule, "_get_switchport_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxInterfaceModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'onyx_l2_interface_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_access_vlan_no_change(self):
|
||||
set_module_args(dict(name='Eth1/11', access_vlan=1))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_trunk_vlans_no_change(self):
|
||||
set_module_args(dict(name='Eth1/10', mode='hybrid', access_vlan=1,
|
||||
trunk_allowed_vlans=[10]))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_access_vlan_change(self):
|
||||
set_module_args(dict(name='Eth1/11', access_vlan=10))
|
||||
commands = ['interface ethernet 1/11', 'switchport access vlan 10',
|
||||
'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_trunk_vlan_change(self):
|
||||
set_module_args(dict(name='Eth1/10', mode='hybrid', access_vlan=1,
|
||||
trunk_allowed_vlans=[11]))
|
||||
commands = ['interface ethernet 1/10',
|
||||
'switchport hybrid allowed-vlan remove 10',
|
||||
'switchport hybrid allowed-vlan add 11', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_trunk_vlan_add(self):
|
||||
set_module_args(dict(name='Eth1/10', mode='hybrid', access_vlan=1,
|
||||
trunk_allowed_vlans=[10, 11]))
|
||||
commands = ['interface ethernet 1/10',
|
||||
'switchport hybrid allowed-vlan add 11', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_switch_port_access(self):
|
||||
set_module_args(dict(name='Eth1/12', mode='access', access_vlan=11))
|
||||
commands = ['interface ethernet 1/12', 'switchport mode access',
|
||||
'switchport access vlan 11', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_switch_port_trunk(self):
|
||||
set_module_args(dict(name='Eth1/12', mode='trunk',
|
||||
trunk_allowed_vlans=[11]))
|
||||
commands = ['interface ethernet 1/12', 'switchport mode trunk',
|
||||
'switchport trunk allowed-vlan add 11', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_switch_port_hybrid(self):
|
||||
set_module_args(dict(name='Eth1/12', mode='hybrid', access_vlan=10,
|
||||
trunk_allowed_vlans=[11]))
|
||||
commands = ['interface ethernet 1/12', 'switchport mode hybrid',
|
||||
'switchport access vlan 10',
|
||||
'switchport hybrid allowed-vlan add 11', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_aggregate(self):
|
||||
aggregate = list()
|
||||
aggregate.append(dict(name='Eth1/10'))
|
||||
aggregate.append(dict(name='Eth1/12'))
|
||||
|
||||
set_module_args(dict(aggregate=aggregate, access_vlan=10))
|
||||
commands = ['interface ethernet 1/10', 'switchport mode access',
|
||||
'switchport access vlan 10', 'exit',
|
||||
'interface ethernet 1/12', 'switchport mode access',
|
||||
'switchport access vlan 10', 'exit']
|
||||
self.execute_module(changed=True, commands=commands, sort=False)
|
||||
108
test/units/modules/network/onyx/test_onyx_l3_interface.py
Normal file
108
test/units/modules/network/onyx/test_onyx_l3_interface.py
Normal file
@@ -0,0 +1,108 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_l3_interface
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxL3InterfaceModule(TestOnyxModule):
|
||||
|
||||
module = onyx_l3_interface
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxL3InterfaceModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_l3_interface.OnyxL3InterfaceModule,
|
||||
"_get_interfaces_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxL3InterfaceModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def _execute_module(self, failed=False, changed=False, commands=None, sort=True):
|
||||
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:
|
||||
commands_res = result.get('commands')
|
||||
if sort:
|
||||
self.assertEqual(sorted(commands), sorted(commands_res), commands_res)
|
||||
else:
|
||||
self.assertEqual(commands, commands_res, commands_res)
|
||||
|
||||
return result
|
||||
|
||||
def load_fixture(self, config_file):
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def load_eth_ifc_fixture(self):
|
||||
config_file = 'onyx_l3_interface_show.cfg'
|
||||
self.load_fixture(config_file)
|
||||
|
||||
def load_vlan_ifc_fixture(self):
|
||||
config_file = 'onyx_l3_vlan_interface_show.cfg'
|
||||
self.load_fixture(config_file)
|
||||
|
||||
def test_vlan_ifc_no_change(self):
|
||||
set_module_args(dict(name='Vlan 1002', state='present',
|
||||
ipv4='172.3.12.4/24'))
|
||||
self.load_vlan_ifc_fixture()
|
||||
self._execute_module(changed=False)
|
||||
|
||||
def test_vlan_ifc_remove(self):
|
||||
set_module_args(dict(name='Vlan 1002', state='absent'))
|
||||
commands = ['interface vlan 1002 no ip address']
|
||||
self.load_vlan_ifc_fixture()
|
||||
self._execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_vlan_ifc_update(self):
|
||||
set_module_args(dict(name='Vlan 1002', state='present',
|
||||
ipv4='172.3.13.4/24'))
|
||||
commands = ['interface vlan 1002 ip address 172.3.13.4/24']
|
||||
self.load_vlan_ifc_fixture()
|
||||
self._execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eth_ifc_no_change(self):
|
||||
set_module_args(dict(name='Eth1/5', state='present',
|
||||
ipv4='172.3.12.4/24'))
|
||||
self.load_eth_ifc_fixture()
|
||||
self._execute_module(changed=False)
|
||||
|
||||
def test_eth_ifc_remove(self):
|
||||
set_module_args(dict(name='Eth1/5', state='absent'))
|
||||
commands = ['interface ethernet 1/5 no ip address']
|
||||
self.load_eth_ifc_fixture()
|
||||
self._execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eth_ifc_update(self):
|
||||
set_module_args(dict(name='Eth1/5', state='present',
|
||||
ipv4='172.3.13.4/24'))
|
||||
commands = ['interface ethernet 1/5 ip address 172.3.13.4/24']
|
||||
self.load_eth_ifc_fixture()
|
||||
self._execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_eth_ifc_add_ip(self):
|
||||
set_module_args(dict(name='Eth1/6', state='present',
|
||||
ipv4='172.3.14.4/24'))
|
||||
commands = ['interface ethernet 1/6 no switchport force',
|
||||
'interface ethernet 1/6 ip address 172.3.14.4/24']
|
||||
self.load_eth_ifc_fixture()
|
||||
self._execute_module(changed=True, commands=commands)
|
||||
111
test/units/modules/network/onyx/test_onyx_linkagg.py
Normal file
111
test/units/modules/network/onyx/test_onyx_linkagg.py
Normal file
@@ -0,0 +1,111 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_linkagg
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxLinkaggModule(TestOnyxModule):
|
||||
|
||||
module = onyx_linkagg
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxLinkaggModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_linkagg.OnyxLinkAggModule,
|
||||
"_get_port_channels")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxLinkaggModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixture(self, config_file):
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def load_port_channel_fixture(self):
|
||||
config_file = 'onyx_port_channel_show.cfg'
|
||||
self.load_fixture(config_file)
|
||||
|
||||
def load_mlag_port_channel_fixture(self):
|
||||
config_file = 'onyx_mlag_port_channel_show.cfg'
|
||||
self.load_fixture(config_file)
|
||||
|
||||
def test_port_channel_no_change(self):
|
||||
set_module_args(dict(name='Po22', state='present',
|
||||
members=['Eth1/7']))
|
||||
self.load_port_channel_fixture()
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_port_channel_remove(self):
|
||||
set_module_args(dict(name='Po22', state='absent'))
|
||||
self.load_port_channel_fixture()
|
||||
commands = ['no interface port-channel 22']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_port_channel_add(self):
|
||||
set_module_args(dict(name='Po23', state='present',
|
||||
members=['Eth1/8']))
|
||||
self.load_port_channel_fixture()
|
||||
commands = ['interface port-channel 23', 'exit',
|
||||
'interface ethernet 1/8 channel-group 23 mode on']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_port_channel_add_member(self):
|
||||
set_module_args(dict(name='Po22', state='present',
|
||||
members=['Eth1/7', 'Eth1/8']))
|
||||
self.load_port_channel_fixture()
|
||||
commands = ['interface ethernet 1/8 channel-group 22 mode on']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_port_channel_remove_member(self):
|
||||
set_module_args(dict(name='Po22', state='present'))
|
||||
self.load_port_channel_fixture()
|
||||
commands = ['interface ethernet 1/7 no channel-group']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mlag_port_channel_no_change(self):
|
||||
set_module_args(dict(name='Mpo33', state='present',
|
||||
members=['Eth1/8']))
|
||||
self.load_mlag_port_channel_fixture()
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_mlag_port_channel_remove(self):
|
||||
set_module_args(dict(name='Mpo33', state='absent'))
|
||||
self.load_mlag_port_channel_fixture()
|
||||
commands = ['no interface mlag-port-channel 33']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mlag_port_channel_add(self):
|
||||
set_module_args(dict(name='Mpo34', state='present',
|
||||
members=['Eth1/9']))
|
||||
self.load_mlag_port_channel_fixture()
|
||||
commands = ['interface mlag-port-channel 34', 'exit',
|
||||
'interface ethernet 1/9 mlag-channel-group 34 mode on']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mlag_port_channel_add_member(self):
|
||||
set_module_args(dict(name='Mpo33', state='present',
|
||||
members=['Eth1/8', 'Eth1/9']))
|
||||
self.load_mlag_port_channel_fixture()
|
||||
commands = ['interface ethernet 1/9 mlag-channel-group 33 mode on']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mlag_port_channel_remove_member(self):
|
||||
set_module_args(dict(name='Mpo33', state='present'))
|
||||
self.load_mlag_port_channel_fixture()
|
||||
commands = ['interface ethernet 1/8 no mlag-channel-group']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
70
test/units/modules/network/onyx/test_onyx_lldp.py
Normal file
70
test/units/modules/network/onyx/test_onyx_lldp.py
Normal file
@@ -0,0 +1,70 @@
|
||||
#
|
||||
# (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.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_lldp
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxInterfaceModule(TestOnyxModule):
|
||||
|
||||
module = onyx_lldp
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxInterfaceModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_lldp.OnyxLldpModule, "_get_lldp_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxInterfaceModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
if commands == ['lldp']:
|
||||
self.get_config.return_value = None
|
||||
else:
|
||||
config_file = 'onyx_lldp_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_lldp_no_change(self):
|
||||
set_module_args(dict())
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_lldp_disable(self):
|
||||
set_module_args(dict(state='absent'))
|
||||
commands = ['no lldp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_enable(self):
|
||||
set_module_args(dict(state='present'))
|
||||
commands = ['lldp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
76
test/units/modules/network/onyx/test_onyx_lldp_interface.py
Normal file
76
test/units/modules/network/onyx/test_onyx_lldp_interface.py
Normal file
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_lldp_interface
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxLldpInterfaceModule(TestOnyxModule):
|
||||
|
||||
module = onyx_lldp_interface
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxLldpInterfaceModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_lldp_interface.OnyxLldpInterfaceModule,
|
||||
"_get_lldp_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxLldpInterfaceModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'onyx_lldp_interface_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_lldp_no_change(self):
|
||||
set_module_args(dict(name='Eth1/1', state='present'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_no_lldp_no_change(self):
|
||||
set_module_args(dict(name='Eth1/2', state='absent'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_no_lldp_change(self):
|
||||
set_module_args(dict(name='Eth1/2', state='present'))
|
||||
commands = ['interface ethernet 1/2 lldp receive',
|
||||
'interface ethernet 1/2 lldp transmit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_change(self):
|
||||
set_module_args(dict(name='Eth1/1', state='absent'))
|
||||
commands = ['interface ethernet 1/1 no lldp receive',
|
||||
'interface ethernet 1/1 no lldp transmit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_aggregate(self):
|
||||
aggregate = [dict(name='Eth1/1'), dict(name='Eth1/2')]
|
||||
set_module_args(dict(aggregate=aggregate, state='present'))
|
||||
commands = ['interface ethernet 1/2 lldp receive',
|
||||
'interface ethernet 1/2 lldp transmit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_aggregate_purge(self):
|
||||
aggregate = [dict(name='Eth1/3'), dict(name='Eth1/2')]
|
||||
set_module_args(dict(aggregate=aggregate, state='present', purge=True))
|
||||
commands = ['interface ethernet 1/2 lldp receive',
|
||||
'interface ethernet 1/2 lldp transmit',
|
||||
'interface ethernet 1/3 lldp receive',
|
||||
'interface ethernet 1/3 lldp transmit',
|
||||
'interface ethernet 1/1 no lldp receive',
|
||||
'interface ethernet 1/1 no lldp transmit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
104
test/units/modules/network/onyx/test_onyx_magp.py
Normal file
104
test/units/modules/network/onyx/test_onyx_magp.py
Normal file
@@ -0,0 +1,104 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_magp
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxMagpModule(TestOnyxModule):
|
||||
|
||||
module = onyx_magp
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxMagpModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_magp.OnyxMagpModule,
|
||||
"_get_magp_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxMagpModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'onyx_magp_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_magp_absent_no_change(self):
|
||||
set_module_args(dict(interface='Vlan 1002', magp_id=110,
|
||||
state='absent'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_magp_no_change(self):
|
||||
set_module_args(dict(interface='Vlan 1200', magp_id=103,
|
||||
state='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_magp_present_no_change(self):
|
||||
set_module_args(dict(interface='Vlan 1200', magp_id=103))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_magp_enable(self):
|
||||
set_module_args(dict(interface='Vlan 1200', magp_id=103,
|
||||
state='enabled'))
|
||||
commands = ['interface vlan 1200 magp 103 no shutdown']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_magp_disable(self):
|
||||
set_module_args(dict(interface='Vlan 1243', magp_id=102,
|
||||
state='disabled', router_ip='10.0.0.43',
|
||||
router_mac='01:02:03:04:05:06'))
|
||||
commands = ['interface vlan 1243 magp 102 shutdown']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_magp_change_address(self):
|
||||
set_module_args(dict(interface='Vlan 1243', magp_id=102,
|
||||
router_ip='10.0.0.44',
|
||||
router_mac='01:02:03:04:05:07'))
|
||||
commands = [
|
||||
'interface vlan 1243 magp 102 ip virtual-router address 10.0.0.44',
|
||||
'interface vlan 1243 magp 102 ip virtual-router mac-address 01:02:03:04:05:07']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_magp_remove_address(self):
|
||||
set_module_args(dict(interface='Vlan 1243', magp_id=102))
|
||||
commands = [
|
||||
'interface vlan 1243 magp 102 no ip virtual-router address',
|
||||
'interface vlan 1243 magp 102 no ip virtual-router mac-address']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_magp_add(self):
|
||||
set_module_args(dict(interface='Vlan 1244', magp_id=104,
|
||||
router_ip='10.0.0.44',
|
||||
router_mac='01:02:03:04:05:07'))
|
||||
commands = [
|
||||
'interface vlan 1244 magp 104',
|
||||
'exit',
|
||||
'interface vlan 1244 magp 104 ip virtual-router address 10.0.0.44',
|
||||
'interface vlan 1244 magp 104 ip virtual-router mac-address 01:02:03:04:05:07']
|
||||
self.execute_module(changed=True, commands=commands, sort=False)
|
||||
|
||||
def test_magp_change_vlan(self):
|
||||
set_module_args(dict(interface='Vlan 1244', magp_id=102,
|
||||
router_ip='10.0.0.43',
|
||||
router_mac='01:02:03:04:05:06'))
|
||||
commands = [
|
||||
'interface vlan 1243 no magp 102',
|
||||
'interface vlan 1244 magp 102',
|
||||
'exit',
|
||||
'interface vlan 1244 magp 102 ip virtual-router address 10.0.0.43',
|
||||
'interface vlan 1244 magp 102 ip virtual-router mac-address 01:02:03:04:05:06']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
86
test/units/modules/network/onyx/test_onyx_mlag_ipl.py
Normal file
86
test/units/modules/network/onyx/test_onyx_mlag_ipl.py
Normal file
@@ -0,0 +1,86 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_mlag_ipl
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxMlagIplModule(TestOnyxModule):
|
||||
|
||||
module = onyx_mlag_ipl
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxMlagIplModule, self).setUp()
|
||||
self._mlag_enabled = True
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_mlag_ipl.OnyxMlagIplModule,
|
||||
"_show_mlag_data")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxMlagIplModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
if self._mlag_enabled:
|
||||
config_file = 'onyx_mlag_ipl_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
else:
|
||||
self.get_config.return_value = None
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_no_ipl_no_change(self):
|
||||
self._mlag_enabled = False
|
||||
set_module_args(dict(name="Po1", state='absent'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ipl_no_change(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1002',
|
||||
peer_address='10.2.2.2'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ipl_add(self):
|
||||
self._mlag_enabled = False
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1002',
|
||||
peer_address='10.2.2.2'))
|
||||
commands = ['interface port-channel 1 ipl 1',
|
||||
'interface vlan 1002 ipl 1 peer-address 10.2.2.2']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ipl_add_peer(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1002',
|
||||
peer_address='10.2.2.4'))
|
||||
commands = ['interface vlan 1002 ipl 1 peer-address 10.2.2.4']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ipl_remove(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='absent'))
|
||||
commands = ['interface port-channel 1 no ipl 1']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ipl_change_vlan(self):
|
||||
self._mlag_enabled = True
|
||||
set_module_args(dict(name="Po1", state='present',
|
||||
vlan_interface='Vlan 1003',
|
||||
peer_address='10.2.2.4'))
|
||||
commands = ['interface vlan 1002 no ipl 1',
|
||||
'interface vlan 1003 ipl 1 peer-address 10.2.2.4']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
76
test/units/modules/network/onyx/test_onyx_mlag_vip.py
Normal file
76
test/units/modules/network/onyx/test_onyx_mlag_vip.py
Normal file
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_mlag_vip
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxMlagVipModule(TestOnyxModule):
|
||||
|
||||
module = onyx_mlag_vip
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxMlagVipModule, self).setUp()
|
||||
self._mlag_enabled = True
|
||||
self.mock_show_mlag = patch.object(
|
||||
onyx_mlag_vip.OnyxMLagVipModule,
|
||||
"_show_mlag")
|
||||
self.show_mlag = self.mock_show_mlag.start()
|
||||
self.mock_show_mlag_vip = patch.object(
|
||||
onyx_mlag_vip.OnyxMLagVipModule,
|
||||
"_show_mlag_vip")
|
||||
self.show_mlag_vip = self.mock_show_mlag_vip.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxMlagVipModule, self).tearDown()
|
||||
self.mock_show_mlag.stop()
|
||||
self.mock_show_mlag_vip.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
if self._mlag_enabled:
|
||||
config_file = 'onyx_mlag_vip_show.cfg'
|
||||
self.show_mlag_vip.return_value = load_fixture(config_file)
|
||||
config_file = 'onyx_mlag_show.cfg'
|
||||
self.show_mlag.return_value = load_fixture(config_file)
|
||||
else:
|
||||
self.show_mlag_vip.return_value = None
|
||||
self.show_mlag.return_value = None
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_mlag_no_change(self):
|
||||
set_module_args(dict(ipaddress='10.209.25.107/24',
|
||||
group_name='neo-mlag-vip-500',
|
||||
mac_address='00:00:5E:00:01:4E'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_mlag_change(self):
|
||||
self._mlag_enabled = False
|
||||
set_module_args(dict(ipaddress='10.209.25.107/24',
|
||||
group_name='neo-mlag-vip-500',
|
||||
mac_address='00:00:5E:00:01:4E',
|
||||
delay=0))
|
||||
commands = ['mlag-vip neo-mlag-vip-500 ip 10.209.25.107 /24 force',
|
||||
'mlag system-mac 00:00:5e:00:01:4e', 'no mlag shutdown']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mlag_absent_no_change(self):
|
||||
self._mlag_enabled = False
|
||||
set_module_args(dict(state='absent'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_mlag_absent_change(self):
|
||||
set_module_args(dict(state='absent', delay=0))
|
||||
commands = ['no mlag-vip']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
106
test/units/modules/network/onyx/test_onyx_ospf.py
Normal file
106
test/units/modules/network/onyx/test_onyx_ospf.py
Normal file
@@ -0,0 +1,106 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_ospf
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxOspfModule(TestOnyxModule):
|
||||
|
||||
module = onyx_ospf
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxOspfModule, self).setUp()
|
||||
self._ospf_exists = True
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_ospf.OnyxOspfModule,
|
||||
"_get_ospf_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_get_interfaces_config = patch.object(
|
||||
onyx_ospf.OnyxOspfModule,
|
||||
"_get_ospf_interfaces_config")
|
||||
self.get_interfaces_config = self.mock_get_interfaces_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxOspfModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
if self._ospf_exists:
|
||||
config_file = 'onyx_ospf_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
config_file = 'onyx_ospf_interfaces_show.cfg'
|
||||
self.get_interfaces_config.return_value = load_fixture(config_file)
|
||||
else:
|
||||
self.get_config.return_value = None
|
||||
self.get_interfaces_config.return_value = None
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_ospf_absent_no_change(self):
|
||||
set_module_args(dict(ospf=3, state='absent'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ospf_present_no_change(self):
|
||||
interface = dict(name='Loopback 1', area='0.0.0.0')
|
||||
set_module_args(dict(ospf=2, router_id='10.2.3.4',
|
||||
interfaces=[interface]))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ospf_present_remove(self):
|
||||
set_module_args(dict(ospf=2, state='absent'))
|
||||
commands = ['no router ospf 2']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ospf_change_router(self):
|
||||
interface = dict(name='Loopback 1', area='0.0.0.0')
|
||||
set_module_args(dict(ospf=2, router_id='10.2.3.5',
|
||||
interfaces=[interface]))
|
||||
commands = ['router ospf 2', 'router-id 10.2.3.5', 'exit']
|
||||
self.execute_module(changed=True, commands=commands, sort=False)
|
||||
|
||||
def test_ospf_remove_router(self):
|
||||
interface = dict(name='Loopback 1', area='0.0.0.0')
|
||||
set_module_args(dict(ospf=2, interfaces=[interface]))
|
||||
commands = ['router ospf 2', 'no router-id', 'exit']
|
||||
self.execute_module(changed=True, commands=commands, sort=False)
|
||||
|
||||
def test_ospf_add_interface(self):
|
||||
interfaces = [dict(name='Loopback 1', area='0.0.0.0'),
|
||||
dict(name='Loopback 2', area='0.0.0.0')]
|
||||
set_module_args(dict(ospf=2, router_id='10.2.3.4',
|
||||
interfaces=interfaces))
|
||||
commands = ['interface loopback 2 ip ospf area 0.0.0.0']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ospf_remove_interface(self):
|
||||
set_module_args(dict(ospf=2, router_id='10.2.3.4'))
|
||||
commands = ['interface loopback 1 no ip ospf area']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ospf_add(self):
|
||||
self._ospf_exists = False
|
||||
interfaces = [dict(name='Loopback 1', area='0.0.0.0'),
|
||||
dict(name='Vlan 210', area='0.0.0.0'),
|
||||
dict(name='Eth1/1', area='0.0.0.0'),
|
||||
dict(name='Po1', area='0.0.0.0')]
|
||||
set_module_args(dict(ospf=2, router_id='10.2.3.4',
|
||||
interfaces=interfaces))
|
||||
commands = ['router ospf 2', 'router-id 10.2.3.4', 'exit',
|
||||
'interface loopback 1 ip ospf area 0.0.0.0',
|
||||
'interface vlan 210 ip ospf area 0.0.0.0',
|
||||
'interface ethernet 1/1 ip ospf area 0.0.0.0',
|
||||
'interface port-channel 1 ip ospf area 0.0.0.0']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
109
test/units/modules/network/onyx/test_onyx_pfc_interface.py
Normal file
109
test/units/modules/network/onyx/test_onyx_pfc_interface.py
Normal file
@@ -0,0 +1,109 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_pfc_interface
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxPfcInterfaceModule(TestOnyxModule):
|
||||
|
||||
module = onyx_pfc_interface
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxPfcInterfaceModule, self).setUp()
|
||||
self._pfc_enabled = True
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_pfc_interface.OnyxPfcInterfaceModule,
|
||||
"_get_pfc_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxPfcInterfaceModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
if self._pfc_enabled:
|
||||
suffix = 'enabled'
|
||||
else:
|
||||
suffix = 'disabled'
|
||||
config_file = 'onyx_pfc_interface_%s.cfg' % suffix
|
||||
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def _test_pfc_if(self, if_name, enabled, changed, commands):
|
||||
state = 'enabled' if enabled else 'disabled'
|
||||
set_module_args(dict(name=if_name, state=state))
|
||||
self.execute_module(changed=changed, commands=commands)
|
||||
|
||||
def _test_pfc_no_change(self, enabled):
|
||||
interfaces = ('Eth1/1', 'Eth1/1/2', 'Po1', 'Mpo2')
|
||||
changed = False
|
||||
commands = None
|
||||
for ifc in interfaces:
|
||||
self._test_pfc_if(ifc, enabled, changed, commands)
|
||||
|
||||
def test_pfc_enabled_no_change(self):
|
||||
self._pfc_enabled = True
|
||||
enabled = True
|
||||
self._test_pfc_no_change(enabled)
|
||||
|
||||
def test_pfc_disabled_no_change(self):
|
||||
self._pfc_enabled = False
|
||||
enabled = False
|
||||
self._test_pfc_no_change(enabled)
|
||||
|
||||
def _test_pfc_change(self, enabled):
|
||||
cmd_list = [
|
||||
('Eth1/1', 'interface ethernet 1/1'),
|
||||
('Eth1/1/2', 'interface ethernet 1/1/2'),
|
||||
('Po1', 'interface port-channel 1'),
|
||||
('Mpo2', 'interface mlag-port-channel 2'),
|
||||
]
|
||||
changed = True
|
||||
suffix = ' dcb priority-flow-control mode on force'
|
||||
if not enabled:
|
||||
suffix = ' no dcb priority-flow-control mode force'
|
||||
for (if_name, cmd) in cmd_list:
|
||||
commands = [cmd + suffix]
|
||||
self._test_pfc_if(if_name, enabled, changed, commands)
|
||||
|
||||
def test_pfc_disabled_change(self):
|
||||
self._pfc_enabled = False
|
||||
enabled = True
|
||||
self._test_pfc_change(enabled)
|
||||
|
||||
def test_pfc_enabled_change(self):
|
||||
self._pfc_enabled = True
|
||||
enabled = False
|
||||
self._test_pfc_change(enabled)
|
||||
|
||||
def test_pfc_aggregate(self):
|
||||
self._pfc_enabled = False
|
||||
aggregate = [dict(name='Eth1/1'), dict(name='Eth1/1/2')]
|
||||
set_module_args(dict(aggregate=aggregate, state='enabled'))
|
||||
commands = [
|
||||
'interface ethernet 1/1 dcb priority-flow-control mode on force',
|
||||
'interface ethernet 1/1/2 dcb priority-flow-control mode on force']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_pfc_aggregate_purge(self):
|
||||
self._pfc_enabled = True
|
||||
aggregate = [dict(name='Po1'), dict(name='Mpo2')]
|
||||
set_module_args(dict(aggregate=aggregate, state='enabled', purge=True))
|
||||
commands = [
|
||||
'interface ethernet 1/1 no dcb priority-flow-control mode force',
|
||||
'interface ethernet 1/1/2 no dcb priority-flow-control mode force']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
134
test/units/modules/network/onyx/test_onyx_protocols.py
Normal file
134
test/units/modules/network/onyx/test_onyx_protocols.py
Normal file
@@ -0,0 +1,134 @@
|
||||
#
|
||||
# Copyright: Ansible Project
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
# Make coding more python3-ish
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_protocol
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxProtocolModule(TestOnyxModule):
|
||||
|
||||
module = onyx_protocol
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxProtocolModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_protocol.OnyxProtocolModule,
|
||||
"_get_protocols")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_get_ip_config = patch.object(
|
||||
onyx_protocol.OnyxProtocolModule,
|
||||
"_get_ip_routing")
|
||||
self.get_ip_config = self.mock_get_ip_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxProtocolModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'onyx_protocols_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
self.get_ip_config.return_value = "IP routing: enabled"
|
||||
|
||||
def test_mlag_enable(self):
|
||||
set_module_args(dict(mlag='enabled'))
|
||||
commands = ['protocol mlag']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_mlag_disable(self):
|
||||
set_module_args(dict(mlag='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_magp_enable(self):
|
||||
set_module_args(dict(magp='enabled'))
|
||||
commands = ['protocol magp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_magp_disable(self):
|
||||
set_module_args(dict(magp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_spanning_tree_enable(self):
|
||||
set_module_args(dict(spanning_tree='enabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_spanning_tree_disable(self):
|
||||
set_module_args(dict(spanning_tree='disabled'))
|
||||
commands = ['no spanning-tree']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_dcb_pfc_enable(self):
|
||||
set_module_args(dict(dcb_pfc='enabled'))
|
||||
commands = ['dcb priority-flow-control enable force']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_dcb_pfc_disable(self):
|
||||
set_module_args(dict(dcb_pfc='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_igmp_snooping_enable(self):
|
||||
set_module_args(dict(igmp_snooping='enabled'))
|
||||
commands = ['ip igmp snooping']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_igmp_snooping_disable(self):
|
||||
set_module_args(dict(igmp_snooping='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_lacp_enable(self):
|
||||
set_module_args(dict(lacp='enabled'))
|
||||
commands = ['lacp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lacp_disable(self):
|
||||
set_module_args(dict(lacp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ip_routing_enable(self):
|
||||
set_module_args(dict(ip_routing='enabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ip_routing_disable(self):
|
||||
set_module_args(dict(ip_routing='disabled'))
|
||||
commands = ['no ip routing']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_enable(self):
|
||||
set_module_args(dict(lldp='enabled'))
|
||||
commands = ['lldp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_lldp_disable(self):
|
||||
set_module_args(dict(lldp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_bgp_enable(self):
|
||||
set_module_args(dict(bgp='enabled'))
|
||||
commands = ['protocol bgp']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_bgp_disable(self):
|
||||
set_module_args(dict(bgp='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_ospf_enable(self):
|
||||
set_module_args(dict(ospf='enabled'))
|
||||
commands = ['protocol ospf']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_ospf_disable(self):
|
||||
set_module_args(dict(ospf='disabled'))
|
||||
self.execute_module(changed=False)
|
||||
102
test/units/modules/network/onyx/test_onyx_vlan.py
Normal file
102
test/units/modules/network/onyx/test_onyx_vlan.py
Normal file
@@ -0,0 +1,102 @@
|
||||
#
|
||||
# (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.compat.tests.mock import patch
|
||||
from ansible.modules.network.onyx import onyx_vlan
|
||||
from units.modules.utils import set_module_args
|
||||
from .onyx_module import TestOnyxModule, load_fixture
|
||||
|
||||
|
||||
class TestOnyxVlanModule(TestOnyxModule):
|
||||
|
||||
module = onyx_vlan
|
||||
|
||||
def setUp(self):
|
||||
super(TestOnyxVlanModule, self).setUp()
|
||||
self.mock_get_config = patch.object(
|
||||
onyx_vlan.OnyxVlanModule, "_get_vlan_config")
|
||||
self.get_config = self.mock_get_config.start()
|
||||
|
||||
self.mock_load_config = patch(
|
||||
'ansible.module_utils.network.onyx.onyx.load_config')
|
||||
self.load_config = self.mock_load_config.start()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOnyxVlanModule, self).tearDown()
|
||||
self.mock_get_config.stop()
|
||||
self.mock_load_config.stop()
|
||||
|
||||
def load_fixtures(self, commands=None, transport='cli'):
|
||||
config_file = 'onyx_vlan_show.cfg'
|
||||
self.get_config.return_value = load_fixture(config_file)
|
||||
self.load_config.return_value = None
|
||||
|
||||
def test_vlan_no_change(self):
|
||||
set_module_args(dict(vlan_id=20))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_vlan_remove_name(self):
|
||||
set_module_args(dict(vlan_id=10, name=''))
|
||||
commands = ['vlan 10 no name']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_vlan_change_name(self):
|
||||
set_module_args(dict(vlan_id=10, name='test-test'))
|
||||
commands = ['vlan 10 name test-test']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_vlan_create(self):
|
||||
set_module_args(dict(vlan_id=30))
|
||||
commands = ['vlan 30', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_vlan_create_with_name(self):
|
||||
set_module_args(dict(vlan_id=30, name='test-test'))
|
||||
commands = ['vlan 30', 'exit', 'vlan 30 name test-test']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_vlan_remove(self):
|
||||
set_module_args(dict(vlan_id=20, state='absent'))
|
||||
commands = ['no vlan 20']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_vlan_remove_not_exist(self):
|
||||
set_module_args(dict(vlan_id=30, state='absent'))
|
||||
self.execute_module(changed=False)
|
||||
|
||||
def test_vlan_aggregate(self):
|
||||
aggregate = list()
|
||||
aggregate.append(dict(vlan_id=30))
|
||||
aggregate.append(dict(vlan_id=20))
|
||||
set_module_args(dict(aggregate=aggregate))
|
||||
commands = ['vlan 30', 'exit']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
|
||||
def test_vlan_aggregate_purge(self):
|
||||
aggregate = list()
|
||||
aggregate.append(dict(vlan_id=30))
|
||||
aggregate.append(dict(vlan_id=20))
|
||||
set_module_args(dict(aggregate=aggregate, purge=True))
|
||||
commands = ['vlan 30', 'exit', 'no vlan 10', 'no vlan 1']
|
||||
self.execute_module(changed=True, commands=commands)
|
||||
Reference in New Issue
Block a user