cisco_node_utils 1.0.1 → 1.1.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 +4 -0
- data/.rubocop.yml +81 -1
- data/.travis.yml +9 -0
- data/CHANGELOG.md +72 -6
- data/CONTRIBUTING.md +32 -7
- data/README.md +70 -7
- data/Rakefile +17 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +81 -0
- data/bin/git/hooks/hook_lib +108 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/rubocop +20 -0
- data/bin/git/hooks/pre-commit/validate-diffs +31 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +65 -0
- data/cisco_node_utils.gemspec +9 -3
- data/docs/README-develop-best-practices.md +404 -0
- data/docs/README-develop-node-utils-APIs.md +215 -365
- data/docs/README-maintainers.md +33 -3
- data/docs/template-router.rb +89 -91
- data/docs/template-test_router.rb +52 -55
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils.rb +2 -19
- data/lib/cisco_node_utils/README_YAML.md +1 -9
- data/lib/cisco_node_utils/bgp.rb +664 -0
- data/lib/cisco_node_utils/bgp_af.rb +530 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +425 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +709 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +59 -25
- data/lib/cisco_node_utils/command_reference.rb +72 -74
- data/lib/cisco_node_utils/command_reference_common.yaml +174 -9
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +535 -0
- data/lib/cisco_node_utils/command_reference_n7k.yaml +4 -0
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -9
- data/lib/cisco_node_utils/configparser_lib.rb +152 -147
- data/lib/cisco_node_utils/dns_domain.rb +79 -0
- data/lib/cisco_node_utils/domain_name.rb +71 -0
- data/lib/cisco_node_utils/interface.rb +167 -161
- data/lib/cisco_node_utils/interface_ospf.rb +78 -81
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +154 -198
- data/lib/cisco_node_utils/node_util.rb +61 -0
- data/lib/cisco_node_utils/ntp_config.rb +65 -0
- data/lib/cisco_node_utils/ntp_server.rb +76 -0
- data/lib/cisco_node_utils/platform.rb +174 -165
- data/lib/cisco_node_utils/radius_global.rb +146 -0
- data/lib/cisco_node_utils/radius_server.rb +295 -0
- data/lib/cisco_node_utils/router_ospf.rb +59 -63
- data/lib/cisco_node_utils/router_ospf_vrf.rb +226 -210
- data/lib/cisco_node_utils/snmpcommunity.rb +52 -58
- data/lib/cisco_node_utils/snmpgroup.rb +22 -23
- data/lib/cisco_node_utils/snmpserver.rb +99 -103
- data/lib/cisco_node_utils/snmpuser.rb +294 -274
- data/lib/cisco_node_utils/syslog_server.rb +92 -0
- data/lib/cisco_node_utils/syslog_settings.rb +69 -0
- data/lib/cisco_node_utils/tacacs_server.rb +137 -133
- data/lib/cisco_node_utils/tacacs_server_host.rb +84 -87
- data/lib/cisco_node_utils/version.rb +2 -1
- data/lib/cisco_node_utils/vlan.rb +28 -31
- data/lib/cisco_node_utils/vrf.rb +80 -0
- data/lib/cisco_node_utils/vtp.rb +100 -97
- data/lib/cisco_node_utils/yum.rb +15 -17
- data/tests/.rubocop.yml +15 -0
- data/tests/basetest.rb +81 -36
- data/tests/ciscotest.rb +38 -78
- data/{lib/cisco_node_utils → tests}/platform_info.rb +12 -8
- data/{lib/cisco_node_utils → tests}/platform_info.yaml +1 -1
- data/tests/test_bgp_af.rb +920 -0
- data/tests/test_bgp_neighbor.rb +403 -0
- data/tests/test_bgp_neighbor_af.rb +589 -0
- data/tests/test_command_config.rb +65 -62
- data/tests/test_command_reference.rb +31 -45
- data/tests/test_dns_domain.rb +113 -0
- data/tests/test_domain_name.rb +86 -0
- data/tests/test_interface.rb +424 -548
- data/tests/test_interface_ospf.rb +248 -432
- data/tests/test_interface_svi.rb +56 -79
- data/tests/test_interface_switchport.rb +196 -272
- data/tests/test_name_server.rb +85 -0
- data/tests/test_node.rb +7 -6
- data/tests/test_node_ext.rb +133 -186
- data/tests/test_ntp_config.rb +49 -0
- data/tests/test_ntp_server.rb +74 -0
- data/tests/test_platform.rb +58 -37
- data/tests/test_radius_global.rb +78 -0
- data/tests/test_radius_server.rb +185 -0
- data/tests/test_router_bgp.rb +838 -0
- data/tests/test_router_ospf.rb +49 -80
- data/tests/test_router_ospf_vrf.rb +274 -392
- data/tests/test_snmpcommunity.rb +128 -172
- data/tests/test_snmpgroup.rb +12 -14
- data/tests/test_snmpserver.rb +160 -189
- data/tests/test_snmpuser.rb +568 -717
- data/tests/test_syslog_server.rb +88 -0
- data/tests/test_syslog_settings.rb +54 -0
- data/tests/test_tacacs_server.rb +113 -148
- data/tests/test_tacacs_server_host.rb +108 -161
- data/tests/test_vlan.rb +63 -79
- data/tests/test_vrf.rb +92 -0
- data/tests/test_vtp.rb +108 -126
- data/tests/test_yum.rb +47 -41
- metadata +92 -56
- data/.rubocop_todo.yml +0 -293
- data/docs/.rubocop.yml +0 -13
- data/docs/template-feature.rb +0 -45
- data/docs/template-test_feature.rb +0 -51
- data/tests/test_all_cisco.rb +0 -46
data/tests/test_interface_svi.rb
CHANGED
|
@@ -12,15 +12,16 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/interface'
|
|
17
17
|
|
|
18
18
|
include Cisco
|
|
19
19
|
|
|
20
|
+
# TestSvi - Minitest for Interface configuration of SVI interfaces.
|
|
20
21
|
class TestSvi < CiscoTestCase
|
|
21
|
-
def
|
|
22
|
-
ref = cmd_ref.lookup(
|
|
23
|
-
assert(ref,
|
|
22
|
+
def cmd_ref_autostate
|
|
23
|
+
ref = cmd_ref.lookup('interface', 'svi_autostate')
|
|
24
|
+
assert(ref, 'Error, reference not found for autostate')
|
|
24
25
|
ref
|
|
25
26
|
end
|
|
26
27
|
|
|
@@ -34,145 +35,121 @@ class TestSvi < CiscoTestCase
|
|
|
34
35
|
end
|
|
35
36
|
end
|
|
36
37
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
s = @device.cmd("#{state}system default interface-vlan autostate")
|
|
40
|
-
s = @device.cmd("end")
|
|
41
|
-
node.cache_flush
|
|
38
|
+
def system_default_svi_autostate(state='')
|
|
39
|
+
config("#{state}system default interface-vlan autostate")
|
|
42
40
|
end
|
|
43
41
|
|
|
44
42
|
def test_svi_prop_nil_when_ethernet
|
|
45
43
|
intf = Interface.new(interfaces[0])
|
|
46
44
|
assert_nil(intf.svi_autostate,
|
|
47
|
-
|
|
45
|
+
'Error: svi_autostate should be nil when interface is ethernet')
|
|
48
46
|
assert_nil(intf.svi_management,
|
|
49
|
-
|
|
47
|
+
'Error: svi_management should be nil when interface is ethernet')
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
def test_svi_create_valid
|
|
53
51
|
svi = Interface.new('Vlan23')
|
|
54
|
-
s = @device.cmd(
|
|
55
|
-
cmd=
|
|
56
|
-
assert(s.include?(cmd),
|
|
52
|
+
s = @device.cmd('show run interface all | inc Vlan')
|
|
53
|
+
cmd = 'interface Vlan1'
|
|
54
|
+
assert(s.include?(cmd), 'Error: Failed to create svi Vlan1')
|
|
57
55
|
|
|
58
|
-
cmd=
|
|
59
|
-
assert(s.include?(cmd),
|
|
56
|
+
cmd = 'interface Vlan23'
|
|
57
|
+
assert(s.include?(cmd), 'Error: Failed to create svi Vlan23')
|
|
60
58
|
svi.destroy
|
|
61
59
|
|
|
62
60
|
# Verify that svi23 got removed now that we invoked svi.destroy
|
|
63
|
-
s = @device.cmd(
|
|
64
|
-
cmd=
|
|
65
|
-
refute(s.include?(cmd),
|
|
61
|
+
s = @device.cmd('show run interface all | inc Vlan')
|
|
62
|
+
cmd = 'interface Vlan23'
|
|
63
|
+
refute(s.include?(cmd), 'Error: svi Vlan23 still configured')
|
|
66
64
|
end
|
|
67
65
|
|
|
68
66
|
def test_svi_create_vlan_invalid
|
|
69
|
-
assert_raises(CliError)
|
|
70
|
-
svi = Interface.new('10.1.1.1')
|
|
71
|
-
end
|
|
67
|
+
assert_raises(CliError) { Interface.new('10.1.1.1') }
|
|
72
68
|
end
|
|
73
69
|
|
|
74
70
|
def test_svi_create_vlan_invalid_value
|
|
75
|
-
assert_raises(CliError)
|
|
76
|
-
svi = Interface.new('Vlan0')
|
|
77
|
-
end
|
|
71
|
+
assert_raises(CliError) { Interface.new('Vlan0') }
|
|
78
72
|
end
|
|
79
73
|
|
|
80
74
|
def test_svi_create_vlan_nil
|
|
81
|
-
assert_raises(TypeError)
|
|
82
|
-
svi = Interface.new(nil)
|
|
83
|
-
end
|
|
75
|
+
assert_raises(TypeError) { Interface.new(nil) }
|
|
84
76
|
end
|
|
85
77
|
|
|
86
78
|
def test_svi_name
|
|
87
79
|
svi = Interface.new('Vlan23')
|
|
88
|
-
assert_equal(
|
|
80
|
+
assert_equal('vlan23', svi.name, 'Error: svi vlan name is wrong')
|
|
89
81
|
svi.destroy
|
|
90
82
|
end
|
|
91
83
|
|
|
92
84
|
def test_svi_assignment
|
|
93
85
|
svi = Interface.new('Vlan23')
|
|
94
86
|
svi.svi_management = true
|
|
95
|
-
assert(svi.svi_management,
|
|
87
|
+
assert(svi.svi_management, 'Error: svi svi_management, false')
|
|
96
88
|
svi_extra = svi
|
|
97
|
-
assert(svi_extra.svi_management,
|
|
89
|
+
assert(svi_extra.svi_management, 'Error: new svi svi_management, false')
|
|
98
90
|
svi.destroy
|
|
99
91
|
end
|
|
100
92
|
|
|
101
93
|
def test_svi_get_autostate_false
|
|
102
94
|
svi = Interface.new('Vlan23')
|
|
103
95
|
|
|
104
|
-
|
|
105
|
-
|
|
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
|
|
96
|
+
config('interface vlan 23', 'no autostate')
|
|
97
|
+
ref = cmd_ref_autostate
|
|
111
98
|
result = ref.default_value
|
|
112
99
|
result = false if ref.config_set
|
|
113
100
|
assert_equal(result, svi.svi_autostate,
|
|
114
|
-
|
|
101
|
+
'Error: svi autostate not correct.')
|
|
115
102
|
svi.destroy
|
|
116
103
|
end
|
|
117
104
|
|
|
118
105
|
def test_svi_get_autostate_true
|
|
119
106
|
svi = Interface.new('Vlan23')
|
|
120
107
|
|
|
121
|
-
|
|
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()
|
|
108
|
+
config('interface vlan 23', 'autostate')
|
|
127
109
|
|
|
128
|
-
ref =
|
|
110
|
+
ref = cmd_ref_autostate
|
|
129
111
|
result = ref.default_value
|
|
130
112
|
result = true if ref.config_set
|
|
131
113
|
assert_equal(result, svi.svi_autostate,
|
|
132
|
-
|
|
114
|
+
'Error: svi autostate not correct.')
|
|
133
115
|
svi.destroy
|
|
134
116
|
end
|
|
135
117
|
|
|
136
118
|
def test_svi_set_autostate_false
|
|
137
|
-
ref =
|
|
119
|
+
ref = cmd_ref_autostate
|
|
138
120
|
svi = Interface.new('Vlan23')
|
|
139
121
|
assert_result(ref.test_config_result(false),
|
|
140
|
-
|
|
122
|
+
'Error: svi autostate not set to false') do
|
|
141
123
|
svi.svi_autostate = false
|
|
142
|
-
|
|
124
|
+
end
|
|
143
125
|
svi.destroy
|
|
144
126
|
end
|
|
145
127
|
|
|
146
128
|
def test_svi_set_autostate_true
|
|
147
129
|
svi = Interface.new('Vlan23')
|
|
148
|
-
ref =
|
|
130
|
+
ref = cmd_ref_autostate
|
|
149
131
|
assert_result(ref.test_config_result(true),
|
|
150
|
-
|
|
132
|
+
'Error: svi autostate not set to true') do
|
|
151
133
|
svi.svi_autostate = true
|
|
152
|
-
|
|
134
|
+
end
|
|
153
135
|
svi.destroy
|
|
154
136
|
end
|
|
155
137
|
|
|
156
138
|
def test_svi_set_autostate_default
|
|
157
139
|
svi = Interface.new('Vlan23')
|
|
158
|
-
ref =
|
|
140
|
+
ref = cmd_ref_autostate
|
|
159
141
|
default_value = ref.default_value
|
|
160
142
|
assert_result(ref.test_config_result(default_value),
|
|
161
|
-
|
|
143
|
+
'Error: svi autostate not set to default') do
|
|
162
144
|
svi.svi_autostate = default_value
|
|
163
|
-
|
|
145
|
+
end
|
|
164
146
|
svi.destroy
|
|
165
147
|
end
|
|
166
148
|
|
|
167
149
|
def test_svi_get_management_true
|
|
168
150
|
svi = Interface.new('Vlan23')
|
|
169
151
|
|
|
170
|
-
|
|
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()
|
|
152
|
+
config('interface vlan 23', 'management')
|
|
176
153
|
|
|
177
154
|
assert(svi.svi_management)
|
|
178
155
|
svi.destroy
|
|
@@ -205,29 +182,29 @@ class TestSvi < CiscoTestCase
|
|
|
205
182
|
def test_svi_get_svis
|
|
206
183
|
count = 5
|
|
207
184
|
|
|
208
|
-
ref =
|
|
185
|
+
ref = cmd_ref_autostate
|
|
209
186
|
# Have to account for interface Vlan1 why we add 1 to count
|
|
210
187
|
(2..count + 1).each do |i|
|
|
211
|
-
str =
|
|
188
|
+
str = 'Vlan' + i.to_s
|
|
212
189
|
svi = Interface.new(str)
|
|
213
190
|
assert_result(ref.test_config_result(false),
|
|
214
|
-
|
|
191
|
+
'Error: svi autostate not set to false') do
|
|
215
192
|
svi.svi_autostate = false
|
|
216
|
-
|
|
193
|
+
end
|
|
217
194
|
svi.svi_management = true
|
|
218
195
|
end
|
|
219
196
|
|
|
220
197
|
svis = Interface.interfaces
|
|
221
|
-
ref =
|
|
198
|
+
ref = cmd_ref_autostate
|
|
222
199
|
result = ref.default_value
|
|
223
200
|
svis.each do |id, svi|
|
|
224
201
|
case id
|
|
225
202
|
when /^vlan1$/
|
|
226
203
|
result = true if ref.config_set
|
|
227
204
|
assert_equal(result, svi.svi_autostate,
|
|
228
|
-
|
|
205
|
+
'Error: svis collection, Vlan1, incorrect autostate')
|
|
229
206
|
refute(svi.svi_management,
|
|
230
|
-
|
|
207
|
+
'Error: svis collection, Vlan1, incorrect management')
|
|
231
208
|
when /^vlan/
|
|
232
209
|
result = false if ref.config_set
|
|
233
210
|
assert_equal(result, svi.svi_autostate,
|
|
@@ -237,31 +214,31 @@ class TestSvi < CiscoTestCase
|
|
|
237
214
|
end
|
|
238
215
|
end
|
|
239
216
|
|
|
240
|
-
svis.
|
|
241
|
-
|
|
217
|
+
svis.each_key do |id|
|
|
218
|
+
config("no interface #{id}") if id[/^vlan/]
|
|
242
219
|
end
|
|
243
220
|
end
|
|
244
221
|
|
|
245
222
|
def test_svi_create_interface_description
|
|
246
223
|
svi = Interface.new('Vlan23')
|
|
247
224
|
|
|
248
|
-
description =
|
|
225
|
+
description = 'Test description'
|
|
249
226
|
svi.description = description
|
|
250
227
|
assert_equal(description, svi.description,
|
|
251
|
-
|
|
228
|
+
'Error: Description not configured')
|
|
252
229
|
svi.destroy
|
|
253
230
|
end
|
|
254
231
|
|
|
255
232
|
def test_system_default_svi_autostate_on_off
|
|
256
|
-
interface = Interface.new(
|
|
233
|
+
interface = Interface.new('Eth1/1')
|
|
257
234
|
|
|
258
|
-
|
|
235
|
+
system_default_svi_autostate('no ')
|
|
259
236
|
refute(interface.system_default_svi_autostate,
|
|
260
|
-
|
|
237
|
+
'Test for disabled - failed')
|
|
261
238
|
|
|
262
239
|
# common default is enabled
|
|
263
|
-
|
|
240
|
+
system_default_svi_autostate('')
|
|
264
241
|
assert(interface.system_default_svi_autostate,
|
|
265
|
-
|
|
242
|
+
'Test for enabled - failed')
|
|
266
243
|
end
|
|
267
244
|
end
|
|
@@ -12,36 +12,30 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/interface'
|
|
17
|
+
require_relative '../lib/cisco_node_utils/vtp'
|
|
18
18
|
|
|
19
19
|
include Cisco
|
|
20
20
|
|
|
21
|
+
# TestInterfaceSwitchport - Minitest for switchport config by Interface class.
|
|
21
22
|
class TestInterfaceSwitchport < CiscoTestCase
|
|
22
|
-
DEFAULT_IF_SWITCHPORT_ALLOWED_VLAN =
|
|
23
|
+
DEFAULT_IF_SWITCHPORT_ALLOWED_VLAN = '1-4094'
|
|
23
24
|
DEFAULT_IF_SWITCHPORT_NATIVE_VLAN = 1
|
|
24
25
|
|
|
25
26
|
def setup
|
|
26
27
|
super
|
|
27
|
-
|
|
28
|
-
s = @device.cmd("no feature vtp")
|
|
29
|
-
s = @device.cmd("no feature interface-vlan")
|
|
30
|
-
s = @device.cmd("end")
|
|
31
|
-
node.cache_flush
|
|
28
|
+
config('no feature vtp', 'no feature interface-vlan')
|
|
32
29
|
end
|
|
33
30
|
|
|
34
31
|
def interface_ethernet_default(ethernet_id)
|
|
35
|
-
|
|
36
|
-
s = @device.cmd("default interface ethernet #{ethernet_id}")
|
|
37
|
-
s = @device.cmd("end")
|
|
38
|
-
node.cache_flush
|
|
32
|
+
config("default interface ethernet #{ethernet_id}")
|
|
39
33
|
end
|
|
40
34
|
|
|
41
|
-
def
|
|
42
|
-
ref = cmd_ref.lookup(
|
|
43
|
-
|
|
44
|
-
assert(ref,
|
|
35
|
+
def cmd_ref_switchport_autostate_exclude
|
|
36
|
+
ref = cmd_ref.lookup('interface',
|
|
37
|
+
'switchport_autostate_exclude')
|
|
38
|
+
assert(ref, 'Error, reference not found for switchport_autostate_exclude')
|
|
45
39
|
ref
|
|
46
40
|
end
|
|
47
41
|
|
|
@@ -55,45 +49,39 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
55
49
|
end
|
|
56
50
|
end
|
|
57
51
|
|
|
58
|
-
def
|
|
59
|
-
|
|
60
|
-
s = @device.cmd("#{state} system default switchport")
|
|
61
|
-
s = @device.cmd("end")
|
|
62
|
-
node.cache_flush
|
|
52
|
+
def system_default_switchport(state='')
|
|
53
|
+
config("#{state} system default switchport")
|
|
63
54
|
end
|
|
64
55
|
|
|
65
|
-
def
|
|
66
|
-
|
|
67
|
-
s = @device.cmd("#{state} system default switchport shutdown")
|
|
68
|
-
s = @device.cmd("end")
|
|
69
|
-
node.cache_flush
|
|
56
|
+
def system_default_switchport_shutdown(state='')
|
|
57
|
+
config("#{state} system default switchport shutdown")
|
|
70
58
|
end
|
|
71
59
|
|
|
72
60
|
def test_switchport_vtp_disabled_feature_enabled
|
|
73
61
|
vtp = Vtp.new(true)
|
|
74
62
|
interface = Interface.new(interfaces[0])
|
|
75
63
|
refute(interface.switchport_vtp,
|
|
76
|
-
|
|
64
|
+
'Error: interface, access, vtp not disabled')
|
|
77
65
|
vtp.destroy
|
|
78
66
|
end
|
|
79
67
|
|
|
80
68
|
def test_switchport_vtp_disabled_feature_disabled_eth1_1
|
|
81
69
|
interface = Interface.new(interfaces[0])
|
|
82
70
|
refute(interface.switchport_vtp,
|
|
83
|
-
|
|
71
|
+
'Error: interface, access, vtp not disabled')
|
|
84
72
|
end
|
|
85
73
|
|
|
86
74
|
def test_switchport_vtp_disabled_feature_disabled_mgmt0
|
|
87
|
-
interface = Interface.new(
|
|
75
|
+
interface = Interface.new('mgmt0')
|
|
88
76
|
refute(interface.switchport_vtp,
|
|
89
|
-
|
|
77
|
+
'Error: interface, access, vtp not disabled')
|
|
90
78
|
end
|
|
91
79
|
|
|
92
80
|
def test_switchport_vtp_disabled_unsupported_mode_disabled
|
|
93
81
|
interface = Interface.new(interfaces[0])
|
|
94
82
|
interface.switchport_mode = :disabled
|
|
95
83
|
refute(interface.switchport_vtp,
|
|
96
|
-
|
|
84
|
+
'Error: interface, access, vtp not disabled')
|
|
97
85
|
interface_ethernet_default(interfaces_id[0])
|
|
98
86
|
end
|
|
99
87
|
|
|
@@ -102,9 +90,10 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
102
90
|
interface = Interface.new(interfaces[0])
|
|
103
91
|
interface.switchport_mode = :fex_fabric
|
|
104
92
|
refute(interface.switchport_vtp,
|
|
105
|
-
|
|
93
|
+
'Error: interface, access, vtp not disabled')
|
|
106
94
|
rescue RuntimeError => e
|
|
107
|
-
msg = "[#{interfaces[0]}] switchport_mode is not supported
|
|
95
|
+
msg = "[#{interfaces[0]}] switchport_mode is not supported " \
|
|
96
|
+
'on this interface'
|
|
108
97
|
assert_equal(msg.downcase, e.message)
|
|
109
98
|
end
|
|
110
99
|
interface_ethernet_default(interfaces_id[0])
|
|
@@ -114,15 +103,10 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
114
103
|
vtp = Vtp.new(true)
|
|
115
104
|
interface = Interface.new(interfaces[0])
|
|
116
105
|
interface.switchport_mode = :access
|
|
117
|
-
|
|
118
|
-
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
|
119
|
-
s = @device.cmd("vtp")
|
|
120
|
-
s = @device.cmd("end")
|
|
121
|
-
# Flush the cache since we've modified the device
|
|
122
|
-
node.cache_flush()
|
|
106
|
+
config("interface ethernet #{interfaces_id[0]}", 'vtp')
|
|
123
107
|
|
|
124
108
|
assert(interface.switchport_vtp,
|
|
125
|
-
|
|
109
|
+
'Error: interface, access, vtp not enabled')
|
|
126
110
|
vtp.destroy
|
|
127
111
|
interface_ethernet_default(interfaces_id[0])
|
|
128
112
|
end
|
|
@@ -131,15 +115,10 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
131
115
|
vtp = Vtp.new(true)
|
|
132
116
|
interface = Interface.new(interfaces[0])
|
|
133
117
|
interface.switchport_mode = :access
|
|
134
|
-
|
|
135
|
-
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
|
136
|
-
s = @device.cmd("no vtp")
|
|
137
|
-
s = @device.cmd("end")
|
|
138
|
-
# Flush the cache since we've modified the device
|
|
139
|
-
node.cache_flush()
|
|
118
|
+
config("interface ethernet #{interfaces_id[0]}", 'no vtp')
|
|
140
119
|
|
|
141
120
|
refute(interface.switchport_vtp,
|
|
142
|
-
|
|
121
|
+
'Error: interface, access, vtp not disabled')
|
|
143
122
|
vtp.destroy
|
|
144
123
|
interface_ethernet_default(interfaces_id[0])
|
|
145
124
|
end
|
|
@@ -148,15 +127,10 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
148
127
|
vtp = Vtp.new(true)
|
|
149
128
|
interface = Interface.new(interfaces[0])
|
|
150
129
|
interface.switchport_mode = :trunk
|
|
151
|
-
|
|
152
|
-
s = @device.cmd("interface ethernet #{interfaces_id[0]}")
|
|
153
|
-
s = @device.cmd("vtp")
|
|
154
|
-
s = @device.cmd("end")
|
|
155
|
-
# Flush the cache since we've modified the device
|
|
156
|
-
node.cache_flush()
|
|
130
|
+
config("interface ethernet #{interfaces_id[0]}", 'vtp')
|
|
157
131
|
|
|
158
132
|
assert(interface.switchport_vtp,
|
|
159
|
-
|
|
133
|
+
'Error: interface, trunk, vtp not enabled')
|
|
160
134
|
vtp.destroy
|
|
161
135
|
interface_ethernet_default(interfaces_id[0])
|
|
162
136
|
end
|
|
@@ -167,7 +141,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
167
141
|
|
|
168
142
|
interface.switchport_mode = :trunk
|
|
169
143
|
refute(interface.switchport_vtp,
|
|
170
|
-
|
|
144
|
+
'Error: interface, trunk, vtp not disabled')
|
|
171
145
|
vtp.destroy
|
|
172
146
|
interface_ethernet_default(interfaces_id[0])
|
|
173
147
|
end
|
|
@@ -179,15 +153,15 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
179
153
|
|
|
180
154
|
interface.switchport_vtp = interface.default_switchport_vtp
|
|
181
155
|
refute(interface.switchport_vtp,
|
|
182
|
-
|
|
156
|
+
'Error:(1) mode :access, vtp should be default (false)')
|
|
183
157
|
|
|
184
158
|
interface.switchport_vtp = true
|
|
185
159
|
assert(interface.switchport_vtp,
|
|
186
|
-
|
|
160
|
+
'Error:(2) mode :access, vtp should be true')
|
|
187
161
|
|
|
188
162
|
interface.switchport_vtp = interface.default_switchport_vtp
|
|
189
163
|
refute(interface.switchport_vtp,
|
|
190
|
-
|
|
164
|
+
'Error:(3) mode :access, vtp should be default (false)')
|
|
191
165
|
|
|
192
166
|
vtp.destroy
|
|
193
167
|
interface_ethernet_default(interfaces_id[0])
|
|
@@ -200,15 +174,15 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
200
174
|
interface.switchport_mode = :trunk
|
|
201
175
|
interface.switchport_vtp = interface.default_switchport_vtp
|
|
202
176
|
refute(interface.switchport_vtp,
|
|
203
|
-
|
|
177
|
+
'Error:(1) mode :trunk, vtp should be default (false)')
|
|
204
178
|
|
|
205
179
|
interface.switchport_vtp = true
|
|
206
180
|
assert(interface.switchport_vtp,
|
|
207
|
-
|
|
181
|
+
'Error:(2) mode :trunk, vtp should be true')
|
|
208
182
|
|
|
209
183
|
interface.switchport_vtp = interface.default_switchport_vtp
|
|
210
184
|
refute(interface.switchport_vtp,
|
|
211
|
-
|
|
185
|
+
'Error:(3) mode :trunk, vtp should be default (false)')
|
|
212
186
|
vtp.destroy
|
|
213
187
|
interface_ethernet_default(interfaces_id[0])
|
|
214
188
|
end
|
|
@@ -220,7 +194,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
220
194
|
interface.switchport_mode = :access
|
|
221
195
|
interface.switchport_vtp = true
|
|
222
196
|
assert(interface.switchport_vtp,
|
|
223
|
-
|
|
197
|
+
'Error: interface, access, vtp not enabled')
|
|
224
198
|
vtp.destroy
|
|
225
199
|
interface_ethernet_default(interfaces_id[0])
|
|
226
200
|
end
|
|
@@ -232,7 +206,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
232
206
|
interface.switchport_mode = :trunk
|
|
233
207
|
interface.switchport_vtp = true
|
|
234
208
|
assert(interface.switchport_vtp,
|
|
235
|
-
|
|
209
|
+
'Error: interface, access, vtp not enabled')
|
|
236
210
|
vtp.destroy
|
|
237
211
|
interface_ethernet_default(interfaces_id[0])
|
|
238
212
|
end
|
|
@@ -243,18 +217,18 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
243
217
|
|
|
244
218
|
interface.switchport_mode = :disabled
|
|
245
219
|
refute(interface.switchport_vtp,
|
|
246
|
-
|
|
220
|
+
'Error: interface, access, vtp is enabled')
|
|
247
221
|
vtp.destroy
|
|
248
222
|
interface_ethernet_default(interfaces_id[0])
|
|
249
223
|
end
|
|
250
224
|
|
|
251
225
|
def test_set_switchport_vtp_true_unsupported_mgmt0
|
|
252
226
|
vtp = Vtp.new(true)
|
|
253
|
-
interface = Interface.new(
|
|
227
|
+
interface = Interface.new('mgmt0')
|
|
254
228
|
|
|
255
229
|
interface.switchport_vtp = true
|
|
256
230
|
refute(interface.switchport_vtp,
|
|
257
|
-
|
|
231
|
+
'Error: interface, access, vtp is enabled')
|
|
258
232
|
vtp.destroy
|
|
259
233
|
end
|
|
260
234
|
|
|
@@ -265,7 +239,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
265
239
|
interface.switchport_mode = :access
|
|
266
240
|
interface.switchport_vtp = false
|
|
267
241
|
refute(interface.switchport_vtp,
|
|
268
|
-
|
|
242
|
+
'Error: interface, access, vtp not disabled')
|
|
269
243
|
vtp.destroy
|
|
270
244
|
interface_ethernet_default(interfaces_id[0])
|
|
271
245
|
end
|
|
@@ -277,7 +251,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
277
251
|
interface.switchport_mode = :trunk
|
|
278
252
|
interface.switchport_vtp = false
|
|
279
253
|
refute(interface.switchport_vtp,
|
|
280
|
-
|
|
254
|
+
'Error: interface, access, vtp not disabled')
|
|
281
255
|
vtp.destroy
|
|
282
256
|
interface_ethernet_default(interfaces_id[0])
|
|
283
257
|
end
|
|
@@ -289,7 +263,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
289
263
|
interface.switchport_mode = :disabled
|
|
290
264
|
interface.switchport_vtp = false
|
|
291
265
|
refute(interface.switchport_vtp,
|
|
292
|
-
|
|
266
|
+
'Error: mode :disabled, vtp should be false')
|
|
293
267
|
vtp.destroy
|
|
294
268
|
interface_ethernet_default(interfaces_id[0])
|
|
295
269
|
end
|
|
@@ -298,49 +272,45 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
298
272
|
svi = Interface.new('Vlan23')
|
|
299
273
|
interface = Interface.new(interfaces[0])
|
|
300
274
|
refute(interface.switchport_autostate_exclude,
|
|
301
|
-
|
|
275
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
302
276
|
svi.destroy
|
|
303
277
|
end
|
|
304
278
|
|
|
305
279
|
def test_switchport_autostate_disabled_feature_disabled_eth1_1
|
|
306
280
|
interface = Interface.new(interfaces[0])
|
|
307
281
|
refute(interface.switchport_autostate_exclude,
|
|
308
|
-
|
|
282
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
309
283
|
end
|
|
310
284
|
|
|
311
285
|
def test_switchport_autostate_disabled_feature_disabled_mgmt0
|
|
312
|
-
interface = Interface.new(
|
|
286
|
+
interface = Interface.new('mgmt0')
|
|
313
287
|
refute(interface.switchport_autostate_exclude,
|
|
314
|
-
|
|
288
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
315
289
|
end
|
|
316
290
|
|
|
317
291
|
def test_switchport_autostate_disabled_unsupported_mode
|
|
318
292
|
interface = Interface.new(interfaces[0])
|
|
319
293
|
interface.switchport_mode = :disabled
|
|
320
294
|
refute(interface.switchport_autostate_exclude,
|
|
321
|
-
|
|
295
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
322
296
|
interface_ethernet_default(interfaces_id[0])
|
|
323
297
|
end
|
|
324
298
|
|
|
325
299
|
def test_switchport_autostate_enabled_access
|
|
326
300
|
svi = Interface.new('Vlan23')
|
|
327
301
|
interface = Interface.new(interfaces[0])
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
s = @device.cmd("switchport autostate exclude")
|
|
332
|
-
s = @device.cmd("end")
|
|
333
|
-
# Flush the cache since we've modified the device
|
|
334
|
-
node.cache_flush()
|
|
302
|
+
config("interface ethernet #{interfaces_id[0]}",
|
|
303
|
+
'switchport',
|
|
304
|
+
'switchport autostate exclude')
|
|
335
305
|
|
|
336
|
-
cmd_ref =
|
|
306
|
+
cmd_ref = cmd_ref_switchport_autostate_exclude
|
|
337
307
|
if cmd_ref.config_set
|
|
338
308
|
assert(interface.switchport_autostate_exclude,
|
|
339
|
-
|
|
340
|
-
|
|
309
|
+
'Error: interface, access, autostate exclude not enabled')
|
|
310
|
+
else
|
|
341
311
|
assert_equal(interface.default_switchport_autostate_exclude,
|
|
342
312
|
interface.switchport_autostate_exclude,
|
|
343
|
-
|
|
313
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
344
314
|
end
|
|
345
315
|
|
|
346
316
|
svi.destroy
|
|
@@ -351,7 +321,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
351
321
|
svi = Interface.new('Vlan23')
|
|
352
322
|
interface = Interface.new(interfaces[0])
|
|
353
323
|
refute(interface.switchport_autostate_exclude,
|
|
354
|
-
|
|
324
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
355
325
|
svi.destroy
|
|
356
326
|
end
|
|
357
327
|
|
|
@@ -359,21 +329,17 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
359
329
|
svi = Interface.new('Vlan23')
|
|
360
330
|
interface = Interface.new(interfaces[0])
|
|
361
331
|
interface.switchport_mode = :trunk
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
# Flush the cache since we've modified the device
|
|
367
|
-
node.cache_flush()
|
|
368
|
-
|
|
369
|
-
cmd_ref = get_cmd_ref_switchport_autostate_exclude
|
|
332
|
+
config("interface ethernet #{interfaces_id[0]}",
|
|
333
|
+
'switchport autostate exclude')
|
|
334
|
+
|
|
335
|
+
cmd_ref = cmd_ref_switchport_autostate_exclude
|
|
370
336
|
if cmd_ref.config_set
|
|
371
337
|
assert(interface.switchport_autostate_exclude,
|
|
372
|
-
|
|
373
|
-
|
|
338
|
+
'Error: interface, access, autostate exclude not enabled')
|
|
339
|
+
else
|
|
374
340
|
assert_equal(interface.default_switchport_autostate_exclude,
|
|
375
341
|
interface.switchport_autostate_exclude,
|
|
376
|
-
|
|
342
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
377
343
|
end
|
|
378
344
|
|
|
379
345
|
svi.destroy
|
|
@@ -384,15 +350,11 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
384
350
|
svi = Interface.new('Vlan23')
|
|
385
351
|
interface = Interface.new(interfaces[0])
|
|
386
352
|
interface.switchport_mode = :trunk
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
s = @device.cmd("no switchport autostate exclude")
|
|
390
|
-
s = @device.cmd("end")
|
|
391
|
-
# Flush the cache since we've modified the device
|
|
392
|
-
node.cache_flush()
|
|
353
|
+
config("interface ethernet #{interfaces_id[0]}",
|
|
354
|
+
'no switchport autostate exclude')
|
|
393
355
|
|
|
394
356
|
refute(interface.switchport_autostate_exclude,
|
|
395
|
-
|
|
357
|
+
'Error: interface, access, autostate exclude not disabled')
|
|
396
358
|
svi.destroy
|
|
397
359
|
interface_ethernet_default(interfaces_id[0])
|
|
398
360
|
end
|
|
@@ -400,15 +362,11 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
400
362
|
def test_raise_error_switchport_not_enabled
|
|
401
363
|
interface = Interface.new(interfaces[0])
|
|
402
364
|
|
|
403
|
-
|
|
404
|
-
@device.cmd("interface #{interfaces[0]}")
|
|
405
|
-
@device.cmd("no switchport")
|
|
406
|
-
@device.cmd("end")
|
|
407
|
-
node.cache_flush
|
|
365
|
+
config("interface #{interfaces[0]}", 'no switchport')
|
|
408
366
|
|
|
409
|
-
assert_raises(RuntimeError)
|
|
367
|
+
assert_raises(RuntimeError) do
|
|
410
368
|
interface.switchport_autostate_exclude = true
|
|
411
|
-
|
|
369
|
+
end
|
|
412
370
|
end
|
|
413
371
|
|
|
414
372
|
def test_set_switchport_autostate_default_access
|
|
@@ -416,17 +374,13 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
416
374
|
interface = Interface.new(interfaces[0])
|
|
417
375
|
|
|
418
376
|
# switchport must be enabled to configure autostate
|
|
419
|
-
|
|
420
|
-
@device.cmd("interface #{interfaces[0]}")
|
|
421
|
-
@device.cmd("switchport")
|
|
422
|
-
@device.cmd("end")
|
|
423
|
-
node.cache_flush
|
|
377
|
+
config("interface #{interfaces[0]}", 'switchport')
|
|
424
378
|
|
|
425
379
|
result = interface.default_switchport_autostate_exclude
|
|
426
380
|
assert_result(result,
|
|
427
|
-
|
|
381
|
+
'Error: interface, access, autostate exclude not disabled') do
|
|
428
382
|
interface.switchport_autostate_exclude = result
|
|
429
|
-
|
|
383
|
+
end
|
|
430
384
|
svi.destroy
|
|
431
385
|
interface_ethernet_default(interfaces_id[0])
|
|
432
386
|
end
|
|
@@ -437,17 +391,13 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
437
391
|
interface.switchport_mode = :trunk
|
|
438
392
|
|
|
439
393
|
# switchport must be enabled to configure autostate
|
|
440
|
-
|
|
441
|
-
@device.cmd("interface #{interfaces[0]}")
|
|
442
|
-
@device.cmd("switchport")
|
|
443
|
-
@device.cmd("end")
|
|
444
|
-
node.cache_flush
|
|
394
|
+
config("interface #{interfaces[0]}", 'switchport')
|
|
445
395
|
|
|
446
396
|
result = false
|
|
447
397
|
assert_result(result,
|
|
448
|
-
|
|
398
|
+
'Error: interface, access, autostate exclude not disabled') do
|
|
449
399
|
interface.switchport_autostate_exclude = result
|
|
450
|
-
|
|
400
|
+
end
|
|
451
401
|
svi.destroy
|
|
452
402
|
interface_ethernet_default(interfaces_id[0])
|
|
453
403
|
end
|
|
@@ -457,17 +407,13 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
457
407
|
interface = Interface.new(interfaces[0])
|
|
458
408
|
|
|
459
409
|
# switchport must be enabled to configure autostate
|
|
460
|
-
|
|
461
|
-
@device.cmd("interface #{interfaces[0]}")
|
|
462
|
-
@device.cmd("switchport")
|
|
463
|
-
@device.cmd("end")
|
|
464
|
-
node.cache_flush
|
|
410
|
+
config("interface #{interfaces[0]}", 'switchport')
|
|
465
411
|
|
|
466
412
|
result = true
|
|
467
413
|
assert_result(result,
|
|
468
|
-
|
|
414
|
+
'Error: interface, access, autostate exclude not disabled') do
|
|
469
415
|
interface.switchport_autostate_exclude = result
|
|
470
|
-
|
|
416
|
+
end
|
|
471
417
|
svi.destroy
|
|
472
418
|
interface_ethernet_default(interfaces_id[0])
|
|
473
419
|
end
|
|
@@ -478,17 +424,13 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
478
424
|
interface.switchport_mode = :trunk
|
|
479
425
|
|
|
480
426
|
# switchport must be enabled to configure autostate
|
|
481
|
-
|
|
482
|
-
@device.cmd("interface #{interfaces[0]}")
|
|
483
|
-
@device.cmd("switchport")
|
|
484
|
-
@device.cmd("end")
|
|
485
|
-
node.cache_flush
|
|
427
|
+
config("interface #{interfaces[0]}", 'switchport')
|
|
486
428
|
|
|
487
429
|
result = true
|
|
488
430
|
assert_result(result,
|
|
489
|
-
|
|
431
|
+
'Error: interface, access, autostate exclude not disabled') do
|
|
490
432
|
interface.switchport_autostate_exclude = result
|
|
491
|
-
|
|
433
|
+
end
|
|
492
434
|
svi.destroy
|
|
493
435
|
interface_ethernet_default(interfaces_id[0])
|
|
494
436
|
end
|
|
@@ -498,7 +440,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
498
440
|
interface = Interface.new(interfaces[0])
|
|
499
441
|
interface.switchport_mode = :disabled
|
|
500
442
|
|
|
501
|
-
assert_raises
|
|
443
|
+
assert_raises RuntimeError do
|
|
502
444
|
interface.switchport_autostate_exclude = true
|
|
503
445
|
end
|
|
504
446
|
svi.destroy
|
|
@@ -507,8 +449,8 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
507
449
|
|
|
508
450
|
def test_set_switchport_autostate_true_unsupported_mgmt0
|
|
509
451
|
svi = Interface.new('Vlan23')
|
|
510
|
-
interface = Interface.new(
|
|
511
|
-
assert_raises
|
|
452
|
+
interface = Interface.new('mgmt0')
|
|
453
|
+
assert_raises RuntimeError do
|
|
512
454
|
interface.switchport_autostate_exclude = true
|
|
513
455
|
end
|
|
514
456
|
svi.destroy
|
|
@@ -519,17 +461,13 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
519
461
|
interface = Interface.new(interfaces[0])
|
|
520
462
|
|
|
521
463
|
# switchport must be enabled to configure autostate
|
|
522
|
-
|
|
523
|
-
@device.cmd("interface #{interfaces[0]}")
|
|
524
|
-
@device.cmd("switchport")
|
|
525
|
-
@device.cmd("end")
|
|
526
|
-
node.cache_flush
|
|
464
|
+
config("interface #{interfaces[0]}", 'switchport')
|
|
527
465
|
|
|
528
466
|
result = false
|
|
529
467
|
assert_result(result,
|
|
530
|
-
|
|
468
|
+
'Error: interface, access, autostate exclude not disabled') do
|
|
531
469
|
interface.switchport_autostate_exclude = result
|
|
532
|
-
|
|
470
|
+
end
|
|
533
471
|
svi.destroy
|
|
534
472
|
interface_ethernet_default(interfaces_id[0])
|
|
535
473
|
end
|
|
@@ -540,17 +478,13 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
540
478
|
interface.switchport_mode = :trunk
|
|
541
479
|
|
|
542
480
|
# switchport must be enabled to configure autostate
|
|
543
|
-
|
|
544
|
-
@device.cmd("interface #{interfaces[0]}")
|
|
545
|
-
@device.cmd("switchport")
|
|
546
|
-
@device.cmd("end")
|
|
547
|
-
node.cache_flush
|
|
481
|
+
config("interface #{interfaces[0]}", 'switchport')
|
|
548
482
|
|
|
549
483
|
result = false
|
|
550
484
|
assert_result(result,
|
|
551
|
-
|
|
485
|
+
'Error: interface, access, autostate exclude not disabled') do
|
|
552
486
|
interface.switchport_autostate_exclude = result
|
|
553
|
-
|
|
487
|
+
end
|
|
554
488
|
svi.destroy
|
|
555
489
|
interface_ethernet_default(interfaces_id[0])
|
|
556
490
|
end
|
|
@@ -560,7 +494,7 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
560
494
|
interface = Interface.new(interfaces[0])
|
|
561
495
|
interface.switchport_mode = :disabled
|
|
562
496
|
|
|
563
|
-
assert_raises
|
|
497
|
+
assert_raises RuntimeError do
|
|
564
498
|
interface.switchport_autostate_exclude = false
|
|
565
499
|
end
|
|
566
500
|
svi.destroy
|
|
@@ -569,21 +503,17 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
569
503
|
|
|
570
504
|
def test_interface_switchport_mode_invalid
|
|
571
505
|
interface = Interface.new(interfaces[0])
|
|
572
|
-
assert_raises(ArgumentError) {
|
|
573
|
-
interface.switchport_mode = :unknown
|
|
574
|
-
}
|
|
506
|
+
assert_raises(ArgumentError) { interface.switchport_mode = :unknown }
|
|
575
507
|
interface_ethernet_default(interfaces_id[0])
|
|
576
508
|
end
|
|
577
509
|
|
|
578
510
|
def test_interface_switchport_mode_not_supported
|
|
579
|
-
interface = Interface.new(
|
|
580
|
-
assert_raises(RuntimeError) {
|
|
581
|
-
interface.switchport_mode = :access
|
|
582
|
-
}
|
|
511
|
+
interface = Interface.new('mgmt0')
|
|
512
|
+
assert_raises(RuntimeError) { interface.switchport_mode = :access }
|
|
583
513
|
begin
|
|
584
514
|
interface.switchport_mode = :access
|
|
585
515
|
rescue RuntimeError => e
|
|
586
|
-
msg =
|
|
516
|
+
msg = '[mgmt0] switchport_mode is not supported on this interface'
|
|
587
517
|
assert_equal(msg, e.message)
|
|
588
518
|
end
|
|
589
519
|
end
|
|
@@ -600,25 +530,25 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
600
530
|
|
|
601
531
|
interface = Interface.new(interfaces[0])
|
|
602
532
|
|
|
603
|
-
switchport_modes.each
|
|
604
|
-
switchport_modes.each
|
|
605
|
-
if start
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
533
|
+
switchport_modes.each do |start|
|
|
534
|
+
switchport_modes.each do |finish|
|
|
535
|
+
next if start == :unknown || finish == :unknown
|
|
536
|
+
begin
|
|
537
|
+
# puts "#{start},#{finish}"
|
|
538
|
+
interface.switchport_mode = start
|
|
539
|
+
assert_equal(start, interface.switchport_mode,
|
|
540
|
+
"Error: Switchport mode, #{start}, not as expected")
|
|
541
|
+
# puts "now finish #{finish}"
|
|
542
|
+
interface.switchport_mode = finish
|
|
543
|
+
assert_equal(finish, interface.switchport_mode,
|
|
544
|
+
"Error: Switchport mode, #{finish}, not as expected")
|
|
545
|
+
rescue RuntimeError => e
|
|
546
|
+
msg = "[#{interfaces[0]}] switchport_mode is not supported " \
|
|
547
|
+
'on this interface'
|
|
548
|
+
assert_equal(msg.downcase, e.message)
|
|
619
549
|
end
|
|
620
|
-
|
|
621
|
-
|
|
550
|
+
end
|
|
551
|
+
end
|
|
622
552
|
interface_ethernet_default(interfaces_id[0])
|
|
623
553
|
end
|
|
624
554
|
|
|
@@ -629,32 +559,31 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
629
559
|
]
|
|
630
560
|
|
|
631
561
|
interface = Interface.new(interfaces[0])
|
|
632
|
-
switchport_modes.each
|
|
633
|
-
switchport_modes.each
|
|
634
|
-
if start
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
end
|
|
562
|
+
switchport_modes.each do |start|
|
|
563
|
+
switchport_modes.each do |finish|
|
|
564
|
+
next if start == :unknown || finish == :unknown
|
|
565
|
+
begin
|
|
566
|
+
# puts "#{start},#{finish}"
|
|
567
|
+
interface.switchport_mode = start
|
|
568
|
+
assert_equal(start, interface.switchport_mode,
|
|
569
|
+
"Error: Switchport mode, #{start}, not as expected")
|
|
570
|
+
interface.switchport_mode = finish
|
|
571
|
+
assert_equal(finish, interface.switchport_mode,
|
|
572
|
+
"Error: Switchport mode, #{finish}, not as expected")
|
|
573
|
+
rescue RuntimeError => e
|
|
574
|
+
msg = "[#{interfaces[0]}] switchport_mode is not supported " \
|
|
575
|
+
'on this interface'
|
|
576
|
+
assert_equal(msg.downcase, e.message)
|
|
648
577
|
end
|
|
649
|
-
|
|
650
|
-
|
|
578
|
+
end
|
|
579
|
+
end
|
|
651
580
|
interface_ethernet_default(interfaces_id[0])
|
|
652
581
|
end
|
|
653
582
|
|
|
654
583
|
def test_interface_switchport_trunk_allowed_vlan_all
|
|
655
584
|
interface = Interface.new(interfaces[0])
|
|
656
585
|
interface.switchport_enable
|
|
657
|
-
interface.switchport_trunk_allowed_vlan =
|
|
586
|
+
interface.switchport_trunk_allowed_vlan = 'all'
|
|
658
587
|
assert_equal(
|
|
659
588
|
DEFAULT_IF_SWITCHPORT_ALLOWED_VLAN,
|
|
660
589
|
interface.switchport_trunk_allowed_vlan)
|
|
@@ -664,10 +593,10 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
664
593
|
def test_interface_switchport_trunk_allowed_vlan_change
|
|
665
594
|
interface = Interface.new(interfaces[0])
|
|
666
595
|
interface.switchport_enable
|
|
667
|
-
interface.switchport_trunk_allowed_vlan =
|
|
668
|
-
assert_equal(
|
|
669
|
-
interface.switchport_trunk_allowed_vlan =
|
|
670
|
-
assert_equal(
|
|
596
|
+
interface.switchport_trunk_allowed_vlan = '20'
|
|
597
|
+
assert_equal('20', interface.switchport_trunk_allowed_vlan)
|
|
598
|
+
interface.switchport_trunk_allowed_vlan = '30'
|
|
599
|
+
assert_equal('30', interface.switchport_trunk_allowed_vlan)
|
|
671
600
|
interface_ethernet_default(interfaces_id[0])
|
|
672
601
|
end
|
|
673
602
|
|
|
@@ -685,25 +614,25 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
685
614
|
def test_interface_switchport_trunk_allowed_vlan_invalid
|
|
686
615
|
interface = Interface.new(interfaces[0])
|
|
687
616
|
interface.switchport_enable
|
|
688
|
-
assert_raises(RuntimeError)
|
|
689
|
-
interface.switchport_trunk_allowed_vlan =
|
|
690
|
-
|
|
617
|
+
assert_raises(RuntimeError) do
|
|
618
|
+
interface.switchport_trunk_allowed_vlan = 'hello'
|
|
619
|
+
end
|
|
691
620
|
interface_ethernet_default(interfaces_id[0])
|
|
692
621
|
end
|
|
693
622
|
|
|
694
623
|
def test_interface_switchport_trunk_allowed_vlan_none
|
|
695
624
|
interface = Interface.new(interfaces[0])
|
|
696
625
|
interface.switchport_enable
|
|
697
|
-
interface.switchport_trunk_allowed_vlan =
|
|
698
|
-
assert_equal(
|
|
626
|
+
interface.switchport_trunk_allowed_vlan = 'none'
|
|
627
|
+
assert_equal('none', interface.switchport_trunk_allowed_vlan)
|
|
699
628
|
interface_ethernet_default(interfaces_id[0])
|
|
700
629
|
end
|
|
701
630
|
|
|
702
631
|
def test_interface_switchport_trunk_allowed_vlan_valid
|
|
703
632
|
interface = Interface.new(interfaces[0])
|
|
704
633
|
interface.switchport_enable
|
|
705
|
-
interface.switchport_trunk_allowed_vlan =
|
|
706
|
-
assert_equal(
|
|
634
|
+
interface.switchport_trunk_allowed_vlan = '20, 30'
|
|
635
|
+
assert_equal('20,30', interface.switchport_trunk_allowed_vlan)
|
|
707
636
|
interface_ethernet_default(interfaces_id[0])
|
|
708
637
|
end
|
|
709
638
|
|
|
@@ -731,9 +660,9 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
731
660
|
def test_interface_switchport_trunk_native_vlan_invalid
|
|
732
661
|
interface = Interface.new(interfaces[0])
|
|
733
662
|
interface.switchport_enable
|
|
734
|
-
assert_raises(RuntimeError)
|
|
735
|
-
interface.switchport_trunk_native_vlan =
|
|
736
|
-
|
|
663
|
+
assert_raises(RuntimeError) do
|
|
664
|
+
interface.switchport_trunk_native_vlan = '20, 30'
|
|
665
|
+
end
|
|
737
666
|
interface_ethernet_default(interfaces_id[0])
|
|
738
667
|
end
|
|
739
668
|
|
|
@@ -745,81 +674,76 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
745
674
|
interface_ethernet_default(interfaces_id[0])
|
|
746
675
|
end
|
|
747
676
|
|
|
748
|
-
|
|
749
|
-
# Run this test at your peril as it can cause timeouts for this test and
|
|
677
|
+
# TODO: Run this test at your peril as it can cause timeouts for this test and
|
|
750
678
|
# others - 'no feature-set fex' states:
|
|
751
|
-
# "Feature-set Operation may take up to 30 minutes depending on the
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
end
|
|
787
|
-
|
|
679
|
+
# "Feature-set Operation may take up to 30 minutes depending on the
|
|
680
|
+
# size of configuration."
|
|
681
|
+
#
|
|
682
|
+
# def test_interface_switchport_fex_feature
|
|
683
|
+
# test_matrix = {
|
|
684
|
+
# # [ <set_state>, <expected> ]
|
|
685
|
+
# 1 => [:uninstalled, :uninstalled], # noop
|
|
686
|
+
# 2 => [:installed, :installed],
|
|
687
|
+
# 3 => [:uninstalled, :uninstalled],
|
|
688
|
+
# 4 => [:enabled, :enabled],
|
|
689
|
+
# 5 => [:enabled, :enabled], # noop
|
|
690
|
+
# 6 => [:installed, :enabled], # noop
|
|
691
|
+
# 7 => [:uninstalled, :uninstalled],
|
|
692
|
+
# 8 => [:disabled, :uninstalled], # noop
|
|
693
|
+
# 9 => [:installed, :installed],
|
|
694
|
+
# 10 => [:installed, :installed], # noop
|
|
695
|
+
# 11 => [:enabled, :enabled],
|
|
696
|
+
# 12 => [:disabled, :disabled],
|
|
697
|
+
# 13 => [:uninstalled, :uninstalled],
|
|
698
|
+
# 14 => [:installed, :installed],
|
|
699
|
+
# 15 => [:disabled, :installed], # noop
|
|
700
|
+
# 16 => [:uninstalled, :uninstalled],
|
|
701
|
+
# }
|
|
702
|
+
# interface = Interface.new(interfaces[0])
|
|
703
|
+
# # start test from :uninstalled state
|
|
704
|
+
# interface.fex_feature_set(:uninstalled)
|
|
705
|
+
# from = interface.fex_feature
|
|
706
|
+
# test_matrix.each do |id,test|
|
|
707
|
+
# #puts "Test #{id}: #{test}, (from: #{from}"
|
|
708
|
+
# set_state, expected = test
|
|
709
|
+
# interface.fex_feature_set(set_state)
|
|
710
|
+
# curr = interface.fex_feature
|
|
711
|
+
# assert_equal(expected, curr,
|
|
712
|
+
# "Error: fex test #{id}: from #{from} to #{set_state}")
|
|
713
|
+
# from = curr
|
|
714
|
+
# end
|
|
715
|
+
# end
|
|
788
716
|
|
|
789
717
|
def test_system_default_switchport_on_off
|
|
790
|
-
interface = Interface.new(
|
|
718
|
+
interface = Interface.new('Eth1/1')
|
|
791
719
|
|
|
792
|
-
|
|
720
|
+
system_default_switchport('')
|
|
793
721
|
assert(interface.system_default_switchport,
|
|
794
|
-
|
|
722
|
+
'Test for enabled - failed')
|
|
795
723
|
|
|
796
724
|
# common default is "no switch"
|
|
797
|
-
|
|
725
|
+
system_default_switchport('no ')
|
|
798
726
|
refute(interface.system_default_switchport,
|
|
799
|
-
|
|
727
|
+
'Test for disabled - failed')
|
|
800
728
|
end
|
|
801
729
|
|
|
802
730
|
def test_system_default_switchport_shutdown_on_off
|
|
803
|
-
interface = Interface.new(
|
|
731
|
+
interface = Interface.new('Eth1/1')
|
|
804
732
|
|
|
805
|
-
|
|
733
|
+
system_default_switchport_shutdown('no ')
|
|
806
734
|
refute(interface.system_default_switchport_shutdown,
|
|
807
|
-
|
|
735
|
+
'Test for disabled - failed')
|
|
808
736
|
|
|
809
737
|
# common default is "shutdown"
|
|
810
|
-
|
|
738
|
+
system_default_switchport_shutdown('')
|
|
811
739
|
assert(interface.system_default_switchport_shutdown,
|
|
812
|
-
|
|
740
|
+
'Test for enabled - failed')
|
|
813
741
|
end
|
|
814
742
|
|
|
815
743
|
def test_interface_svi_command_on_non_vlan
|
|
816
744
|
interface = Interface.new(interfaces[0])
|
|
817
|
-
assert_raises(RuntimeError) {
|
|
818
|
-
|
|
819
|
-
}
|
|
820
|
-
assert_raises(RuntimeError) {
|
|
821
|
-
interface.svi_management = true
|
|
822
|
-
}
|
|
745
|
+
assert_raises(RuntimeError) { interface.svi_autostate = true }
|
|
746
|
+
assert_raises(RuntimeError) { interface.svi_management = true }
|
|
823
747
|
interface_ethernet_default(interfaces_id[0])
|
|
824
748
|
end
|
|
825
749
|
end
|