cisco_node_utils 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +3 -0
- data/.rubocop_todo.yml +293 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +4 -0
- data/LICENSE +201 -0
- data/README.md +113 -0
- data/Rakefile +4 -0
- data/cisco_node_utils.gemspec +30 -0
- data/lib/cisco_node_utils.rb +33 -0
- data/lib/cisco_node_utils/README_YAML.md +333 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +92 -0
- data/lib/cisco_node_utils/command_reference.rb +415 -0
- data/lib/cisco_node_utils/command_reference_common.yaml +845 -0
- data/lib/cisco_node_utils/command_reference_n3064.yaml +13 -0
- data/lib/cisco_node_utils/command_reference_n7k.yaml +48 -0
- data/lib/cisco_node_utils/command_reference_n9k.yaml +35 -0
- data/lib/cisco_node_utils/configparser_lib.rb +196 -0
- data/lib/cisco_node_utils/interface.rb +501 -0
- data/lib/cisco_node_utils/interface_ospf.rb +241 -0
- data/lib/cisco_node_utils/node.rb +673 -0
- data/lib/cisco_node_utils/platform.rb +184 -0
- data/lib/cisco_node_utils/platform_info.rb +58 -0
- data/lib/cisco_node_utils/platform_info.yaml +10 -0
- data/lib/cisco_node_utils/router_ospf.rb +96 -0
- data/lib/cisco_node_utils/router_ospf_vrf.rb +258 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +91 -0
- data/lib/cisco_node_utils/snmpgroup.rb +55 -0
- data/lib/cisco_node_utils/snmpserver.rb +150 -0
- data/lib/cisco_node_utils/snmpuser.rb +342 -0
- data/lib/cisco_node_utils/tacacs_server.rb +175 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +128 -0
- data/lib/cisco_node_utils/version.rb +17 -0
- data/lib/cisco_node_utils/vlan.rb +153 -0
- data/lib/cisco_node_utils/vtp.rb +127 -0
- data/lib/cisco_node_utils/yum.rb +84 -0
- data/tests/basetest.rb +93 -0
- data/tests/ciscotest.rb +136 -0
- data/tests/cmd_config.yaml +51 -0
- data/tests/cmd_config_invalid.yaml +16 -0
- data/tests/test_all_cisco.rb +46 -0
- data/tests/test_command_config.rb +192 -0
- data/tests/test_command_reference.rb +222 -0
- data/tests/test_interface.rb +1017 -0
- data/tests/test_interface_ospf.rb +763 -0
- data/tests/test_interface_svi.rb +267 -0
- data/tests/test_interface_switchport.rb +722 -0
- data/tests/test_node.rb +108 -0
- data/tests/test_node_ext.rb +450 -0
- data/tests/test_platform.rb +188 -0
- data/tests/test_router_ospf.rb +164 -0
- data/tests/test_router_ospf_vrf.rb +753 -0
- data/tests/test_snmpcommunity.rb +344 -0
- data/tests/test_snmpgroup.rb +71 -0
- data/tests/test_snmpserver.rb +443 -0
- data/tests/test_snmpuser.rb +803 -0
- data/tests/test_tacacs_server.rb +388 -0
- data/tests/test_tacacs_server_host.rb +391 -0
- data/tests/test_vlan.rb +264 -0
- data/tests/test_vtp.rb +319 -0
- data/tests/test_yum.rb +106 -0
- metadata +188 -0
@@ -0,0 +1,267 @@
|
|
1
|
+
# Copyright (c) 2014-2015 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 File.expand_path("../ciscotest", __FILE__)
|
16
|
+
require File.expand_path("../../lib/cisco_node_utils/interface", __FILE__)
|
17
|
+
|
18
|
+
include Cisco
|
19
|
+
|
20
|
+
class TestSvi < CiscoTestCase
|
21
|
+
def get_cmd_ref_autostate
|
22
|
+
ref = cmd_ref.lookup("interface", "svi_autostate")
|
23
|
+
assert(ref, "Error, reference not found for autostate")
|
24
|
+
ref
|
25
|
+
end
|
26
|
+
|
27
|
+
# Decides whether to check for a raised Exception or an equal value.
|
28
|
+
def assert_result(expected_result, err_msg, &block)
|
29
|
+
if expected_result.is_a? Class
|
30
|
+
assert_raises(expected_result, &block)
|
31
|
+
else
|
32
|
+
value = block.call
|
33
|
+
assert_equal(expected_result, value, err_msg)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_cmd_ref_system_default_svi_autostate(state="")
|
38
|
+
s = @device.cmd("configure terminal")
|
39
|
+
s = @device.cmd("#{state}system default interface-vlan autostate")
|
40
|
+
s = @device.cmd("end")
|
41
|
+
node.cache_flush
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_svi_prop_nil_when_ethernet
|
45
|
+
intf = Interface.new(interfaces[0])
|
46
|
+
assert_nil(intf.svi_autostate,
|
47
|
+
"Error: svi_autostate should be nil when interface is ethernet")
|
48
|
+
assert_nil(intf.svi_management,
|
49
|
+
"Error: svi_management should be nil when interface is ethernet")
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_svi_create_valid
|
53
|
+
svi = Interface.new('Vlan23')
|
54
|
+
s = @device.cmd("show run interface all | inc Vlan")
|
55
|
+
cmd="interface Vlan1"
|
56
|
+
assert(s.include?(cmd), "Error: Failed to create svi Vlan1")
|
57
|
+
|
58
|
+
cmd="interface Vlan23"
|
59
|
+
assert(s.include?(cmd), "Error: Failed to create svi Vlan23")
|
60
|
+
svi.destroy
|
61
|
+
|
62
|
+
# Verify that svi23 got removed now that we invoked svi.destroy
|
63
|
+
s = @device.cmd("show run interface all | inc Vlan")
|
64
|
+
cmd="interface Vlan23"
|
65
|
+
refute(s.include?(cmd), "Error: svi Vlan23 still configured")
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_svi_create_vlan_invalid
|
69
|
+
assert_raises(CliError) do
|
70
|
+
svi = Interface.new('10.1.1.1')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_svi_create_vlan_invalid_value
|
75
|
+
assert_raises(CliError) do
|
76
|
+
svi = Interface.new('Vlan0')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_svi_create_vlan_nil
|
81
|
+
assert_raises(TypeError) do
|
82
|
+
svi = Interface.new(nil)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_svi_name
|
87
|
+
svi = Interface.new('Vlan23')
|
88
|
+
assert_equal("vlan23", svi.name, "Error: svi vlan name is wrong")
|
89
|
+
svi.destroy
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_svi_assignment
|
93
|
+
svi = Interface.new('Vlan23')
|
94
|
+
svi.svi_management = true
|
95
|
+
assert(svi.svi_management, "Error: svi svi_management, false")
|
96
|
+
svi_extra = svi
|
97
|
+
assert(svi_extra.svi_management, "Error: new svi svi_management, false")
|
98
|
+
svi.destroy
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_svi_get_autostate_false
|
102
|
+
svi = Interface.new('Vlan23')
|
103
|
+
|
104
|
+
s = @device.cmd("configure terminal")
|
105
|
+
s = @device.cmd("interface vlan 23")
|
106
|
+
s = @device.cmd("no autostate")
|
107
|
+
s = @device.cmd("end")
|
108
|
+
# Flush the cache since we've modified the device
|
109
|
+
node.cache_flush()
|
110
|
+
ref = get_cmd_ref_autostate
|
111
|
+
result = ref.default_value
|
112
|
+
result = false if ref.config_set
|
113
|
+
assert_equal(result, svi.svi_autostate,
|
114
|
+
"Error: svi autostate not correct.")
|
115
|
+
svi.destroy
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_svi_get_autostate_true
|
119
|
+
svi = Interface.new('Vlan23')
|
120
|
+
|
121
|
+
s = @device.cmd("configure terminal")
|
122
|
+
s = @device.cmd("interface vlan 23")
|
123
|
+
s = @device.cmd("autostate")
|
124
|
+
s = @device.cmd("end")
|
125
|
+
# Flush the cache since we've modified the device
|
126
|
+
node.cache_flush()
|
127
|
+
|
128
|
+
ref = get_cmd_ref_autostate
|
129
|
+
result = ref.default_value
|
130
|
+
result = true if ref.config_set
|
131
|
+
assert_equal(result, svi.svi_autostate,
|
132
|
+
"Error: svi autostate not correct.")
|
133
|
+
svi.destroy
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_svi_set_autostate_false
|
137
|
+
ref = get_cmd_ref_autostate
|
138
|
+
svi = Interface.new('Vlan23')
|
139
|
+
assert_result(ref.test_config_result(false),
|
140
|
+
"Error: svi autostate not set to false") {
|
141
|
+
svi.svi_autostate = false
|
142
|
+
}
|
143
|
+
svi.destroy
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_svi_set_autostate_true
|
147
|
+
svi = Interface.new('Vlan23')
|
148
|
+
ref = get_cmd_ref_autostate
|
149
|
+
assert_result(ref.test_config_result(true),
|
150
|
+
"Error: svi autostate not set to true") {
|
151
|
+
svi.svi_autostate = true
|
152
|
+
}
|
153
|
+
svi.destroy
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_svi_set_autostate_default
|
157
|
+
svi = Interface.new('Vlan23')
|
158
|
+
ref = get_cmd_ref_autostate
|
159
|
+
default_value = ref.default_value
|
160
|
+
assert_result(ref.test_config_result(default_value),
|
161
|
+
"Error: svi autostate not set to default") {
|
162
|
+
svi.svi_autostate = default_value
|
163
|
+
}
|
164
|
+
svi.destroy
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_svi_get_management_true
|
168
|
+
svi = Interface.new('Vlan23')
|
169
|
+
|
170
|
+
s = @device.cmd("configure terminal")
|
171
|
+
s = @device.cmd("interface vlan 23")
|
172
|
+
s = @device.cmd("management")
|
173
|
+
s = @device.cmd("end")
|
174
|
+
# Flush the cache since we've modified the device
|
175
|
+
node.cache_flush()
|
176
|
+
|
177
|
+
assert(svi.svi_management)
|
178
|
+
svi.destroy
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_svi_set_management_false
|
182
|
+
svi = Interface.new('Vlan23')
|
183
|
+
svi.svi_management = false
|
184
|
+
refute(svi.svi_management)
|
185
|
+
svi.destroy
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_svi_set_management_true
|
189
|
+
svi = Interface.new('Vlan23')
|
190
|
+
svi.svi_management = true
|
191
|
+
assert(svi.svi_management)
|
192
|
+
svi.destroy
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_svi_set_management_default
|
196
|
+
svi = Interface.new('Vlan23')
|
197
|
+
svi.svi_management = true
|
198
|
+
assert(svi.svi_management)
|
199
|
+
|
200
|
+
svi.svi_management = svi.default_svi_management
|
201
|
+
assert_equal(svi.default_svi_management, svi.svi_management)
|
202
|
+
svi.destroy
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_svi_get_svis
|
206
|
+
count = 5
|
207
|
+
|
208
|
+
ref = get_cmd_ref_autostate
|
209
|
+
# Have to account for interface Vlan1 why we add 1 to count
|
210
|
+
(2..count + 1).each do |i|
|
211
|
+
str = "Vlan" + i.to_s
|
212
|
+
svi = Interface.new(str)
|
213
|
+
assert_result(ref.test_config_result(false),
|
214
|
+
"Error: svi autostate not set to false") {
|
215
|
+
svi.svi_autostate = false
|
216
|
+
}
|
217
|
+
svi.svi_management = true
|
218
|
+
end
|
219
|
+
|
220
|
+
svis = Interface.interfaces
|
221
|
+
ref = get_cmd_ref_autostate
|
222
|
+
result = ref.default_value
|
223
|
+
svis.each do |id, svi|
|
224
|
+
case id
|
225
|
+
when /^vlan1$/
|
226
|
+
result = true if ref.config_set
|
227
|
+
assert_equal(result, svi.svi_autostate,
|
228
|
+
"Error: svis collection, Vlan1, incorrect autostate")
|
229
|
+
refute(svi.svi_management,
|
230
|
+
"Error: svis collection, Vlan1, incorrect management")
|
231
|
+
when /^vlan/
|
232
|
+
result = false if ref.config_set
|
233
|
+
assert_equal(result, svi.svi_autostate,
|
234
|
+
"Error: svis collection, Vlan#{id}, incorrect autostate")
|
235
|
+
assert(svi.svi_management,
|
236
|
+
"Error: svis collection, Vlan#{id}, incorrect management")
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
svis.each do |id, svi|
|
241
|
+
s = @device.cmd("conf t ; no interface #{id} ; end") if id[/^vlan/]
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_svi_create_interface_description
|
246
|
+
svi = Interface.new('Vlan23')
|
247
|
+
|
248
|
+
description = "Test description"
|
249
|
+
svi.description = description
|
250
|
+
assert_equal(description, svi.description,
|
251
|
+
"Error: Description not configured")
|
252
|
+
svi.destroy
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_system_default_svi_autostate_on_off
|
256
|
+
interface = Interface.new("Eth1/1")
|
257
|
+
|
258
|
+
set_cmd_ref_system_default_svi_autostate("no ")
|
259
|
+
refute(interface.system_default_svi_autostate,
|
260
|
+
"Test for disabled - failed")
|
261
|
+
|
262
|
+
# common default is enabled
|
263
|
+
set_cmd_ref_system_default_svi_autostate("")
|
264
|
+
assert(interface.system_default_svi_autostate,
|
265
|
+
"Test for enabled - failed")
|
266
|
+
end
|
267
|
+
end
|
@@ -0,0 +1,722 @@
|
|
1
|
+
# Copyright (c) 2014-2015 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 File.expand_path("../ciscotest", __FILE__)
|
16
|
+
require File.expand_path("../../lib/cisco_node_utils/interface", __FILE__)
|
17
|
+
require File.expand_path("../../lib/cisco_node_utils/vtp", __FILE__)
|
18
|
+
|
19
|
+
include Cisco
|
20
|
+
|
21
|
+
class TestInterfaceSwitchport < CiscoTestCase
|
22
|
+
def interface_ethernet_default(ethernet_id)
|
23
|
+
s = @device.cmd("configure terminal")
|
24
|
+
s = @device.cmd("no feature vtp")
|
25
|
+
s = @device.cmd("no feature interface-vlan")
|
26
|
+
|
27
|
+
s = @device.cmd("default interface ethernet #{ethernet_id}")
|
28
|
+
s = @device.cmd("end")
|
29
|
+
node.cache_flush
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_cmd_ref_switchport_autostate_exclude
|
33
|
+
ref = cmd_ref.lookup("interface",
|
34
|
+
"switchport_autostate_exclude")
|
35
|
+
assert(ref, "Error, reference not found for switchport_autostate_exclude")
|
36
|
+
ref
|
37
|
+
end
|
38
|
+
|
39
|
+
# Decides whether to check for a raised Exception or an equal value.
|
40
|
+
def assert_result(expected_result, err_msg, &block)
|
41
|
+
if expected_result.is_a? Class
|
42
|
+
assert_raises(expected_result, &block)
|
43
|
+
else
|
44
|
+
value = block.call
|
45
|
+
assert_equal(expected_result, value, err_msg)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_cmd_ref_system_default_switchport(state="")
|
50
|
+
s = @device.cmd("configure terminal")
|
51
|
+
s = @device.cmd("#{state} system default switchport")
|
52
|
+
s = @device.cmd("end")
|
53
|
+
node.cache_flush
|
54
|
+
end
|
55
|
+
|
56
|
+
def set_cmd_ref_system_default_switchport_shutdown(state="")
|
57
|
+
s = @device.cmd("configure terminal")
|
58
|
+
s = @device.cmd("#{state} system default switchport shutdown")
|
59
|
+
s = @device.cmd("end")
|
60
|
+
node.cache_flush
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_switchport_vtp_disabled_feature_enabled
|
64
|
+
vtp = Vtp.new(true)
|
65
|
+
interface = Interface.new(interfaces[0])
|
66
|
+
refute(interface.switchport_vtp,
|
67
|
+
"Error: interface, access, vtp not disabled")
|
68
|
+
vtp.destroy
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_switchport_vtp_disabled_feature_disabled_eth1_1
|
72
|
+
interface = Interface.new(interfaces[0])
|
73
|
+
refute(interface.switchport_vtp,
|
74
|
+
"Error: interface, access, vtp not disabled")
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_switchport_vtp_disabled_feature_disabled_mgmt0
|
78
|
+
interface = Interface.new("mgmt0")
|
79
|
+
refute(interface.switchport_vtp,
|
80
|
+
"Error: interface, access, vtp not disabled")
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_switchport_vtp_disabled_unsupported_mode_disabled
|
84
|
+
interface = Interface.new(interfaces[0])
|
85
|
+
interface.switchport_mode = :disabled
|
86
|
+
refute(interface.switchport_vtp,
|
87
|
+
"Error: interface, access, vtp not disabled")
|
88
|
+
interface_ethernet_default(interfaces_id[0])
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_switchport_vtp_disabled_unsupported_mode_fex
|
92
|
+
begin
|
93
|
+
interface = Interface.new(interfaces[0])
|
94
|
+
interface.switchport_mode = :fex_fabric
|
95
|
+
refute(interface.switchport_vtp,
|
96
|
+
"Error: interface, access, vtp not disabled")
|
97
|
+
rescue RuntimeError => e
|
98
|
+
msg = "[#{interfaces[0]}] switchport_mode is not supported on this interface"
|
99
|
+
assert_equal(msg.downcase, e.message)
|
100
|
+
end
|
101
|
+
interface_ethernet_default(interfaces_id[0])
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_switchport_vtp_enabled_access
|
105
|
+
vtp = Vtp.new(true)
|
106
|
+
interface = Interface.new(interfaces[0])
|
107
|
+
interface.switchport_mode = :access
|
108
|
+
s = @device.cmd("configure terminal")
|
109
|
+
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
110
|
+
s = @device.cmd("vtp")
|
111
|
+
s = @device.cmd("end")
|
112
|
+
# Flush the cache since we've modified the device
|
113
|
+
node.cache_flush()
|
114
|
+
|
115
|
+
assert(interface.switchport_vtp,
|
116
|
+
"Error: interface, access, vtp not enabled")
|
117
|
+
vtp.destroy
|
118
|
+
interface_ethernet_default(interfaces_id[0])
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_switchport_vtp_disabled_access
|
122
|
+
vtp = Vtp.new(true)
|
123
|
+
interface = Interface.new(interfaces[0])
|
124
|
+
interface.switchport_mode = :access
|
125
|
+
s = @device.cmd("configure terminal")
|
126
|
+
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
127
|
+
s = @device.cmd("no vtp")
|
128
|
+
s = @device.cmd("end")
|
129
|
+
# Flush the cache since we've modified the device
|
130
|
+
node.cache_flush()
|
131
|
+
|
132
|
+
refute(interface.switchport_vtp,
|
133
|
+
"Error: interface, access, vtp not disabled")
|
134
|
+
vtp.destroy
|
135
|
+
interface_ethernet_default(interfaces_id[0])
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_switchport_vtp_enabled_trunk
|
139
|
+
vtp = Vtp.new(true)
|
140
|
+
interface = Interface.new(interfaces[0])
|
141
|
+
interface.switchport_mode = :trunk
|
142
|
+
s = @device.cmd("configure terminal")
|
143
|
+
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
144
|
+
s = @device.cmd("vtp")
|
145
|
+
s = @device.cmd("end")
|
146
|
+
# Flush the cache since we've modified the device
|
147
|
+
node.cache_flush()
|
148
|
+
|
149
|
+
assert(interface.switchport_vtp,
|
150
|
+
"Error: interface, trunk, vtp not enabled")
|
151
|
+
vtp.destroy
|
152
|
+
interface_ethernet_default(interfaces_id[0])
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_switchport_vtp_disabled_trunk
|
156
|
+
vtp = Vtp.new(true)
|
157
|
+
interface = Interface.new(interfaces[0])
|
158
|
+
|
159
|
+
interface.switchport_mode = :trunk
|
160
|
+
refute(interface.switchport_vtp,
|
161
|
+
"Error: interface, trunk, vtp not disabled")
|
162
|
+
vtp.destroy
|
163
|
+
interface_ethernet_default(interfaces_id[0])
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_set_switchport_vtp_default_access
|
167
|
+
vtp = Vtp.new(true)
|
168
|
+
interface = Interface.new(interfaces[0])
|
169
|
+
interface.switchport_mode = :access
|
170
|
+
|
171
|
+
interface.switchport_vtp = interface.default_switchport_vtp
|
172
|
+
refute(interface.switchport_vtp,
|
173
|
+
"Error:(1) mode :access, vtp should be default (false)")
|
174
|
+
|
175
|
+
interface.switchport_vtp = true
|
176
|
+
assert(interface.switchport_vtp,
|
177
|
+
"Error:(2) mode :access, vtp should be true")
|
178
|
+
|
179
|
+
interface.switchport_vtp = interface.default_switchport_vtp
|
180
|
+
refute(interface.switchport_vtp,
|
181
|
+
"Error:(3) mode :access, vtp should be default (false)")
|
182
|
+
|
183
|
+
vtp.destroy
|
184
|
+
interface_ethernet_default(interfaces_id[0])
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_set_switchport_vtp_default_trunk
|
188
|
+
vtp = Vtp.new(true)
|
189
|
+
interface = Interface.new(interfaces[0])
|
190
|
+
|
191
|
+
interface.switchport_mode = :trunk
|
192
|
+
interface.switchport_vtp = interface.default_switchport_vtp
|
193
|
+
refute(interface.switchport_vtp,
|
194
|
+
"Error:(1) mode :trunk, vtp should be default (false)")
|
195
|
+
|
196
|
+
interface.switchport_vtp = true
|
197
|
+
assert(interface.switchport_vtp,
|
198
|
+
"Error:(2) mode :trunk, vtp should be true")
|
199
|
+
|
200
|
+
interface.switchport_vtp = interface.default_switchport_vtp
|
201
|
+
refute(interface.switchport_vtp,
|
202
|
+
"Error:(3) mode :trunk, vtp should be default (false)")
|
203
|
+
vtp.destroy
|
204
|
+
interface_ethernet_default(interfaces_id[0])
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_set_switchport_vtp_true_access
|
208
|
+
vtp = Vtp.new(true)
|
209
|
+
interface = Interface.new(interfaces[0])
|
210
|
+
|
211
|
+
interface.switchport_mode = :access
|
212
|
+
interface.switchport_vtp = true
|
213
|
+
assert(interface.switchport_vtp,
|
214
|
+
"Error: interface, access, vtp not enabled")
|
215
|
+
vtp.destroy
|
216
|
+
interface_ethernet_default(interfaces_id[0])
|
217
|
+
end
|
218
|
+
|
219
|
+
def test_set_switchport_vtp_true_trunk
|
220
|
+
vtp = Vtp.new(true)
|
221
|
+
interface = Interface.new(interfaces[0])
|
222
|
+
|
223
|
+
interface.switchport_mode = :trunk
|
224
|
+
interface.switchport_vtp = true
|
225
|
+
assert(interface.switchport_vtp,
|
226
|
+
"Error: interface, access, vtp not enabled")
|
227
|
+
vtp.destroy
|
228
|
+
interface_ethernet_default(interfaces_id[0])
|
229
|
+
end
|
230
|
+
|
231
|
+
def test_set_switchport_vtp_true_unsupported_mode_disabled
|
232
|
+
vtp = Vtp.new(true)
|
233
|
+
interface = Interface.new(interfaces[0])
|
234
|
+
|
235
|
+
interface.switchport_mode = :disabled
|
236
|
+
refute(interface.switchport_vtp,
|
237
|
+
"Error: interface, access, vtp is enabled")
|
238
|
+
vtp.destroy
|
239
|
+
interface_ethernet_default(interfaces_id[0])
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_set_switchport_vtp_true_unsupported_mgmt0
|
243
|
+
vtp = Vtp.new(true)
|
244
|
+
interface = Interface.new("mgmt0")
|
245
|
+
|
246
|
+
interface.switchport_vtp = true
|
247
|
+
refute(interface.switchport_vtp,
|
248
|
+
"Error: interface, access, vtp is enabled")
|
249
|
+
vtp.destroy
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_set_switchport_vtp_false_access
|
253
|
+
vtp = Vtp.new(true)
|
254
|
+
interface = Interface.new(interfaces[0])
|
255
|
+
|
256
|
+
interface.switchport_mode = :access
|
257
|
+
interface.switchport_vtp = false
|
258
|
+
refute(interface.switchport_vtp,
|
259
|
+
"Error: interface, access, vtp not disabled")
|
260
|
+
vtp.destroy
|
261
|
+
interface_ethernet_default(interfaces_id[0])
|
262
|
+
end
|
263
|
+
|
264
|
+
def test_set_switchport_vtp_false_trunk
|
265
|
+
vtp = Vtp.new(true)
|
266
|
+
interface = Interface.new(interfaces[0])
|
267
|
+
|
268
|
+
interface.switchport_mode = :trunk
|
269
|
+
interface.switchport_vtp = false
|
270
|
+
refute(interface.switchport_vtp,
|
271
|
+
"Error: interface, access, vtp not disabled")
|
272
|
+
vtp.destroy
|
273
|
+
interface_ethernet_default(interfaces_id[0])
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_set_switchport_vtp_false_unsupported_mode_disabled
|
277
|
+
vtp = Vtp.new(true)
|
278
|
+
interface = Interface.new(interfaces[0])
|
279
|
+
|
280
|
+
interface.switchport_mode = :disabled
|
281
|
+
interface.switchport_vtp = false
|
282
|
+
refute(interface.switchport_vtp,
|
283
|
+
"Error: mode :disabled, vtp should be false")
|
284
|
+
vtp.destroy
|
285
|
+
interface_ethernet_default(interfaces_id[0])
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_switchport_autostate_disabled_feature_enabled
|
289
|
+
svi = Interface.new('Vlan23')
|
290
|
+
interface = Interface.new(interfaces[0])
|
291
|
+
refute(interface.switchport_autostate_exclude,
|
292
|
+
"Error: interface, access, autostate exclude not disabled")
|
293
|
+
svi.destroy
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_switchport_autostate_disabled_feature_disabled_eth1_1
|
297
|
+
interface = Interface.new(interfaces[0])
|
298
|
+
refute(interface.switchport_autostate_exclude,
|
299
|
+
"Error: interface, access, autostate exclude not disabled")
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_switchport_autostate_disabled_feature_disabled_mgmt0
|
303
|
+
interface = Interface.new("mgmt0")
|
304
|
+
refute(interface.switchport_autostate_exclude,
|
305
|
+
"Error: interface, access, autostate exclude not disabled")
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_switchport_autostate_disabled_unsupported_mode
|
309
|
+
interface = Interface.new(interfaces[0])
|
310
|
+
interface.switchport_mode = :disabled
|
311
|
+
refute(interface.switchport_autostate_exclude,
|
312
|
+
"Error: interface, access, autostate exclude not disabled")
|
313
|
+
interface_ethernet_default(interfaces_id[0])
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_switchport_autostate_enabled_access
|
317
|
+
svi = Interface.new('Vlan23')
|
318
|
+
interface = Interface.new(interfaces[0])
|
319
|
+
s = @device.cmd("configure terminal")
|
320
|
+
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
321
|
+
s = @device.cmd("switchport")
|
322
|
+
s = @device.cmd("switchport autostate exclude")
|
323
|
+
s = @device.cmd("end")
|
324
|
+
# Flush the cache since we've modified the device
|
325
|
+
node.cache_flush()
|
326
|
+
|
327
|
+
cmd_ref = get_cmd_ref_switchport_autostate_exclude
|
328
|
+
if cmd_ref.config_set
|
329
|
+
assert(interface.switchport_autostate_exclude,
|
330
|
+
"Error: interface, access, autostate exclude not enabled")
|
331
|
+
elsif
|
332
|
+
assert_equal(interface.default_switchport_autostate_exclude,
|
333
|
+
interface.switchport_autostate_exclude,
|
334
|
+
"Error: interface, access, autostate exclude not disabled")
|
335
|
+
end
|
336
|
+
|
337
|
+
svi.destroy
|
338
|
+
interface_ethernet_default(interfaces_id[0])
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_switchport_autostate_disabled_access
|
342
|
+
svi = Interface.new('Vlan23')
|
343
|
+
interface = Interface.new(interfaces[0])
|
344
|
+
refute(interface.switchport_autostate_exclude,
|
345
|
+
"Error: interface, access, autostate exclude not disabled")
|
346
|
+
svi.destroy
|
347
|
+
end
|
348
|
+
|
349
|
+
def test_switchport_autostate_enabled_trunk
|
350
|
+
svi = Interface.new('Vlan23')
|
351
|
+
interface = Interface.new(interfaces[0])
|
352
|
+
interface.switchport_mode = :trunk
|
353
|
+
s = @device.cmd("configure terminal")
|
354
|
+
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
355
|
+
s = @device.cmd("switchport autostate exclude")
|
356
|
+
s = @device.cmd("end")
|
357
|
+
# Flush the cache since we've modified the device
|
358
|
+
node.cache_flush()
|
359
|
+
|
360
|
+
cmd_ref = get_cmd_ref_switchport_autostate_exclude
|
361
|
+
if cmd_ref.config_set
|
362
|
+
assert(interface.switchport_autostate_exclude,
|
363
|
+
"Error: interface, access, autostate exclude not enabled")
|
364
|
+
elsif
|
365
|
+
assert_equal(interface.default_switchport_autostate_exclude,
|
366
|
+
interface.switchport_autostate_exclude,
|
367
|
+
"Error: interface, access, autostate exclude not disabled")
|
368
|
+
end
|
369
|
+
|
370
|
+
svi.destroy
|
371
|
+
interface_ethernet_default(interfaces_id[0])
|
372
|
+
end
|
373
|
+
|
374
|
+
def test_switchport_autostate_disabled_trunk
|
375
|
+
svi = Interface.new('Vlan23')
|
376
|
+
interface = Interface.new(interfaces[0])
|
377
|
+
interface.switchport_mode = :trunk
|
378
|
+
s = @device.cmd("configure terminal")
|
379
|
+
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
380
|
+
s = @device.cmd("no switchport autostate exclude")
|
381
|
+
s = @device.cmd("end")
|
382
|
+
# Flush the cache since we've modified the device
|
383
|
+
node.cache_flush()
|
384
|
+
|
385
|
+
refute(interface.switchport_autostate_exclude,
|
386
|
+
"Error: interface, access, autostate exclude not disabled")
|
387
|
+
svi.destroy
|
388
|
+
interface_ethernet_default(interfaces_id[0])
|
389
|
+
end
|
390
|
+
|
391
|
+
def test_raise_error_switchport_not_enabled
|
392
|
+
interface = Interface.new(interfaces[0])
|
393
|
+
|
394
|
+
@device.cmd("configure terminal")
|
395
|
+
@device.cmd("interface #{interfaces[0]}")
|
396
|
+
@device.cmd("no switchport")
|
397
|
+
@device.cmd("end")
|
398
|
+
node.cache_flush
|
399
|
+
|
400
|
+
assert_raises(RuntimeError) {
|
401
|
+
interface.switchport_autostate_exclude = true
|
402
|
+
}
|
403
|
+
end
|
404
|
+
|
405
|
+
def test_set_switchport_autostate_default_access
|
406
|
+
svi = Interface.new('Vlan23')
|
407
|
+
interface = Interface.new(interfaces[0])
|
408
|
+
|
409
|
+
# switchport must be enabled to configure autostate
|
410
|
+
@device.cmd("configure terminal")
|
411
|
+
@device.cmd("interface #{interfaces[0]}")
|
412
|
+
@device.cmd("switchport")
|
413
|
+
@device.cmd("end")
|
414
|
+
node.cache_flush
|
415
|
+
|
416
|
+
result = interface.default_switchport_autostate_exclude
|
417
|
+
assert_result(result,
|
418
|
+
"Error: interface, access, autostate exclude not disabled") {
|
419
|
+
interface.switchport_autostate_exclude = result
|
420
|
+
}
|
421
|
+
svi.destroy
|
422
|
+
interface_ethernet_default(interfaces_id[0])
|
423
|
+
end
|
424
|
+
|
425
|
+
def test_set_switchport_autostate_default_trunk
|
426
|
+
svi = Interface.new('Vlan23')
|
427
|
+
interface = Interface.new(interfaces[0])
|
428
|
+
interface.switchport_mode = :trunk
|
429
|
+
|
430
|
+
# switchport must be enabled to configure autostate
|
431
|
+
@device.cmd("configure terminal")
|
432
|
+
@device.cmd("interface #{interfaces[0]}")
|
433
|
+
@device.cmd("switchport")
|
434
|
+
@device.cmd("end")
|
435
|
+
node.cache_flush
|
436
|
+
|
437
|
+
result = false
|
438
|
+
assert_result(result,
|
439
|
+
"Error: interface, access, autostate exclude not disabled") {
|
440
|
+
interface.switchport_autostate_exclude = result
|
441
|
+
}
|
442
|
+
svi.destroy
|
443
|
+
interface_ethernet_default(interfaces_id[0])
|
444
|
+
end
|
445
|
+
|
446
|
+
def test_set_switchport_autostate_true_access
|
447
|
+
svi = Interface.new('Vlan23')
|
448
|
+
interface = Interface.new(interfaces[0])
|
449
|
+
|
450
|
+
# switchport must be enabled to configure autostate
|
451
|
+
@device.cmd("configure terminal")
|
452
|
+
@device.cmd("interface #{interfaces[0]}")
|
453
|
+
@device.cmd("switchport")
|
454
|
+
@device.cmd("end")
|
455
|
+
node.cache_flush
|
456
|
+
|
457
|
+
result = true
|
458
|
+
assert_result(result,
|
459
|
+
"Error: interface, access, autostate exclude not disabled") {
|
460
|
+
interface.switchport_autostate_exclude = result
|
461
|
+
}
|
462
|
+
svi.destroy
|
463
|
+
interface_ethernet_default(interfaces_id[0])
|
464
|
+
end
|
465
|
+
|
466
|
+
def test_set_switchport_autostate_true_trunk
|
467
|
+
svi = Interface.new('Vlan23')
|
468
|
+
interface = Interface.new(interfaces[0])
|
469
|
+
interface.switchport_mode = :trunk
|
470
|
+
|
471
|
+
# switchport must be enabled to configure autostate
|
472
|
+
@device.cmd("configure terminal")
|
473
|
+
@device.cmd("interface #{interfaces[0]}")
|
474
|
+
@device.cmd("switchport")
|
475
|
+
@device.cmd("end")
|
476
|
+
node.cache_flush
|
477
|
+
|
478
|
+
result = true
|
479
|
+
assert_result(result,
|
480
|
+
"Error: interface, access, autostate exclude not disabled") {
|
481
|
+
interface.switchport_autostate_exclude = result
|
482
|
+
}
|
483
|
+
svi.destroy
|
484
|
+
interface_ethernet_default(interfaces_id[0])
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_set_switchport_autostate_true_unsupported_mode_disabled
|
488
|
+
svi = Interface.new('Vlan23')
|
489
|
+
interface = Interface.new(interfaces[0])
|
490
|
+
interface.switchport_mode = :disabled
|
491
|
+
|
492
|
+
assert_raises (RuntimeError) do
|
493
|
+
interface.switchport_autostate_exclude = true
|
494
|
+
end
|
495
|
+
svi.destroy
|
496
|
+
interface_ethernet_default(interfaces_id[0])
|
497
|
+
end
|
498
|
+
|
499
|
+
def test_set_switchport_autostate_true_unsupported_mgmt0
|
500
|
+
svi = Interface.new('Vlan23')
|
501
|
+
interface = Interface.new("mgmt0")
|
502
|
+
assert_raises (RuntimeError) do
|
503
|
+
interface.switchport_autostate_exclude = true
|
504
|
+
end
|
505
|
+
svi.destroy
|
506
|
+
end
|
507
|
+
|
508
|
+
def test_set_switchport_autostate_false_access
|
509
|
+
svi = Interface.new('Vlan23')
|
510
|
+
interface = Interface.new(interfaces[0])
|
511
|
+
|
512
|
+
# switchport must be enabled to configure autostate
|
513
|
+
@device.cmd("configure terminal")
|
514
|
+
@device.cmd("interface #{interfaces[0]}")
|
515
|
+
@device.cmd("switchport")
|
516
|
+
@device.cmd("end")
|
517
|
+
node.cache_flush
|
518
|
+
|
519
|
+
result = false
|
520
|
+
assert_result(result,
|
521
|
+
"Error: interface, access, autostate exclude not disabled") {
|
522
|
+
interface.switchport_autostate_exclude = result
|
523
|
+
}
|
524
|
+
svi.destroy
|
525
|
+
interface_ethernet_default(interfaces_id[0])
|
526
|
+
end
|
527
|
+
|
528
|
+
def test_set_switchport_autostate_false_trunk
|
529
|
+
svi = Interface.new('Vlan23')
|
530
|
+
interface = Interface.new(interfaces[0])
|
531
|
+
interface.switchport_mode = :trunk
|
532
|
+
|
533
|
+
# switchport must be enabled to configure autostate
|
534
|
+
@device.cmd("configure terminal")
|
535
|
+
@device.cmd("interface #{interfaces[0]}")
|
536
|
+
@device.cmd("switchport")
|
537
|
+
@device.cmd("end")
|
538
|
+
node.cache_flush
|
539
|
+
|
540
|
+
result = false
|
541
|
+
assert_result(result,
|
542
|
+
"Error: interface, access, autostate exclude not disabled") {
|
543
|
+
interface.switchport_autostate_exclude = result
|
544
|
+
}
|
545
|
+
svi.destroy
|
546
|
+
interface_ethernet_default(interfaces_id[0])
|
547
|
+
end
|
548
|
+
|
549
|
+
def test_set_switchport_autostate_false_unsupported_mode_disabled
|
550
|
+
svi = Interface.new('Vlan23')
|
551
|
+
interface = Interface.new(interfaces[0])
|
552
|
+
interface.switchport_mode = :disabled
|
553
|
+
|
554
|
+
assert_raises (RuntimeError) do
|
555
|
+
interface.switchport_autostate_exclude = false
|
556
|
+
end
|
557
|
+
svi.destroy
|
558
|
+
interface_ethernet_default(interfaces_id[0])
|
559
|
+
end
|
560
|
+
|
561
|
+
def test_interface_switchport_mode_invalid
|
562
|
+
interface = Interface.new(interfaces[0])
|
563
|
+
assert_raises(ArgumentError) {
|
564
|
+
interface.switchport_mode = :unknown
|
565
|
+
}
|
566
|
+
interface_ethernet_default(interfaces_id[0])
|
567
|
+
end
|
568
|
+
|
569
|
+
def test_interface_switchport_mode_not_supported
|
570
|
+
interface = Interface.new("mgmt0")
|
571
|
+
assert_raises(RuntimeError) {
|
572
|
+
interface.switchport_mode = :access
|
573
|
+
}
|
574
|
+
begin
|
575
|
+
interface.switchport_mode = :access
|
576
|
+
rescue RuntimeError => e
|
577
|
+
msg = "[mgmt0] switchport_mode is not supported on this interface"
|
578
|
+
assert_equal(msg, e.message)
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
def test_interface_switchport_mode_valid
|
583
|
+
switchport_modes = [
|
584
|
+
:unknown,
|
585
|
+
:disabled,
|
586
|
+
:access,
|
587
|
+
:trunk,
|
588
|
+
#:fex_fabric, (fex is tested by test_interface_switchport_mode_valid_fex)
|
589
|
+
:tunnel,
|
590
|
+
]
|
591
|
+
|
592
|
+
interface = Interface.new(interfaces[0])
|
593
|
+
|
594
|
+
switchport_modes.each { | start |
|
595
|
+
switchport_modes.each { | finish |
|
596
|
+
if start != :unknown && finish != :unknown
|
597
|
+
begin
|
598
|
+
# puts "#{start},#{finish}"
|
599
|
+
interface.switchport_mode = start
|
600
|
+
assert_equal(start, interface.switchport_mode,
|
601
|
+
"Error: Switchport mode, #{start}, not as expected")
|
602
|
+
# puts "now finish #{finish}"
|
603
|
+
interface.switchport_mode = finish
|
604
|
+
assert_equal(finish, interface.switchport_mode,
|
605
|
+
"Error: Switchport mode, #{finish}, not as expected")
|
606
|
+
rescue RuntimeError => e
|
607
|
+
msg = "[#{interfaces[0]}] switchport_mode is not supported on this interface"
|
608
|
+
assert_equal(msg.downcase, e.message)
|
609
|
+
end
|
610
|
+
end
|
611
|
+
}
|
612
|
+
}
|
613
|
+
interface_ethernet_default(interfaces_id[0])
|
614
|
+
end
|
615
|
+
|
616
|
+
def test_interface_switchport_mode_valid_fex
|
617
|
+
switchport_modes = [
|
618
|
+
:unknown,
|
619
|
+
:fex_fabric,
|
620
|
+
]
|
621
|
+
|
622
|
+
interface = Interface.new(interfaces[0])
|
623
|
+
switchport_modes.each { | start |
|
624
|
+
switchport_modes.each { | finish |
|
625
|
+
if start != :unknown &&
|
626
|
+
finish != :unknown
|
627
|
+
begin
|
628
|
+
# puts "#{start},#{finish}"
|
629
|
+
interface.switchport_mode = start
|
630
|
+
assert_equal(start, interface.switchport_mode,
|
631
|
+
"Error: Switchport mode, #{start}, not as expected")
|
632
|
+
interface.switchport_mode = finish
|
633
|
+
assert_equal(finish, interface.switchport_mode,
|
634
|
+
"Error: Switchport mode, #{finish}, not as expected")
|
635
|
+
rescue RuntimeError => e
|
636
|
+
msg = "[#{interfaces[0]}] switchport_mode is not supported on this interface"
|
637
|
+
assert_equal(msg.downcase, e.message)
|
638
|
+
end
|
639
|
+
end
|
640
|
+
}
|
641
|
+
}
|
642
|
+
interface_ethernet_default(interfaces_id[0])
|
643
|
+
end
|
644
|
+
|
645
|
+
=begin
|
646
|
+
# Run this test at your peril as it can cause timeouts for this test and
|
647
|
+
# others - 'no feature-set fex' states:
|
648
|
+
# "Feature-set Operation may take up to 30 minutes depending on the size of configuration."
|
649
|
+
|
650
|
+
def test_interface_switchport_fex_feature
|
651
|
+
test_matrix = {
|
652
|
+
# [ <set_state>, <expected> ]
|
653
|
+
1 => [:uninstalled, :uninstalled], # noop
|
654
|
+
2 => [:installed, :installed],
|
655
|
+
3 => [:uninstalled, :uninstalled],
|
656
|
+
4 => [:enabled, :enabled],
|
657
|
+
5 => [:enabled, :enabled], # noop
|
658
|
+
6 => [:installed, :enabled], # noop
|
659
|
+
7 => [:uninstalled, :uninstalled],
|
660
|
+
8 => [:disabled, :uninstalled], # noop
|
661
|
+
9 => [:installed, :installed],
|
662
|
+
10 => [:installed, :installed], # noop
|
663
|
+
11 => [:enabled, :enabled],
|
664
|
+
12 => [:disabled, :disabled],
|
665
|
+
13 => [:uninstalled, :uninstalled],
|
666
|
+
14 => [:installed, :installed],
|
667
|
+
15 => [:disabled, :installed], # noop
|
668
|
+
16 => [:uninstalled, :uninstalled],
|
669
|
+
}
|
670
|
+
interface = Interface.new(interfaces[0])
|
671
|
+
# start test from :uninstalled state
|
672
|
+
interface.fex_feature_set(:uninstalled)
|
673
|
+
from = interface.fex_feature
|
674
|
+
test_matrix.each { |id,test|
|
675
|
+
#puts "Test #{id}: #{test}, (from: #{from}"
|
676
|
+
set_state, expected = test
|
677
|
+
interface.fex_feature_set(set_state)
|
678
|
+
curr = interface.fex_feature
|
679
|
+
assert_equal(expected, curr,
|
680
|
+
"Error: fex test #{id}: from #{from} to #{set_state}")
|
681
|
+
from = curr
|
682
|
+
}
|
683
|
+
end
|
684
|
+
=end
|
685
|
+
|
686
|
+
def test_system_default_switchport_on_off
|
687
|
+
interface = Interface.new("Eth1/1")
|
688
|
+
|
689
|
+
set_cmd_ref_system_default_switchport("")
|
690
|
+
assert(interface.system_default_switchport,
|
691
|
+
"Test for enabled - failed")
|
692
|
+
|
693
|
+
# common default is "no switch"
|
694
|
+
set_cmd_ref_system_default_switchport("no ")
|
695
|
+
refute(interface.system_default_switchport,
|
696
|
+
"Test for disabled - failed")
|
697
|
+
end
|
698
|
+
|
699
|
+
def test_system_default_switchport_shutdown_on_off
|
700
|
+
interface = Interface.new("Eth1/1")
|
701
|
+
|
702
|
+
set_cmd_ref_system_default_switchport_shutdown("no ")
|
703
|
+
refute(interface.system_default_switchport_shutdown,
|
704
|
+
"Test for disabled - failed")
|
705
|
+
|
706
|
+
# common default is "shutdown"
|
707
|
+
set_cmd_ref_system_default_switchport_shutdown("")
|
708
|
+
assert(interface.system_default_switchport_shutdown,
|
709
|
+
"Test for enabled - failed")
|
710
|
+
end
|
711
|
+
|
712
|
+
def test_interface_svi_command_on_non_vlan
|
713
|
+
interface = Interface.new(interfaces[0])
|
714
|
+
assert_raises(RuntimeError) {
|
715
|
+
interface.svi_autostate = true
|
716
|
+
}
|
717
|
+
assert_raises(RuntimeError) {
|
718
|
+
interface.svi_management = true
|
719
|
+
}
|
720
|
+
interface_ethernet_default(interfaces_id[0])
|
721
|
+
end
|
722
|
+
end
|