cisco_node_utils 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +126 -1
- data/README.md +19 -12
- data/Rakefile +1 -0
- data/bin/git/hooks/commit-msg/enforce_style +8 -0
- data/cisco_node_utils.gemspec +4 -3
- data/docs/README-develop-best-practices.md +127 -109
- data/docs/README-develop-node-utils-APIs.md +47 -39
- data/docs/template-router.rb +3 -7
- data/lib/.rubocop.yml +4 -4
- data/lib/cisco_node_utils.rb +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
- data/lib/cisco_node_utils/ace.rb +196 -0
- data/lib/cisco_node_utils/acl.rb +100 -0
- data/lib/cisco_node_utils/bgp.rb +301 -163
- data/lib/cisco_node_utils/bgp_af.rb +187 -19
- data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
- data/lib/cisco_node_utils/command_reference.rb +359 -187
- data/lib/cisco_node_utils/configparser_lib.rb +1 -1
- data/lib/cisco_node_utils/dns_domain.rb +19 -5
- data/lib/cisco_node_utils/domain_name.rb +4 -8
- data/lib/cisco_node_utils/evpn_vni.rb +157 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
- data/lib/cisco_node_utils/feature.rb +111 -0
- data/lib/cisco_node_utils/interface.rb +390 -97
- data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
- data/lib/cisco_node_utils/interface_ospf.rb +11 -34
- data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/name_server.rb +1 -1
- data/lib/cisco_node_utils/node.rb +55 -249
- data/lib/cisco_node_utils/node_util.rb +5 -1
- data/lib/cisco_node_utils/ntp_config.rb +2 -2
- data/lib/cisco_node_utils/ntp_server.rb +14 -5
- data/lib/cisco_node_utils/overlay_global.rb +153 -0
- data/lib/cisco_node_utils/pim.rb +124 -0
- data/lib/cisco_node_utils/pim_group_list.rb +108 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
- data/lib/cisco_node_utils/platform.rb +8 -9
- data/lib/cisco_node_utils/portchannel_global.rb +277 -0
- data/lib/cisco_node_utils/radius_global.rb +9 -19
- data/lib/cisco_node_utils/radius_server.rb +31 -41
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
- data/lib/cisco_node_utils/snmpgroup.rb +1 -1
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +8 -17
- data/lib/cisco_node_utils/snmpuser.rb +67 -28
- data/lib/cisco_node_utils/syslog_server.rb +3 -9
- data/lib/cisco_node_utils/syslog_settings.rb +2 -10
- data/lib/cisco_node_utils/tacacs_server.rb +9 -14
- data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
- data/lib/cisco_node_utils/vdc.rb +88 -0
- data/lib/cisco_node_utils/version.rb +5 -2
- data/lib/cisco_node_utils/vlan.rb +71 -8
- data/lib/cisco_node_utils/vni.rb +227 -0
- data/lib/cisco_node_utils/vpc.rb +377 -0
- data/lib/cisco_node_utils/vrf.rb +60 -9
- data/lib/cisco_node_utils/vrf_af.rb +191 -0
- data/lib/cisco_node_utils/vtp.rb +8 -6
- data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
- data/lib/cisco_node_utils/yum.rb +1 -1
- data/tests/.rubocop.yml +1 -1
- data/tests/basetest.rb +16 -7
- data/tests/ciscotest.rb +55 -13
- data/tests/cmd_config.yaml +2 -2
- data/tests/platform_info.rb +3 -2
- data/tests/test_aaa_authentication_login.rb +219 -0
- data/tests/test_aaa_authentication_login_service.rb +759 -0
- data/tests/test_aaa_authorization_service.rb +1041 -0
- data/tests/test_ace.rb +160 -0
- data/tests/test_acl.rb +176 -0
- data/tests/test_bgp_af.rb +269 -13
- data/tests/test_bgp_neighbor.rb +38 -40
- data/tests/test_bgp_neighbor_af.rb +92 -32
- data/tests/test_command_config.rb +5 -5
- data/tests/test_command_reference.rb +284 -101
- data/tests/test_dns_domain.rb +1 -1
- data/tests/test_domain_name.rb +1 -1
- data/tests/test_evpn_vni.rb +106 -0
- data/tests/test_fabricpath_global.rb +243 -0
- data/tests/test_fabricpath_topology.rb +98 -0
- data/tests/test_interface.rb +292 -74
- data/tests/test_interface_channel_group.rb +74 -0
- data/tests/test_interface_ospf.rb +9 -4
- data/tests/test_interface_portchannel.rb +105 -0
- data/tests/test_interface_service_vni.rb +232 -0
- data/tests/test_interface_svi.rb +77 -62
- data/tests/test_interface_switchport.rb +17 -5
- data/tests/test_name_server.rb +1 -1
- data/tests/test_node.rb +1 -1
- data/tests/test_node_ext.rb +10 -20
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +18 -6
- data/tests/test_overlay_global.rb +102 -0
- data/tests/test_pim.rb +177 -0
- data/tests/test_pim_group_list.rb +181 -0
- data/tests/test_pim_rp_address.rb +153 -0
- data/tests/test_platform.rb +3 -3
- data/tests/test_portchannel_global.rb +202 -0
- data/tests/test_radius_global.rb +1 -1
- data/tests/test_radius_server.rb +92 -57
- data/tests/test_radius_server_group.rb +149 -0
- data/tests/test_router_bgp.rb +283 -112
- data/tests/test_router_ospf.rb +2 -2
- data/tests/test_router_ospf_vrf.rb +4 -4
- data/tests/test_snmp_notification_receiver.rb +167 -0
- data/tests/test_snmpcommunity.rb +1 -1
- data/tests/test_snmpgroup.rb +1 -1
- data/tests/test_snmpnotification.rb +72 -0
- data/tests/test_snmpserver.rb +29 -105
- data/tests/test_snmpuser.rb +32 -30
- data/tests/test_syslog_server.rb +36 -10
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_server.rb +1 -1
- data/tests/test_tacacs_server_group.rb +405 -0
- data/tests/test_tacacs_server_host.rb +1 -1
- data/tests/test_vdc.rb +78 -0
- data/tests/test_vlan.rb +74 -19
- data/tests/test_vlan_mt_full.rb +95 -0
- data/tests/test_vni.rb +106 -0
- data/tests/test_vpc.rb +361 -0
- data/tests/test_vrf.rb +172 -29
- data/tests/test_vtp.rb +1 -1
- data/tests/test_vxlan_vtep.rb +214 -0
- data/tests/test_vxlan_vtep_vni.rb +201 -0
- data/tests/test_yum.rb +1 -1
- metadata +120 -11
- data/lib/cisco_node_utils/README_YAML.md +0 -325
- data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
- data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
- data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
- data/tests/platform_info.yaml +0 -10
@@ -0,0 +1,153 @@
|
|
1
|
+
# Copyright (c) 2013-2016 Cisco and/or its affiliates.
|
2
|
+
#
|
3
|
+
# Smitha Gopalan, November 2015
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
# ---------------------------------------------------------------------
|
17
|
+
# Cli: <afi> pim rp-address <rp-address> (under different VRFs)
|
18
|
+
# ---------------------------------------------------------------------
|
19
|
+
# Testcases: All Tests create and destroy all instances within a test
|
20
|
+
#
|
21
|
+
# 1. test_all_rp_addrs
|
22
|
+
#
|
23
|
+
# 2. test_single_invalid_rpaddr_single_vrf:
|
24
|
+
# vrf default, ip pim rp-address 256.256.256.256
|
25
|
+
# ---------------------------------------------------------------------
|
26
|
+
|
27
|
+
require_relative 'ciscotest'
|
28
|
+
require_relative '../lib/cisco_node_utils/pim_rp_address'
|
29
|
+
|
30
|
+
include Cisco
|
31
|
+
|
32
|
+
# TestPimRpAddress - Minitest for PimRpAddress
|
33
|
+
class TestPimRpAddress < CiscoTestCase
|
34
|
+
# Enables feature pim
|
35
|
+
#--------------------
|
36
|
+
def setup
|
37
|
+
super
|
38
|
+
config('no feature pim')
|
39
|
+
end
|
40
|
+
|
41
|
+
# Test PimRpAddress.rp_addresses
|
42
|
+
# - multiple vrfs, rp_addrs
|
43
|
+
# - same rp_addr, different vrf
|
44
|
+
#--------------------------------------------
|
45
|
+
def all_rp_addrs(afi)
|
46
|
+
rp_addr1 = '11.11.11.11'
|
47
|
+
rp_addr2 = '22.22.22.22'
|
48
|
+
|
49
|
+
# Basic setup
|
50
|
+
vrf = 'default'
|
51
|
+
pd1 = PimRpAddress.new(afi, vrf, rp_addr1)
|
52
|
+
pd2 = PimRpAddress.new(afi, vrf, rp_addr2)
|
53
|
+
hash = PimRpAddress.rp_addresses
|
54
|
+
assert(hash.key?(afi))
|
55
|
+
assert(hash[afi].key?(vrf))
|
56
|
+
assert_equal(2, hash[afi][vrf].keys.count,
|
57
|
+
"hash[#{afi}][#{vrf}] should have 2 rp-address")
|
58
|
+
assert(hash[afi][vrf].key?(rp_addr1),
|
59
|
+
"hash[#{afi}][#{vrf}] does not contain #{rp_addr1}")
|
60
|
+
assert(hash[afi][vrf].key?(rp_addr2),
|
61
|
+
"hash[#{afi}][#{vrf}] does not contain #{rp_addr2}")
|
62
|
+
|
63
|
+
# vrf with same rp_addrs as in default
|
64
|
+
vrf = 'red'
|
65
|
+
pd3 = PimRpAddress.new(afi, vrf, rp_addr1)
|
66
|
+
pd4 = PimRpAddress.new(afi, vrf, rp_addr2)
|
67
|
+
hash = PimRpAddress.rp_addresses
|
68
|
+
assert_equal(2, hash[afi].keys.count,
|
69
|
+
"hash[#{afi}] does not have 2 vrfs")
|
70
|
+
assert(hash[afi].key?(vrf))
|
71
|
+
assert_equal(2, hash[afi][vrf].keys.count,
|
72
|
+
"hash[#{afi}][#{vrf}] should have 2 rp-address")
|
73
|
+
assert(hash[afi][vrf].key?(rp_addr1),
|
74
|
+
"hash[#{afi}][#{vrf}] does not contain #{rp_addr1}")
|
75
|
+
assert(hash[afi][vrf].key?(rp_addr2),
|
76
|
+
"hash[#{afi}][#{vrf}] does not contain #{rp_addr2}")
|
77
|
+
|
78
|
+
# different vrf, same/diff rps
|
79
|
+
vrf = 'black'
|
80
|
+
rp_addr7 = '7.7.7.7'
|
81
|
+
pd5 = PimRpAddress.new(afi, vrf, rp_addr1)
|
82
|
+
pd6 = PimRpAddress.new(afi, vrf, rp_addr2)
|
83
|
+
pd7 = PimRpAddress.new(afi, vrf, rp_addr7)
|
84
|
+
hash = PimRpAddress.rp_addresses
|
85
|
+
assert_equal(3, hash[afi].keys.count,
|
86
|
+
"hash[#{afi}] does not have 3 vrfs")
|
87
|
+
assert(hash[afi].key?(vrf))
|
88
|
+
assert_equal(3, hash[afi][vrf].keys.count,
|
89
|
+
"hash[#{afi}][#{vrf}] should have 3 rp-address")
|
90
|
+
assert(hash[afi][vrf].key?(rp_addr1),
|
91
|
+
"hash[#{afi}][#{vrf}] does not contain #{rp_addr1}")
|
92
|
+
assert(hash[afi][vrf].key?(rp_addr1),
|
93
|
+
"hash[#{afi}][#{vrf}] does not contain #{rp_addr2}")
|
94
|
+
assert(hash[afi][vrf].key?(rp_addr7),
|
95
|
+
"hash[#{afi}][#{vrf}] does not contain #{rp_addr7}")
|
96
|
+
|
97
|
+
# Test removal
|
98
|
+
vrf = 'default'
|
99
|
+
pd1.destroy
|
100
|
+
hash = PimRpAddress.rp_addresses
|
101
|
+
assert_equal(1, hash[afi][vrf].keys.count,
|
102
|
+
"hash[#{afi}][#{vrf}] should have 1 rp-address")
|
103
|
+
refute(hash[afi][vrf].key?(rp_addr1),
|
104
|
+
"hash[#{afi}][#{vrf}] should not contain #{rp_addr1}")
|
105
|
+
|
106
|
+
vrf = 'red'
|
107
|
+
pd3.destroy
|
108
|
+
hash = PimRpAddress.rp_addresses
|
109
|
+
assert_equal(1, hash[afi][vrf].keys.count,
|
110
|
+
"hash[#{afi}][#{vrf}] should have 1 rp-address")
|
111
|
+
refute(hash[afi][vrf].key?(rp_addr1),
|
112
|
+
"hash[#{afi}][#{vrf}] should not contain #{rp_addr1}")
|
113
|
+
|
114
|
+
vrf = 'black'
|
115
|
+
pd5.destroy
|
116
|
+
pd7.destroy
|
117
|
+
hash = PimRpAddress.rp_addresses
|
118
|
+
assert_equal(1, hash[afi][vrf].keys.count,
|
119
|
+
"hash[#{afi}][#{vrf}] should have 1 rp-address")
|
120
|
+
refute(hash[afi][vrf].key?([rp_addr1]),
|
121
|
+
"hash[#{afi}][#{vrf}] should not contain [#{rp_addr1}]")
|
122
|
+
pd2.destroy
|
123
|
+
pd4.destroy
|
124
|
+
pd6.destroy
|
125
|
+
hash = PimRpAddress.rp_addresses
|
126
|
+
assert_empty(hash[afi], 'hash[#{afi}] is not empty')
|
127
|
+
end
|
128
|
+
|
129
|
+
# Tests PimRpAddress.rp_addresses
|
130
|
+
#------------------------------------------
|
131
|
+
def test_all_rp_addrs
|
132
|
+
%w(ipv4).each do |afi|
|
133
|
+
all_rp_addrs(afi)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# Creates single invalid rp address under vrf default
|
138
|
+
#---------------------------------------------------
|
139
|
+
def create_single_invalid_rpaddr_single_vrf(afi)
|
140
|
+
rp_addr = '256.256.256.256'
|
141
|
+
assert_raises(CliError) do
|
142
|
+
PimRpAddress.new(afi, 'default', rp_addr)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Tests single invalid rp address under vrf default
|
147
|
+
#---------------------------------------------------
|
148
|
+
def test_single_invalid_rpaddr_single_vrf
|
149
|
+
%w(ipv4).each do |afi|
|
150
|
+
create_single_invalid_rpaddr_single_vrf(afi)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
data/tests/test_platform.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2015 Cisco and/or its affiliates.
|
1
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -181,7 +181,7 @@ class TestPlatform < CiscoTestCase
|
|
181
181
|
vir_hsh_hsh = {}
|
182
182
|
unless vir_arr.nil?
|
183
183
|
vir_arr.each do |serv|
|
184
|
-
# rubocop:disable Style/AlignHash
|
184
|
+
# rubocop:disable Style/AlignHash
|
185
185
|
vir_hsh_hsh[serv['name']] = {
|
186
186
|
'package_info' => { 'name' => serv['package_name'],
|
187
187
|
'path' => serv['ova_path'],
|
@@ -201,7 +201,7 @@ class TestPlatform < CiscoTestCase
|
|
201
201
|
'cpu' => serv['cpu_reservation'],
|
202
202
|
},
|
203
203
|
}
|
204
|
-
# rubocop:enable Style/AlignHash
|
204
|
+
# rubocop:enable Style/AlignHash
|
205
205
|
end
|
206
206
|
end
|
207
207
|
assert_equal(vir_hsh_hsh, Platform.virtual_services)
|
@@ -0,0 +1,202 @@
|
|
1
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require_relative 'ciscotest'
|
16
|
+
require_relative '../lib/cisco_node_utils/portchannel_global'
|
17
|
+
|
18
|
+
# TestX__CLASS_NAME__X - Minitest for X__CLASS_NAME__X node utility class
|
19
|
+
class TestPortchannelGlobal < CiscoTestCase
|
20
|
+
# TESTS
|
21
|
+
|
22
|
+
DEFAULT_NAME = 'default'
|
23
|
+
|
24
|
+
def setup
|
25
|
+
super
|
26
|
+
config 'no port-channel load-balance' unless n6k_platform?
|
27
|
+
config 'no port-channel load-balance ethernet' unless
|
28
|
+
n9k_platform? || n7k_platform?
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
config 'no port-channel load-balance' unless n6k_platform?
|
33
|
+
config 'no port-channel load-balance ethernet' unless
|
34
|
+
n9k_platform? || n7k_platform?
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def n3k_in_n3k_mode?
|
39
|
+
return unless /N3/ =~ node.product_id
|
40
|
+
mode = config('show system switch-mode')
|
41
|
+
# note: an n3k in n9k mode displays: 'system switch-mode n9k'
|
42
|
+
patterns = ['system switch-mode n3k',
|
43
|
+
'Switch mode configuration is not not applicable']
|
44
|
+
mode[Regexp.union(patterns)] ? true : false
|
45
|
+
end
|
46
|
+
|
47
|
+
def n7k_platform?
|
48
|
+
/N7/ =~ node.product_id
|
49
|
+
end
|
50
|
+
|
51
|
+
def n9k_platform?
|
52
|
+
/N(3|9)/ =~ node.product_id
|
53
|
+
end
|
54
|
+
|
55
|
+
def n6k_platform?
|
56
|
+
/N(5|6)/ =~ node.product_id
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_portchannel_global(name=DEFAULT_NAME)
|
60
|
+
PortChannelGlobal.new(name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_get_hash_distribution
|
64
|
+
skip('Platform does not support this property') if n6k_platform? ||
|
65
|
+
n9k_platform?
|
66
|
+
@global = create_portchannel_global
|
67
|
+
@global.hash_distribution = 'fixed'
|
68
|
+
assert_equal('fixed', @global.hash_distribution)
|
69
|
+
@global.hash_distribution =
|
70
|
+
@global.default_hash_distribution
|
71
|
+
assert_equal(@global.default_hash_distribution,
|
72
|
+
@global.hash_distribution)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_get_set_load_defer
|
76
|
+
skip('Platform does not support this property') if n6k_platform? ||
|
77
|
+
n9k_platform?
|
78
|
+
@global = create_portchannel_global
|
79
|
+
@global.load_defer = 1000
|
80
|
+
assert_equal(1000, @global.load_defer)
|
81
|
+
@global.load_defer =
|
82
|
+
@global.default_load_defer
|
83
|
+
assert_equal(@global.default_load_defer,
|
84
|
+
@global.load_defer)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_get_set_resilient
|
88
|
+
skip('Platform does not support this property') if n6k_platform? ||
|
89
|
+
n7k_platform?
|
90
|
+
@global = create_portchannel_global
|
91
|
+
@global.resilient = true
|
92
|
+
assert_equal(true, @global.resilient)
|
93
|
+
@global.resilient = @global.default_resilient
|
94
|
+
assert_equal(@global.default_resilient, @global.resilient)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_get_set_port_channel_load_balance_sym_concat_rot
|
98
|
+
skip('Platform does not support this property') if
|
99
|
+
n6k_platform? || n7k_platform? || n3k_in_n3k_mode?
|
100
|
+
@global = create_portchannel_global
|
101
|
+
@global.send(:port_channel_load_balance=,
|
102
|
+
'src-dst', 'ip-l4port', nil, nil, true, true, 4)
|
103
|
+
assert_equal('src-dst',
|
104
|
+
@global.bundle_select)
|
105
|
+
assert_equal('ip-l4port',
|
106
|
+
@global.bundle_hash)
|
107
|
+
assert_equal(true, @global.symmetry)
|
108
|
+
assert_equal(true, @global.concatenation)
|
109
|
+
assert_equal(4, @global.rotate)
|
110
|
+
@global.send(
|
111
|
+
:port_channel_load_balance=,
|
112
|
+
@global.default_bundle_select,
|
113
|
+
@global.default_bundle_hash,
|
114
|
+
nil,
|
115
|
+
nil,
|
116
|
+
@global.default_symmetry,
|
117
|
+
@global.default_concatenation,
|
118
|
+
@global.default_rotate)
|
119
|
+
assert_equal(
|
120
|
+
@global.default_bundle_select,
|
121
|
+
@global.bundle_select)
|
122
|
+
assert_equal(
|
123
|
+
@global.default_bundle_hash,
|
124
|
+
@global.bundle_hash)
|
125
|
+
assert_equal(
|
126
|
+
@global.default_symmetry,
|
127
|
+
@global.symmetry)
|
128
|
+
assert_equal(
|
129
|
+
@global.default_concatenation,
|
130
|
+
@global.concatenation)
|
131
|
+
assert_equal(@global.default_rotate,
|
132
|
+
@global.rotate)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_get_set_port_channel_load_balance_hash_poly
|
136
|
+
skip('Platform does not support this property') if n7k_platform? ||
|
137
|
+
n9k_platform?
|
138
|
+
@global = create_portchannel_global
|
139
|
+
@global.send(:port_channel_load_balance=,
|
140
|
+
'src-dst', 'ip-only', 'CRC10c', nil, nil, nil, nil)
|
141
|
+
assert_equal('src-dst',
|
142
|
+
@global.bundle_select)
|
143
|
+
assert_equal('ip-only',
|
144
|
+
@global.bundle_hash)
|
145
|
+
assert_equal('CRC10c', @global.hash_poly)
|
146
|
+
@global.send(:port_channel_load_balance=,
|
147
|
+
'dst', 'mac', 'CRC10a', nil, nil, nil, nil)
|
148
|
+
assert_equal('dst',
|
149
|
+
@global.bundle_select)
|
150
|
+
assert_equal('mac',
|
151
|
+
@global.bundle_hash)
|
152
|
+
assert_equal('CRC10a', @global.hash_poly)
|
153
|
+
@global.send(
|
154
|
+
:port_channel_load_balance=,
|
155
|
+
@global.default_bundle_select,
|
156
|
+
@global.default_bundle_hash,
|
157
|
+
@global.default_hash_poly,
|
158
|
+
nil, nil, nil, nil)
|
159
|
+
assert_equal(
|
160
|
+
@global.default_bundle_select,
|
161
|
+
@global.bundle_select)
|
162
|
+
assert_equal(
|
163
|
+
@global.default_bundle_hash,
|
164
|
+
@global.bundle_hash)
|
165
|
+
assert_equal(@global.default_hash_poly,
|
166
|
+
@global.hash_poly)
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_get_set_port_channel_load_balance_asym_rot
|
170
|
+
skip('Platform does not support this property') if n6k_platform? ||
|
171
|
+
n9k_platform?
|
172
|
+
@global = create_portchannel_global
|
173
|
+
@global.send(:port_channel_load_balance=,
|
174
|
+
'src-dst', 'ip-vlan', nil, true, nil, nil, 4)
|
175
|
+
assert_equal('src-dst',
|
176
|
+
@global.bundle_select)
|
177
|
+
assert_equal('ip-vlan',
|
178
|
+
@global.bundle_hash)
|
179
|
+
assert_equal(true, @global.asymmetric)
|
180
|
+
assert_equal(4, @global.rotate)
|
181
|
+
@global.send(
|
182
|
+
:port_channel_load_balance=,
|
183
|
+
@global.default_bundle_select,
|
184
|
+
@global.default_bundle_hash,
|
185
|
+
nil,
|
186
|
+
@global.default_asymmetric,
|
187
|
+
nil,
|
188
|
+
nil,
|
189
|
+
@global.default_rotate)
|
190
|
+
assert_equal(
|
191
|
+
@global.default_bundle_select,
|
192
|
+
@global.bundle_select)
|
193
|
+
assert_equal(
|
194
|
+
@global.default_bundle_hash,
|
195
|
+
@global.bundle_hash)
|
196
|
+
assert_equal(
|
197
|
+
@global.default_asymmetric,
|
198
|
+
@global.asymmetric)
|
199
|
+
assert_equal(@global.default_rotate,
|
200
|
+
@global.rotate)
|
201
|
+
end
|
202
|
+
end
|
data/tests/test_radius_global.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Minitest for RadiusGlobal class
|
3
3
|
#
|
4
|
-
# Copyright (c) 2014-
|
4
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
data/tests/test_radius_server.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Minitest for RadiusServer class
|
3
3
|
#
|
4
|
-
# Copyright (c) 2014-
|
4
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
@@ -35,24 +35,25 @@ class TestRadiusServer < CiscoTestCase
|
|
35
35
|
def no_radiusserver
|
36
36
|
# Turn the feature off for a clean test.
|
37
37
|
config('no radius-server host 8.8.8.8',
|
38
|
-
'no radius-server host
|
38
|
+
'no radius-server host 2004::3',
|
39
|
+
'no radius-server host 2005::7')
|
39
40
|
end
|
40
41
|
|
41
42
|
# TESTS
|
42
43
|
|
43
|
-
def
|
44
|
+
def test_create_destroy_single
|
44
45
|
id = '8.8.8.8'
|
45
46
|
refute_includes(Cisco::RadiusServer.radiusservers, id)
|
46
47
|
|
47
48
|
server = Cisco::RadiusServer.new(id, true)
|
48
49
|
assert_includes(Cisco::RadiusServer.radiusservers, id)
|
49
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id]
|
50
|
+
assert_equal(server, Cisco::RadiusServer.radiusservers[id])
|
50
51
|
|
51
52
|
# Default checking
|
52
|
-
assert_equal(server.
|
53
|
-
assert_equal(server.
|
54
|
-
assert_equal(server.
|
55
|
-
assert_equal(server.
|
53
|
+
assert_equal(server.default_acct_port, server.acct_port)
|
54
|
+
assert_equal(server.default_auth_port, server.auth_port)
|
55
|
+
assert_equal(server.default_accounting, server.accounting)
|
56
|
+
assert_equal(server.default_authentication, server.authentication)
|
56
57
|
|
57
58
|
server.accounting = true
|
58
59
|
assert(Cisco::RadiusServer.radiusservers[id].accounting)
|
@@ -61,30 +62,72 @@ class TestRadiusServer < CiscoTestCase
|
|
61
62
|
assert(Cisco::RadiusServer.radiusservers[id].authentication)
|
62
63
|
|
63
64
|
server.acct_port = 44
|
64
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].acct_port
|
65
|
-
44)
|
65
|
+
assert_equal(44, Cisco::RadiusServer.radiusservers[id].acct_port)
|
66
66
|
|
67
67
|
server.auth_port = 55
|
68
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].auth_port
|
69
|
-
55)
|
68
|
+
assert_equal(55, Cisco::RadiusServer.radiusservers[id].auth_port)
|
70
69
|
|
71
70
|
server.retransmit_count = 3
|
72
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].retransmit_count
|
73
|
-
3)
|
71
|
+
assert_equal(3, Cisco::RadiusServer.radiusservers[id].retransmit_count)
|
74
72
|
|
75
73
|
server.key_set('44444444', nil)
|
76
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].key
|
77
|
-
'44444444')
|
74
|
+
assert_equal('44444444', Cisco::RadiusServer.radiusservers[id].key)
|
78
75
|
|
79
76
|
# Setting back to default and re-checking
|
80
77
|
server.acct_port = server.default_acct_port
|
81
78
|
server.auth_port = server.default_auth_port
|
82
79
|
server.accounting = server.default_accounting
|
83
80
|
server.authentication = server.default_authentication
|
84
|
-
assert_equal(server.
|
85
|
-
assert_equal(server.
|
86
|
-
assert_equal(server.
|
87
|
-
assert_equal(server.
|
81
|
+
assert_equal(server.default_acct_port, server.acct_port)
|
82
|
+
assert_equal(server.default_auth_port, server.auth_port)
|
83
|
+
assert_equal(server.default_accounting, server.accounting)
|
84
|
+
assert_equal(server.default_authentication, server.authentication)
|
85
|
+
|
86
|
+
server.destroy
|
87
|
+
refute_includes(Cisco::RadiusServer.radiusservers, id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_create_destroy_single_ipv6
|
91
|
+
id = '2004::3'
|
92
|
+
refute_includes(Cisco::RadiusServer.radiusservers, id)
|
93
|
+
|
94
|
+
server = Cisco::RadiusServer.new(id, true)
|
95
|
+
assert_includes(Cisco::RadiusServer.radiusservers, id)
|
96
|
+
assert_equal(server, Cisco::RadiusServer.radiusservers[id])
|
97
|
+
|
98
|
+
# Default checking
|
99
|
+
assert_equal(server.default_acct_port, server.acct_port)
|
100
|
+
assert_equal(server.default_auth_port, server.auth_port)
|
101
|
+
assert_equal(server.default_accounting, server.accounting)
|
102
|
+
assert_equal(server.default_authentication, server.authentication)
|
103
|
+
|
104
|
+
server.accounting = true
|
105
|
+
assert(Cisco::RadiusServer.radiusservers[id].accounting)
|
106
|
+
|
107
|
+
server.authentication = true
|
108
|
+
assert(Cisco::RadiusServer.radiusservers[id].authentication)
|
109
|
+
|
110
|
+
server.acct_port = 44
|
111
|
+
assert_equal(44, Cisco::RadiusServer.radiusservers[id].acct_port)
|
112
|
+
|
113
|
+
server.auth_port = 55
|
114
|
+
assert_equal(55, Cisco::RadiusServer.radiusservers[id].auth_port)
|
115
|
+
|
116
|
+
server.retransmit_count = 3
|
117
|
+
assert_equal(3, Cisco::RadiusServer.radiusservers[id].retransmit_count)
|
118
|
+
|
119
|
+
server.key_set('44444444', nil)
|
120
|
+
assert_equal('44444444', Cisco::RadiusServer.radiusservers[id].key)
|
121
|
+
|
122
|
+
# Setting back to default and re-checking
|
123
|
+
server.acct_port = server.default_acct_port
|
124
|
+
server.auth_port = server.default_auth_port
|
125
|
+
server.accounting = server.default_accounting
|
126
|
+
server.authentication = server.default_authentication
|
127
|
+
assert_equal(server.default_acct_port, server.acct_port)
|
128
|
+
assert_equal(server.default_auth_port, server.auth_port)
|
129
|
+
assert_equal(server.default_accounting, server.accounting)
|
130
|
+
assert_equal(server.default_authentication, server.authentication)
|
88
131
|
|
89
132
|
server.destroy
|
90
133
|
refute_includes(Cisco::RadiusServer.radiusservers, id)
|
@@ -92,26 +135,27 @@ class TestRadiusServer < CiscoTestCase
|
|
92
135
|
|
93
136
|
def test_radiusserver_create_destroy_multiple
|
94
137
|
id = '8.8.8.8'
|
95
|
-
id2 = '
|
138
|
+
id2 = '2005::7'
|
139
|
+
|
96
140
|
refute_includes(Cisco::RadiusServer.radiusservers, id)
|
97
141
|
refute_includes(Cisco::RadiusServer.radiusservers, id2)
|
98
142
|
|
99
143
|
server = Cisco::RadiusServer.new(id, true)
|
100
144
|
server2 = Cisco::RadiusServer.new(id2, true)
|
101
145
|
assert_includes(Cisco::RadiusServer.radiusservers, id)
|
102
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id]
|
146
|
+
assert_equal(server, Cisco::RadiusServer.radiusservers[id])
|
103
147
|
assert_includes(Cisco::RadiusServer.radiusservers, id2)
|
104
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id2]
|
148
|
+
assert_equal(server2, Cisco::RadiusServer.radiusservers[id2])
|
105
149
|
|
106
150
|
# Default checking
|
107
|
-
assert_equal(server.
|
108
|
-
assert_equal(server.
|
109
|
-
assert_equal(server.
|
110
|
-
assert_equal(server.
|
111
|
-
assert_equal(server2.
|
112
|
-
assert_equal(server2.
|
113
|
-
assert_equal(server2.
|
114
|
-
assert_equal(server2.
|
151
|
+
assert_equal(server.default_acct_port, server.acct_port)
|
152
|
+
assert_equal(server.default_auth_port, server.auth_port)
|
153
|
+
assert_equal(server.default_accounting, server.accounting)
|
154
|
+
assert_equal(server.default_authentication, server.authentication)
|
155
|
+
assert_equal(server2.default_acct_port, server2.acct_port)
|
156
|
+
assert_equal(server2.default_auth_port, server2.auth_port)
|
157
|
+
assert_equal(server2.default_accounting, server2.accounting)
|
158
|
+
assert_equal(server2.default_authentication, server2.authentication)
|
115
159
|
|
116
160
|
server.accounting = true
|
117
161
|
assert(Cisco::RadiusServer.radiusservers[id].accounting)
|
@@ -120,22 +164,17 @@ class TestRadiusServer < CiscoTestCase
|
|
120
164
|
assert(Cisco::RadiusServer.radiusservers[id].authentication)
|
121
165
|
|
122
166
|
server.acct_port = 44
|
123
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].acct_port
|
124
|
-
44)
|
167
|
+
assert_equal(44, Cisco::RadiusServer.radiusservers[id].acct_port)
|
125
168
|
|
126
169
|
server.auth_port = 55
|
127
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].auth_port
|
128
|
-
55)
|
170
|
+
assert_equal(55, Cisco::RadiusServer.radiusservers[id].auth_port)
|
129
171
|
|
130
172
|
server.retransmit_count = 3
|
131
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].retransmit_count
|
132
|
-
3)
|
173
|
+
assert_equal(3, Cisco::RadiusServer.radiusservers[id].retransmit_count)
|
133
174
|
|
134
175
|
server.key_set('44444444', nil)
|
135
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id].key
|
136
|
-
|
137
|
-
assert_equal(server.key,
|
138
|
-
'44444444')
|
176
|
+
assert_equal('44444444', Cisco::RadiusServer.radiusservers[id].key)
|
177
|
+
assert_equal('44444444', server.key)
|
139
178
|
|
140
179
|
server2.accounting = true
|
141
180
|
assert(Cisco::RadiusServer.radiusservers[id2].accounting)
|
@@ -144,20 +183,16 @@ class TestRadiusServer < CiscoTestCase
|
|
144
183
|
assert(Cisco::RadiusServer.radiusservers[id2].authentication)
|
145
184
|
|
146
185
|
server2.acct_port = 44
|
147
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id2].acct_port
|
148
|
-
44)
|
186
|
+
assert_equal(44, Cisco::RadiusServer.radiusservers[id2].acct_port)
|
149
187
|
|
150
188
|
server2.auth_port = 55
|
151
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id2].auth_port
|
152
|
-
55)
|
189
|
+
assert_equal(55, Cisco::RadiusServer.radiusservers[id2].auth_port)
|
153
190
|
|
154
191
|
server2.retransmit_count = 3
|
155
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id2].retransmit_count
|
156
|
-
3)
|
192
|
+
assert_equal(3, Cisco::RadiusServer.radiusservers[id2].retransmit_count)
|
157
193
|
|
158
194
|
server2.key_set('44444444', nil)
|
159
|
-
assert_equal(Cisco::RadiusServer.radiusservers[id2].key
|
160
|
-
'44444444')
|
195
|
+
assert_equal('44444444', Cisco::RadiusServer.radiusservers[id2].key)
|
161
196
|
|
162
197
|
# Setting back to default and re-checking
|
163
198
|
server.acct_port = server.default_acct_port
|
@@ -168,14 +203,14 @@ class TestRadiusServer < CiscoTestCase
|
|
168
203
|
server2.auth_port = server2.default_auth_port
|
169
204
|
server2.accounting = server2.default_accounting
|
170
205
|
server2.authentication = server2.default_authentication
|
171
|
-
assert_equal(server.
|
172
|
-
assert_equal(server.
|
173
|
-
assert_equal(server.
|
174
|
-
assert_equal(server.
|
175
|
-
assert_equal(server2.
|
176
|
-
assert_equal(server2.
|
177
|
-
assert_equal(server2.
|
178
|
-
assert_equal(server2.
|
206
|
+
assert_equal(server.default_acct_port, server.acct_port)
|
207
|
+
assert_equal(server.default_auth_port, server.auth_port)
|
208
|
+
assert_equal(server.default_accounting, server.accounting)
|
209
|
+
assert_equal(server.default_authentication, server.authentication)
|
210
|
+
assert_equal(server2.default_acct_port, server2.acct_port)
|
211
|
+
assert_equal(server2.default_auth_port, server2.auth_port)
|
212
|
+
assert_equal(server2.default_accounting, server2.accounting)
|
213
|
+
assert_equal(server2.default_authentication, server2.authentication)
|
179
214
|
|
180
215
|
server.destroy
|
181
216
|
server2.destroy
|