cisco_node_utils 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +66 -0
- data/Gemfile +1 -0
- data/README.md +44 -43
- data/bin/.rubocop.yml +18 -0
- data/bin/show_running_yang.rb +233 -0
- data/cisco_node_utils.gemspec +1 -1
- data/docs/README-maintainers.md +1 -0
- data/docs/README-utilities.md +14 -0
- data/lib/.rubocop.yml +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +8 -3
- data/lib/cisco_node_utils/aaa_authorization_service.rb +6 -0
- data/lib/cisco_node_utils/bfd_global.rb +300 -0
- data/lib/cisco_node_utils/bgp.rb +6 -4
- data/lib/cisco_node_utils/bgp_af.rb +2 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +14 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +4 -1
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +126 -0
- data/lib/cisco_node_utils/client/client.rb +6 -2
- data/lib/cisco_node_utils/client/grpc/client.rb +120 -36
- data/lib/cisco_node_utils/client/nxapi/client.rb +6 -2
- data/lib/cisco_node_utils/cmd_ref/DEPRECATED.yaml +118 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +7 -7
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +125 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +141 -49
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +44 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +0 -3
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +3 -3
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +39 -15
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +43 -21
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +48 -19
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +0 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +30 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +18 -6
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +4 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +1 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +23 -10
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +8 -2
- data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +10 -1
- data/lib/cisco_node_utils/constants.rb +8 -1
- data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
- data/lib/cisco_node_utils/exceptions.rb +29 -0
- data/lib/cisco_node_utils/feature.rb +28 -0
- data/lib/cisco_node_utils/interface.rb +493 -402
- data/lib/cisco_node_utils/interface_DEPRECATED.rb +513 -0
- data/lib/cisco_node_utils/interface_ospf.rb +126 -0
- data/lib/cisco_node_utils/interface_portchannel.rb +16 -0
- data/lib/cisco_node_utils/logger.rb +3 -0
- data/lib/cisco_node_utils/node.rb +29 -1
- data/lib/cisco_node_utils/overlay_global.rb +1 -12
- data/lib/cisco_node_utils/pim.rb +1 -0
- data/lib/cisco_node_utils/pim_group_list.rb +1 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +1 -0
- data/lib/cisco_node_utils/platform.rb +9 -2
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
- data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
- data/lib/cisco_node_utils/router_ospf_vrf.rb +17 -0
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +27 -9
- data/lib/cisco_node_utils/snmpcommunity.rb +34 -8
- data/lib/cisco_node_utils/snmpserver.rb +4 -4
- data/lib/cisco_node_utils/snmpuser.rb +0 -0
- data/lib/cisco_node_utils/tacacs_global.rb +102 -0
- data/lib/cisco_node_utils/tacacs_server.rb +8 -7
- data/lib/cisco_node_utils/vdc.rb +25 -7
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vlan.rb +30 -56
- data/lib/cisco_node_utils/vlan_DEPRECATED.rb +108 -0
- data/lib/cisco_node_utils/yang.rb +160 -0
- data/lib/cisco_node_utils/yum.rb +25 -32
- data/tests/.rubocop.yml +3 -0
- data/tests/ciscotest.rb +136 -19
- data/tests/cmd_config_invalid.yaml +1 -1
- data/tests/noop.rb +7 -0
- data/tests/tacacs_server.yaml.example +6 -0
- data/tests/test_aaa_authentication_login.rb +24 -1
- data/tests/test_aaa_authentication_login_service.rb +9 -16
- data/tests/test_aaa_authorization_service.rb +111 -84
- data/tests/test_bfd_global.rb +278 -0
- data/tests/test_bgp_neighbor.rb +20 -0
- data/tests/test_bridge_domain_vni.rb +2 -9
- data/tests/test_cmn_utils.rb +76 -0
- data/tests/test_dhcp_relay_global.rb +284 -0
- data/tests/test_dns_domain.rb +4 -4
- data/tests/test_domain_name.rb +2 -2
- data/tests/test_encapsulation.rb +2 -4
- data/tests/test_evpn_vni.rb +14 -7
- data/tests/test_fabricpath_global.rb +12 -13
- data/tests/test_feature.rb +35 -17
- data/tests/test_interface.rb +352 -127
- data/tests/test_interface_bdi.rb +2 -2
- data/tests/test_interface_channel_group.rb +1 -1
- data/tests/test_interface_ospf.rb +153 -23
- data/tests/test_interface_portchannel.rb +15 -6
- data/tests/test_interface_private_vlan.rb +200 -576
- data/tests/test_interface_svi.rb +5 -52
- data/tests/test_interface_switchport.rb +80 -240
- data/tests/test_itd_device_group.rb +2 -2
- data/tests/test_itd_device_group_node.rb +2 -2
- data/tests/test_itd_service.rb +1 -1
- data/tests/test_name_server.rb +3 -3
- data/tests/test_node_ext.rb +15 -17
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +3 -3
- data/tests/test_nxapi.rb +1 -0
- data/tests/test_overlay_global.rb +15 -19
- data/tests/test_pim.rb +5 -5
- data/tests/test_pim_group_list.rb +1 -37
- data/tests/test_pim_rp_address.rb +1 -1
- data/tests/test_platform.rb +9 -11
- data/tests/test_portchannel_global.rb +43 -3
- data/tests/test_radius_server.rb +1 -1
- data/tests/test_radius_server_group.rb +1 -1
- data/tests/test_router_bgp.rb +17 -30
- data/tests/test_router_ospf_area.rb +433 -0
- data/tests/test_router_ospf_area_vlink.rb +298 -0
- data/tests/test_router_ospf_vrf.rb +17 -0
- data/tests/test_snmp_notification_receiver.rb +11 -11
- data/tests/test_snmpcommunity.rb +177 -69
- data/tests/test_snmpgroup.rb +7 -7
- data/tests/test_snmpserver.rb +164 -253
- data/tests/test_snmpuser.rb +73 -69
- data/tests/test_stp_global.rb +15 -15
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_global.rb +80 -0
- data/tests/test_tacacs_server.rb +129 -51
- data/tests/test_tacacs_server_group.rb +3 -29
- data/tests/test_tacacs_server_host.rb +24 -27
- data/tests/test_vlan.rb +57 -59
- data/tests/test_vlan_private.rb +271 -284
- data/tests/test_vpc.rb +10 -4
- data/tests/test_vrf.rb +2 -0
- data/tests/test_vrf_af.rb +2 -5
- data/tests/test_vtp.rb +5 -2
- data/tests/test_vxlan_vtep.rb +20 -44
- data/tests/test_vxlan_vtep_vni.rb +23 -16
- data/tests/test_yang.rb +369 -0
- data/tests/test_yum.rb +34 -42
- data/tests/yum_package.yaml +35 -0
- metadata +31 -4
- data/tests/test_vlan_mt_full.rb +0 -85
data/tests/test_interface_svi.rb
CHANGED
@@ -67,56 +67,7 @@ class TestSvi < CiscoTestCase
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
if validate_property_excluded?('interface',
|
72
|
-
'private_vlan_mapping')
|
73
|
-
assert_nil(svi.private_vlan_mapping)
|
74
|
-
return
|
75
|
-
end
|
76
|
-
input = %w(10-20 30)
|
77
|
-
result = ['10-20,30']
|
78
|
-
svi.private_vlan_mapping = input
|
79
|
-
assert_equal(result,
|
80
|
-
svi.private_vlan_mapping,
|
81
|
-
'Error: svi private mapping not configured')
|
82
|
-
|
83
|
-
input = %w(11-13)
|
84
|
-
result = %w(11-13)
|
85
|
-
svi.private_vlan_mapping = input
|
86
|
-
assert_equal(result,
|
87
|
-
svi.private_vlan_mapping,
|
88
|
-
'Error: svi private mapping not configured')
|
89
|
-
|
90
|
-
input = []
|
91
|
-
result = []
|
92
|
-
svi.private_vlan_mapping = input
|
93
|
-
input = svi.private_vlan_mapping
|
94
|
-
assert_equal(input, result,
|
95
|
-
'Err: wrong config for svi pvlan mapping')
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_private_vlan_mapping_bad_args
|
99
|
-
if validate_property_excluded?('interface',
|
100
|
-
'private_vlan_mapping')
|
101
|
-
assert_nil(svi.private_vlan_mapping)
|
102
|
-
return
|
103
|
-
end
|
104
|
-
input = %w(10 20)
|
105
|
-
result = ['10,20']
|
106
|
-
svi.private_vlan_mapping = input
|
107
|
-
input = svi.private_vlan_mapping
|
108
|
-
assert_equal(result,
|
109
|
-
svi.private_vlan_mapping,
|
110
|
-
'Error: svi private mapping not configured')
|
111
|
-
|
112
|
-
input = %w(23)
|
113
|
-
assert_raises(RuntimeError,
|
114
|
-
'svi pvlan mapping did not raise RuntimeError') do
|
115
|
-
svi.private_vlan_mapping = input
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_prop_nil_when_ethernet
|
70
|
+
def test_prop_nil_when_eth
|
120
71
|
skip_autostate_test?
|
121
72
|
intf = Interface.new(interfaces[0])
|
122
73
|
assert_nil(intf.svi_autostate,
|
@@ -161,6 +112,8 @@ class TestSvi < CiscoTestCase
|
|
161
112
|
end
|
162
113
|
|
163
114
|
def test_get_autostate
|
115
|
+
# TBD: autostate is also tested in test_interface_switchport.rb so remove
|
116
|
+
# tests from one or the other
|
164
117
|
skip_autostate_test?
|
165
118
|
|
166
119
|
config('interface vlan 23', 'no autostate')
|
@@ -233,14 +186,14 @@ class TestSvi < CiscoTestCase
|
|
233
186
|
end
|
234
187
|
end
|
235
188
|
|
236
|
-
def
|
189
|
+
def test_description
|
237
190
|
description = 'Test description'
|
238
191
|
svi.description = description
|
239
192
|
assert_equal(description, svi.description,
|
240
193
|
'Error: Description not configured')
|
241
194
|
end
|
242
195
|
|
243
|
-
def
|
196
|
+
def test_sys_def_svi_autostate
|
244
197
|
skip_autostate_test?
|
245
198
|
interface = Interface.new(interfaces[0])
|
246
199
|
|
@@ -55,7 +55,6 @@ end
|
|
55
55
|
# TestSwitchport - general interface switchport tests.
|
56
56
|
class TestSwitchport < TestInterfaceSwitchport
|
57
57
|
DEFAULT_IF_ACCESS_VLAN = 1
|
58
|
-
DEFAULT_IF_SWITCHPORT_ALLOWED_VLAN = '1-4094'
|
59
58
|
DEFAULT_IF_SWITCHPORT_NATIVE_VLAN = 1
|
60
59
|
|
61
60
|
def system_default_switchport(state='')
|
@@ -66,7 +65,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
66
65
|
config("#{state} system default switchport shutdown")
|
67
66
|
end
|
68
67
|
|
69
|
-
def
|
68
|
+
def test_access_vlan
|
70
69
|
interface.switchport_mode = :disabled
|
71
70
|
if platform == :ios_xr
|
72
71
|
assert_raises(Cisco::UnsupportedError) do
|
@@ -79,7 +78,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
79
78
|
end
|
80
79
|
end
|
81
80
|
|
82
|
-
def
|
81
|
+
def test_access_vlan_sw_disabled
|
83
82
|
interface.switchport_mode = :disabled
|
84
83
|
if platform == :ios_xr
|
85
84
|
assert_nil(interface.access_vlan)
|
@@ -88,7 +87,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
91
|
-
def
|
90
|
+
def test_access_vlan_sw_trunk
|
92
91
|
interface.switchport_mode = :disabled
|
93
92
|
if platform == :ios_xr
|
94
93
|
assert_raises(Cisco::UnsupportedError) do
|
@@ -101,24 +100,22 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
101
100
|
end
|
102
101
|
end
|
103
102
|
|
104
|
-
def
|
103
|
+
def test_sw_vtp_disabled
|
105
104
|
refute(interface.switchport_vtp,
|
106
105
|
'Error: interface, access, vtp not disabled')
|
107
|
-
end
|
108
106
|
|
109
|
-
|
107
|
+
# mgmt
|
110
108
|
interface = Interface.new(mgmt_intf)
|
111
109
|
refute(interface.switchport_vtp,
|
112
110
|
'Error: interface, access, vtp not disabled')
|
113
|
-
end
|
114
111
|
|
115
|
-
|
112
|
+
# no switchport
|
116
113
|
interface.switchport_mode = :disabled
|
117
114
|
refute(interface.switchport_vtp,
|
118
115
|
'Error: interface, access, vtp not disabled')
|
119
116
|
end
|
120
117
|
|
121
|
-
def
|
118
|
+
def test_sw_vtp_disabled_fex
|
122
119
|
if validate_property_excluded?('feature', 'fex')
|
123
120
|
assert_raises(Cisco::UnsupportedError) do
|
124
121
|
Feature.fex_enable
|
@@ -135,23 +132,19 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
135
132
|
refute(interface.switchport_vtp,
|
136
133
|
'Error: interface, access, vtp not disabled')
|
137
134
|
rescue Cisco::CliError => e
|
138
|
-
|
139
|
-
'on this interface'
|
140
|
-
assert_equal(msg.downcase, e.message)
|
135
|
+
incompatible_interface?(e.message)
|
141
136
|
end
|
142
137
|
|
143
|
-
def
|
138
|
+
def test_sw_autostate_disabled
|
144
139
|
refute(interface.switchport_autostate_exclude,
|
145
140
|
'Error: interface, access, autostate exclude not disabled')
|
146
|
-
end
|
147
141
|
|
148
|
-
|
142
|
+
# mgmt
|
149
143
|
interface = Interface.new(mgmt_intf)
|
150
144
|
refute(interface.switchport_autostate_exclude,
|
151
145
|
'Error: interface, access, autostate exclude not disabled')
|
152
|
-
end
|
153
146
|
|
154
|
-
|
147
|
+
# no switchport
|
155
148
|
if platform == :ios_xr
|
156
149
|
assert_nil(interface.switchport_autostate_exclude)
|
157
150
|
else
|
@@ -161,7 +154,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
161
154
|
end
|
162
155
|
end
|
163
156
|
|
164
|
-
def
|
157
|
+
def test_sw_mode_disabled
|
165
158
|
if platform == :ios_xr
|
166
159
|
assert_raises(Cisco::UnsupportedError) do
|
167
160
|
interface.switchport_autostate_exclude = true
|
@@ -175,18 +168,16 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
175
168
|
end
|
176
169
|
end
|
177
170
|
|
178
|
-
def
|
171
|
+
def test_sw_mode_invalid
|
179
172
|
assert_raises(ArgumentError) { interface.switchport_mode = :unknown }
|
180
|
-
end
|
181
173
|
|
182
|
-
def test_interface_switchport_mode_not_supported
|
183
174
|
interface = Interface.new(mgmt_intf)
|
184
175
|
assert_raises(Cisco::CliError, Cisco::UnsupportedError) do
|
185
176
|
interface.switchport_mode = :access
|
186
177
|
end
|
187
178
|
end
|
188
179
|
|
189
|
-
def
|
180
|
+
def test_sw_mode_valid
|
190
181
|
if platform == :ios_xr
|
191
182
|
# We don't support any switchport modes on IOS XR
|
192
183
|
# but we allow the user to set :disabled since that's the default.
|
@@ -229,7 +220,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
229
220
|
end
|
230
221
|
end
|
231
222
|
|
232
|
-
def
|
223
|
+
def test_sw_mode_valid_fex
|
233
224
|
if validate_property_excluded?('feature', 'fex')
|
234
225
|
assert_raises(Cisco::UnsupportedError) do
|
235
226
|
Feature.fex_enable
|
@@ -244,10 +235,11 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
244
235
|
end
|
245
236
|
|
246
237
|
interface.switchport_mode = :fex_fabric
|
247
|
-
|
238
|
+
rescue Cisco::CliError => e
|
239
|
+
incompatible_interface?(e.message)
|
248
240
|
end
|
249
241
|
|
250
|
-
def
|
242
|
+
def test_sw_trunk_allowed_vlan
|
251
243
|
if platform == :ios_xr
|
252
244
|
assert_nil(interface.default_switchport_trunk_allowed_vlan)
|
253
245
|
assert_nil(interface.switchport_trunk_allowed_vlan)
|
@@ -263,7 +255,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
263
255
|
else
|
264
256
|
interface.switchport_enable
|
265
257
|
interface.switchport_trunk_allowed_vlan = 'all'
|
266
|
-
assert_equal(
|
258
|
+
assert_equal(interface.default_switchport_trunk_allowed_vlan,
|
267
259
|
interface.switchport_trunk_allowed_vlan)
|
268
260
|
|
269
261
|
interface.switchport_trunk_allowed_vlan = '20'
|
@@ -274,22 +266,24 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
274
266
|
|
275
267
|
interface.switchport_trunk_allowed_vlan =
|
276
268
|
interface.default_switchport_trunk_allowed_vlan
|
277
|
-
assert_equal(
|
269
|
+
assert_equal(interface.default_switchport_trunk_allowed_vlan,
|
278
270
|
interface.switchport_trunk_allowed_vlan)
|
279
271
|
|
280
|
-
assert_raises(RuntimeError) do
|
281
|
-
interface.switchport_trunk_allowed_vlan = 'hello'
|
282
|
-
end
|
283
|
-
|
284
272
|
interface.switchport_trunk_allowed_vlan = 'none'
|
285
273
|
assert_equal('none', interface.switchport_trunk_allowed_vlan)
|
286
274
|
|
287
275
|
interface.switchport_trunk_allowed_vlan = '20, 30'
|
288
276
|
assert_equal('20,30', interface.switchport_trunk_allowed_vlan)
|
277
|
+
|
278
|
+
# Some images have behavior where 'vlan add' is separate line
|
279
|
+
# This behavior is triggered for vlan ranges that exceed character limit
|
280
|
+
vlans = '500-528,530,532,534,587,590-593,597-598,600,602,604'
|
281
|
+
interface.switchport_trunk_allowed_vlan = vlans
|
282
|
+
assert_equal(vlans, interface.switchport_trunk_allowed_vlan)
|
289
283
|
end
|
290
284
|
end
|
291
285
|
|
292
|
-
def
|
286
|
+
def test_sw_trunk_native_vlan
|
293
287
|
if platform == :ios_xr
|
294
288
|
assert_nil(interface.switchport_trunk_native_vlan)
|
295
289
|
assert_nil(interface.default_switchport_trunk_native_vlan)
|
@@ -309,14 +303,10 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
309
303
|
interface.default_switchport_trunk_native_vlan
|
310
304
|
assert_equal(DEFAULT_IF_SWITCHPORT_NATIVE_VLAN,
|
311
305
|
interface.switchport_trunk_native_vlan)
|
312
|
-
|
313
|
-
assert_raises(RuntimeError) do
|
314
|
-
interface.switchport_trunk_native_vlan = '20, 30'
|
315
|
-
end
|
316
306
|
end
|
317
307
|
end
|
318
308
|
|
319
|
-
def
|
309
|
+
def test_sys_def_sw_on_off
|
320
310
|
if platform == :nexus
|
321
311
|
system_default_switchport('')
|
322
312
|
assert(interface.system_default_switchport,
|
@@ -333,7 +323,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
333
323
|
flunk(e.message)
|
334
324
|
end
|
335
325
|
|
336
|
-
def
|
326
|
+
def test_sys_def_sw_shut_on_off
|
337
327
|
if platform == :nexus
|
338
328
|
system_default_switchport_shutdown('no ')
|
339
329
|
refute(interface.system_default_switchport_shutdown,
|
@@ -346,7 +336,7 @@ class TestSwitchport < TestInterfaceSwitchport
|
|
346
336
|
'Test for enabled - failed')
|
347
337
|
end
|
348
338
|
|
349
|
-
def
|
339
|
+
def test_svi_cmd_on_non_vlan
|
350
340
|
assert_raises(RuntimeError) { interface.svi_autostate = true }
|
351
341
|
assert_raises(RuntimeError) { interface.svi_management = true }
|
352
342
|
end
|
@@ -355,7 +345,7 @@ end
|
|
355
345
|
# TestInterfaceSwitchportSvi
|
356
346
|
# Minitest for Interface switchport configuration in combo with interface-vlan
|
357
347
|
# Not applicable to IOS XR
|
358
|
-
class
|
348
|
+
class TestInterfaceSwSvi < TestInterfaceSwitchport
|
359
349
|
attr_reader :svi
|
360
350
|
|
361
351
|
def setup
|
@@ -365,121 +355,53 @@ class TestInterfaceSwitchportSvi < TestInterfaceSwitchport
|
|
365
355
|
end
|
366
356
|
|
367
357
|
def teardown
|
368
|
-
svi.destroy unless platform == :ios_xr
|
358
|
+
svi.destroy unless platform == :ios_xr || svi.nil?
|
369
359
|
super
|
370
360
|
end
|
371
361
|
|
372
|
-
def
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
def test_switchport_autostate_disabled_feature_enabled
|
380
|
-
refute(interface.switchport_autostate_exclude,
|
381
|
-
'Error: interface, access, autostate exclude not disabled')
|
382
|
-
end
|
383
|
-
|
384
|
-
def test_switchport_autostate_enabled_access
|
385
|
-
config("interface ethernet #{interfaces_id[0]}",
|
386
|
-
'switchport',
|
387
|
-
'switchport autostate exclude')
|
388
|
-
|
389
|
-
cmd_ref = cmd_ref_switchport_autostate_exclude
|
390
|
-
if cmd_ref.setter?
|
391
|
-
assert(interface.switchport_autostate_exclude,
|
392
|
-
'Error: interface, access, autostate exclude not enabled')
|
393
|
-
else
|
394
|
-
assert_equal(interface.default_switchport_autostate_exclude,
|
395
|
-
interface.switchport_autostate_exclude,
|
396
|
-
'Error: interface, access, autostate exclude not disabled')
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
def test_switchport_autostate_disabled_access
|
401
|
-
refute(interface.switchport_autostate_exclude,
|
402
|
-
'Error: interface, access, autostate exclude not disabled')
|
403
|
-
end
|
404
|
-
|
405
|
-
def test_switchport_autostate_enabled_trunk
|
406
|
-
interface.switchport_mode = :trunk
|
407
|
-
config("interface ethernet #{interfaces_id[0]}",
|
408
|
-
'switchport autostate exclude')
|
409
|
-
|
410
|
-
cmd_ref = cmd_ref_switchport_autostate_exclude
|
411
|
-
if cmd_ref.setter?
|
412
|
-
assert(interface.switchport_autostate_exclude,
|
413
|
-
'Error: interface, access, autostate exclude not enabled')
|
414
|
-
else
|
415
|
-
assert_equal(interface.default_switchport_autostate_exclude,
|
416
|
-
interface.switchport_autostate_exclude,
|
417
|
-
'Error: interface, access, autostate exclude not disabled')
|
362
|
+
def test_sw_autostate
|
363
|
+
i = interface
|
364
|
+
if validate_property_excluded?('interface', 'switchport_autostate_exclude')
|
365
|
+
assert_raises(Cisco::UnsupportedError) do
|
366
|
+
i.switchport_autostate_exclude = false
|
367
|
+
end
|
368
|
+
return
|
418
369
|
end
|
419
|
-
end
|
420
370
|
|
421
|
-
|
422
|
-
interface.switchport_mode = :trunk
|
423
|
-
config("interface ethernet #{interfaces_id[0]}",
|
424
|
-
'no switchport autostate exclude')
|
371
|
+
default = i.default_switchport_autostate_exclude
|
425
372
|
|
426
|
-
|
427
|
-
|
428
|
-
|
373
|
+
# access
|
374
|
+
i.switchport_mode = :access
|
375
|
+
assert_equal(default, i.switchport_autostate_exclude)
|
429
376
|
|
430
|
-
|
431
|
-
|
432
|
-
interface.switchport_enable(true)
|
377
|
+
i.switchport_autostate_exclude = true
|
378
|
+
assert(i.switchport_autostate_exclude)
|
433
379
|
|
434
|
-
|
435
|
-
|
436
|
-
'Error: interface, access, autostate exclude not enabled')
|
380
|
+
i.switchport_autostate_exclude = false
|
381
|
+
refute(i.switchport_autostate_exclude)
|
437
382
|
|
438
|
-
|
439
|
-
|
440
|
-
'Error: interface, access, autostate exclude not disabled')
|
383
|
+
i.switchport_autostate_exclude = default
|
384
|
+
assert_equal(default, i.switchport_autostate_exclude)
|
441
385
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
end
|
447
|
-
|
448
|
-
def test_switchport_autostate_trunk
|
449
|
-
interface.switchport_mode = :trunk
|
386
|
+
# trunk
|
387
|
+
i.switchport_mode = :trunk
|
388
|
+
i.switchport_autostate_exclude = true
|
389
|
+
assert(i.switchport_autostate_exclude)
|
450
390
|
|
451
|
-
|
452
|
-
|
391
|
+
i.switchport_autostate_exclude = false
|
392
|
+
refute(i.switchport_autostate_exclude)
|
453
393
|
|
454
|
-
|
455
|
-
|
456
|
-
'Error: interface, access, autostate exclude not enabled')
|
394
|
+
i.switchport_autostate_exclude = default
|
395
|
+
assert_equal(default, i.switchport_autostate_exclude)
|
457
396
|
|
458
|
-
|
459
|
-
refute(interface.switchport_autostate_exclude,
|
460
|
-
'Error: interface, access, autostate exclude not disabled')
|
461
|
-
|
462
|
-
result = interface.default_switchport_autostate_exclude
|
463
|
-
interface.switchport_autostate_exclude = result
|
464
|
-
assert_equal(result, interface.switchport_autostate_exclude,
|
465
|
-
'Error: interface, access, autostate exclude not disabled')
|
466
|
-
end
|
467
|
-
|
468
|
-
def test_switchport_autostate_unsupported_mode_disabled
|
397
|
+
# disabled
|
469
398
|
interface.switchport_mode = :disabled
|
470
|
-
|
471
399
|
assert_raises RuntimeError do
|
472
400
|
interface.switchport_autostate_exclude = true
|
473
401
|
end
|
474
|
-
assert_raises RuntimeError do
|
475
|
-
interface.switchport_autostate_exclude = false
|
476
|
-
end
|
477
|
-
end
|
478
402
|
|
479
|
-
def test_set_switchport_autostate_true_unsupported_mgmt_intf
|
480
|
-
interface = Interface.new(mgmt_intf)
|
481
403
|
assert_raises RuntimeError do
|
482
|
-
interface.switchport_autostate_exclude =
|
404
|
+
interface.switchport_autostate_exclude = false
|
483
405
|
end
|
484
406
|
end
|
485
407
|
end
|
@@ -487,7 +409,7 @@ end
|
|
487
409
|
# TestInterfaceSwitchportVtp
|
488
410
|
# Minitest for Interface switchport configuration in combo with Vtp class
|
489
411
|
# Not applicable to IOS XR
|
490
|
-
class
|
412
|
+
class TestInterfaceSwVtp < TestInterfaceSwitchport
|
491
413
|
attr_reader :vtp
|
492
414
|
|
493
415
|
def setup
|
@@ -501,131 +423,49 @@ class TestInterfaceSwitchportVtp < TestInterfaceSwitchport
|
|
501
423
|
super
|
502
424
|
end
|
503
425
|
|
504
|
-
def
|
505
|
-
|
506
|
-
'Error: interface, access, vtp not disabled')
|
507
|
-
end
|
508
|
-
|
509
|
-
def test_switchport_vtp_enabled_access
|
510
|
-
platform_supports_vtp_switchport_access?
|
511
|
-
interface.switchport_mode = :access
|
512
|
-
config("interface ethernet #{interfaces_id[0]}", 'vtp')
|
513
|
-
|
514
|
-
assert(interface.switchport_vtp,
|
515
|
-
'Error: interface, access, vtp not enabled')
|
516
|
-
end
|
517
|
-
|
518
|
-
def test_switchport_vtp_disabled_access
|
519
|
-
interface.switchport_mode = :access
|
520
|
-
config("interface ethernet #{interfaces_id[0]}", 'no vtp')
|
521
|
-
|
426
|
+
def test_mode_access
|
427
|
+
# Basic test
|
522
428
|
refute(interface.switchport_vtp,
|
523
429
|
'Error: interface, access, vtp not disabled')
|
524
|
-
end
|
525
|
-
|
526
|
-
def test_switchport_vtp_enabled_trunk
|
527
|
-
interface.switchport_mode = :trunk
|
528
|
-
config("interface ethernet #{interfaces_id[0]}", 'vtp')
|
529
|
-
|
530
|
-
assert(interface.switchport_vtp,
|
531
|
-
'Error: interface, trunk, vtp not enabled')
|
532
|
-
end
|
533
430
|
|
534
|
-
|
535
|
-
interface.switchport_mode = :trunk
|
536
|
-
refute(interface.switchport_vtp,
|
537
|
-
'Error: interface, trunk, vtp not disabled')
|
538
|
-
end
|
539
|
-
|
540
|
-
def test_set_switchport_vtp_default_access
|
431
|
+
# Now :access
|
541
432
|
platform_supports_vtp_switchport_access?
|
542
433
|
interface.switchport_mode = :access
|
543
434
|
|
544
|
-
|
545
|
-
|
546
|
-
'Error:(1) mode :access, vtp should be default (false)')
|
435
|
+
default = interface.default_switchport_vtp
|
436
|
+
assert_equal(default, interface.switchport_vtp)
|
547
437
|
|
548
438
|
interface.switchport_vtp = true
|
549
|
-
assert(interface.switchport_vtp
|
550
|
-
'Error:(2) mode :access, vtp should be true')
|
551
|
-
|
552
|
-
interface.switchport_vtp = interface.default_switchport_vtp
|
553
|
-
refute(interface.switchport_vtp,
|
554
|
-
'Error:(3) mode :access, vtp should be default (false)')
|
555
|
-
end
|
556
|
-
|
557
|
-
def test_set_switchport_vtp_default_trunk
|
558
|
-
interface.switchport_mode = :trunk
|
559
|
-
interface.switchport_vtp = interface.default_switchport_vtp
|
560
|
-
refute(interface.switchport_vtp,
|
561
|
-
'Error:(1) mode :trunk, vtp should be default (false)')
|
439
|
+
assert(interface.switchport_vtp)
|
562
440
|
|
563
|
-
interface.switchport_vtp =
|
564
|
-
|
565
|
-
'Error:(2) mode :trunk, vtp should be true')
|
441
|
+
interface.switchport_vtp = false
|
442
|
+
refute(interface.switchport_vtp)
|
566
443
|
|
567
|
-
interface.switchport_vtp =
|
568
|
-
|
569
|
-
'Error:(3) mode :trunk, vtp should be default (false)')
|
444
|
+
interface.switchport_vtp = default
|
445
|
+
assert_equal(default, interface.switchport_vtp)
|
570
446
|
end
|
571
447
|
|
572
|
-
def
|
448
|
+
def test_mode_trunk
|
573
449
|
platform_supports_vtp_switchport_access?
|
574
|
-
interface.switchport_mode = :access
|
575
|
-
interface.switchport_vtp = true
|
576
|
-
assert(interface.switchport_vtp,
|
577
|
-
'Error: interface, access, vtp not enabled')
|
578
|
-
end
|
579
|
-
|
580
|
-
def test_set_switchport_vtp_true_trunk
|
581
450
|
interface.switchport_mode = :trunk
|
582
|
-
interface.switchport_vtp = true
|
583
|
-
assert(interface.switchport_vtp,
|
584
|
-
'Error: interface, access, vtp not enabled')
|
585
|
-
end
|
586
451
|
|
587
|
-
|
588
|
-
interface.
|
589
|
-
refute(interface.switchport_vtp,
|
590
|
-
'Error: interface, access, vtp is enabled')
|
591
|
-
end
|
592
|
-
|
593
|
-
def test_set_switchport_vtp_true_unsupported_mgmt_intf
|
594
|
-
interface = Interface.new(mgmt_intf)
|
452
|
+
default = interface.default_switchport_vtp
|
453
|
+
assert_equal(default, interface.switchport_vtp)
|
595
454
|
|
596
455
|
interface.switchport_vtp = true
|
597
|
-
|
598
|
-
'Error: interface, access, vtp is enabled')
|
599
|
-
end
|
456
|
+
assert(interface.switchport_vtp)
|
600
457
|
|
601
|
-
def test_set_switchport_vtp_false_access
|
602
|
-
interface.switchport_mode = :access
|
603
458
|
interface.switchport_vtp = false
|
604
|
-
refute(interface.switchport_vtp
|
605
|
-
'Error: interface, access, vtp not disabled')
|
606
|
-
end
|
459
|
+
refute(interface.switchport_vtp)
|
607
460
|
|
608
|
-
|
609
|
-
interface.
|
610
|
-
interface.switchport_vtp = false
|
611
|
-
refute(interface.switchport_vtp,
|
612
|
-
'Error: interface, access, vtp not disabled')
|
461
|
+
interface.switchport_vtp = default
|
462
|
+
assert_equal(default, interface.switchport_vtp)
|
613
463
|
end
|
614
464
|
|
615
|
-
def
|
465
|
+
def test_mode_disabled
|
466
|
+
platform_supports_vtp_switchport_access?
|
616
467
|
interface.switchport_mode = :disabled
|
617
|
-
interface.switchport_vtp = false
|
618
468
|
refute(interface.switchport_vtp,
|
619
|
-
'Error:
|
620
|
-
end
|
621
|
-
|
622
|
-
def test_default_switchport_vtp
|
623
|
-
[:access, :disabled].each do |mode|
|
624
|
-
interface.switchport_mode = mode
|
625
|
-
interface.switchport_vtp = interface.default_switchport_vtp
|
626
|
-
assert_equal(interface.switchport_vtp, interface.default_switchport_vtp,
|
627
|
-
"Error: mode :#{mode}, "\
|
628
|
-
'switchport_vtp should equal default_switchport_vtp')
|
629
|
-
end
|
469
|
+
'Error: interface, access, vtp is enabled')
|
630
470
|
end
|
631
471
|
end
|