cisco_node_utils 1.3.0 → 1.4.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 +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_bdi.rb
CHANGED
|
@@ -19,7 +19,7 @@ require_relative '../lib/cisco_node_utils/bridge_domain'
|
|
|
19
19
|
include Cisco
|
|
20
20
|
|
|
21
21
|
# TestBdi - Minitest for Interface configuration of BDI interfaces.
|
|
22
|
-
class
|
|
22
|
+
class TestInterfaceBdi < CiscoTestCase
|
|
23
23
|
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
|
24
24
|
attr_reader :bdi
|
|
25
25
|
|
|
@@ -57,7 +57,7 @@ platform")
|
|
|
57
57
|
super
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
def
|
|
60
|
+
def test_bdi
|
|
61
61
|
# Check all the default values
|
|
62
62
|
assert_equal(@bdi.default_vrf, @bdi.vrf)
|
|
63
63
|
assert_equal(@bdi.default_ipv4_address, @bdi.ipv4_address)
|
|
@@ -16,7 +16,7 @@ require_relative 'ciscotest'
|
|
|
16
16
|
require_relative '../lib/cisco_node_utils/interface_channel_group'
|
|
17
17
|
|
|
18
18
|
# TestInterface - Minitest for general functionality of the Interface class.
|
|
19
|
-
class
|
|
19
|
+
class TestInterfaceChanGrp < CiscoTestCase
|
|
20
20
|
@@clean = false # rubocop:disable Style/ClassVars
|
|
21
21
|
def setup
|
|
22
22
|
super
|
|
@@ -138,6 +138,30 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
138
138
|
'dead_interval'),
|
|
139
139
|
interface.dead_interval,
|
|
140
140
|
'Error: get dead interval failed')
|
|
141
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
142
|
+
'bfd'),
|
|
143
|
+
interface.bfd,
|
|
144
|
+
'Error: bfd get failed')
|
|
145
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
146
|
+
'mtu_ignore'),
|
|
147
|
+
interface.mtu_ignore,
|
|
148
|
+
'Error: mtu_ignore get failed')
|
|
149
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
150
|
+
'priority'),
|
|
151
|
+
interface.priority,
|
|
152
|
+
'Error: priority get failed')
|
|
153
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
154
|
+
'network_type_default'),
|
|
155
|
+
interface.network_type,
|
|
156
|
+
'Error: network type get failed')
|
|
157
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
158
|
+
'shutdown'),
|
|
159
|
+
interface.shutdown,
|
|
160
|
+
'Error: shutdown get failed')
|
|
161
|
+
assert_equal(node.config_get_default('interface_ospf',
|
|
162
|
+
'transmit_delay'),
|
|
163
|
+
interface.transmit_delay,
|
|
164
|
+
'Error: transmit_delay get failed')
|
|
141
165
|
assert_equal(node.config_get_default('interface_ospf',
|
|
142
166
|
'passive_interface'),
|
|
143
167
|
interface.passive_interface,
|
|
@@ -154,13 +178,13 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
154
178
|
end
|
|
155
179
|
end
|
|
156
180
|
|
|
157
|
-
def
|
|
181
|
+
def test_routerospf_nil
|
|
158
182
|
assert_raises(TypeError) do
|
|
159
183
|
InterfaceOspf.new(interfaces[0], nil, '0.0.0.0')
|
|
160
184
|
end
|
|
161
185
|
end
|
|
162
186
|
|
|
163
|
-
def
|
|
187
|
+
def test_name_zero_length
|
|
164
188
|
name = 'ospfTest'
|
|
165
189
|
ospf = RouterOspf.new(name)
|
|
166
190
|
assert_raises(ArgumentError) do
|
|
@@ -168,7 +192,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
168
192
|
end
|
|
169
193
|
end
|
|
170
194
|
|
|
171
|
-
def
|
|
195
|
+
def test_area_zero_length
|
|
172
196
|
name = 'ospfTest'
|
|
173
197
|
ospf = RouterOspf.new(name)
|
|
174
198
|
assert_raises(ArgumentError) do
|
|
@@ -176,7 +200,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
176
200
|
end
|
|
177
201
|
end
|
|
178
202
|
|
|
179
|
-
def
|
|
203
|
+
def test_routerospf
|
|
180
204
|
ospf = create_routerospf
|
|
181
205
|
ifname = interfaces[1]
|
|
182
206
|
area = '0.0.0.0'
|
|
@@ -211,17 +235,35 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
211
235
|
refute_show_match(pattern: /^\s+ip ospf dead-interval \S+/,
|
|
212
236
|
msg: "'dead-interval' not removed")
|
|
213
237
|
|
|
238
|
+
refute_show_match(pattern: /^\s+ip ospf bfd \S+/,
|
|
239
|
+
msg: "'bfd' not removed")
|
|
240
|
+
|
|
241
|
+
refute_show_match(pattern: /^\s+ip ospf mtu-ignore \S+/,
|
|
242
|
+
msg: "'mtu_ignore' not removed")
|
|
243
|
+
|
|
244
|
+
refute_show_match(pattern: /^\s+ip ospf shutdown \S+/,
|
|
245
|
+
msg: "'shutdown' not removed")
|
|
246
|
+
|
|
247
|
+
refute_show_match(pattern: /^\s+ip ospf transmit-delay \S+/,
|
|
248
|
+
msg: "'transmit_delay' not removed")
|
|
249
|
+
|
|
250
|
+
refute_show_match(pattern: /^\s+ip ospf priority \S+/,
|
|
251
|
+
msg: "'priority' not removed")
|
|
252
|
+
|
|
253
|
+
refute_show_match(pattern: /^\s+ip ospf network point-to-point/,
|
|
254
|
+
msg: "'network_type' not removed")
|
|
255
|
+
|
|
214
256
|
refute_show_match(pattern: /^\s+ip ospf passive-interface/,
|
|
215
257
|
msg: "'passive interface' not removed")
|
|
216
258
|
end
|
|
217
259
|
|
|
218
|
-
def
|
|
260
|
+
def test_get_parent
|
|
219
261
|
ospf = create_routerospf
|
|
220
262
|
interface = create_interfaceospf(ospf)
|
|
221
263
|
assert_equal(ospf.name, interface.ospf_name)
|
|
222
264
|
end
|
|
223
265
|
|
|
224
|
-
def
|
|
266
|
+
def test_cost_inv
|
|
225
267
|
ospf = create_routerospf
|
|
226
268
|
interface = create_interfaceospf(ospf)
|
|
227
269
|
# upper range
|
|
@@ -250,7 +292,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
250
292
|
msg: 'Error: default cost set failed')
|
|
251
293
|
end
|
|
252
294
|
|
|
253
|
-
def
|
|
295
|
+
def test_hello_inv
|
|
254
296
|
ospf = create_routerospf
|
|
255
297
|
interface = create_interfaceospf(ospf)
|
|
256
298
|
# upper range
|
|
@@ -263,7 +305,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
263
305
|
end
|
|
264
306
|
end
|
|
265
307
|
|
|
266
|
-
def
|
|
308
|
+
def test_hello
|
|
267
309
|
ospf = create_routerospf
|
|
268
310
|
interface = create_interfaceospf(ospf)
|
|
269
311
|
interval = 90
|
|
@@ -280,7 +322,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
280
322
|
msg: 'Error: default hello-interval set failed')
|
|
281
323
|
end
|
|
282
324
|
|
|
283
|
-
def
|
|
325
|
+
def test_dead_inv
|
|
284
326
|
ospf = create_routerospf
|
|
285
327
|
interface = create_interfaceospf(ospf)
|
|
286
328
|
|
|
@@ -297,7 +339,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
297
339
|
end
|
|
298
340
|
end
|
|
299
341
|
|
|
300
|
-
def
|
|
342
|
+
def test_dead
|
|
301
343
|
ospf = create_routerospf
|
|
302
344
|
interface = create_interfaceospf(ospf)
|
|
303
345
|
interval = 150
|
|
@@ -314,7 +356,51 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
314
356
|
msg: 'Error: default dead-interval set failed')
|
|
315
357
|
end
|
|
316
358
|
|
|
317
|
-
def
|
|
359
|
+
def test_bfd
|
|
360
|
+
ospf = create_routerospf
|
|
361
|
+
interface = create_interfaceospf(ospf)
|
|
362
|
+
assert_equal(interface.default_bfd, interface.bfd)
|
|
363
|
+
interface.bfd = true
|
|
364
|
+
assert_equal(true, interface.bfd)
|
|
365
|
+
interface.bfd = false
|
|
366
|
+
assert_equal(false, interface.bfd)
|
|
367
|
+
interface.bfd = interface.default_bfd
|
|
368
|
+
assert_equal(interface.default_bfd, interface.bfd)
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
def test_mtu_ignore
|
|
372
|
+
ospf = create_routerospf
|
|
373
|
+
interface = create_interfaceospf(ospf)
|
|
374
|
+
assert_equal(interface.default_mtu_ignore, interface.mtu_ignore)
|
|
375
|
+
interface.mtu_ignore = true
|
|
376
|
+
assert_equal(true, interface.mtu_ignore)
|
|
377
|
+
interface.mtu_ignore = interface.default_mtu_ignore
|
|
378
|
+
assert_equal(interface.default_mtu_ignore, interface.mtu_ignore)
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def test_network_type
|
|
382
|
+
ospf = create_routerospf
|
|
383
|
+
interface = create_interfaceospf(ospf)
|
|
384
|
+
|
|
385
|
+
assert_equal(interface.default_network_type, interface.network_type)
|
|
386
|
+
interface.network_type = 'p2p'
|
|
387
|
+
assert_equal('p2p', interface.network_type)
|
|
388
|
+
interface.network_type = interface.default_network_type
|
|
389
|
+
assert_equal(interface.default_network_type, interface.network_type)
|
|
390
|
+
|
|
391
|
+
# setup a loopback to use
|
|
392
|
+
config('interface loopback12')
|
|
393
|
+
interface = InterfaceOspf.new('loopback12', '12', '0.0.0.0')
|
|
394
|
+
assert_equal(interface.default_network_type, interface.network_type)
|
|
395
|
+
interface.network_type = 'p2p'
|
|
396
|
+
assert_equal('p2p', interface.network_type)
|
|
397
|
+
interface.network_type = interface.default_network_type
|
|
398
|
+
assert_equal(interface.default_network_type, interface.network_type)
|
|
399
|
+
# cleanup
|
|
400
|
+
config('no interface loopback12')
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def test_passive
|
|
318
404
|
ospf = create_routerospf
|
|
319
405
|
interface = create_interfaceospf(ospf)
|
|
320
406
|
|
|
@@ -331,7 +417,37 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
331
417
|
msg: 'default passive interface set failed')
|
|
332
418
|
end
|
|
333
419
|
|
|
334
|
-
def
|
|
420
|
+
def test_priority
|
|
421
|
+
ospf = create_routerospf
|
|
422
|
+
interface = create_interfaceospf(ospf)
|
|
423
|
+
assert_equal(interface.default_priority, interface.priority)
|
|
424
|
+
interface.priority = 100
|
|
425
|
+
assert_equal(100, interface.priority)
|
|
426
|
+
interface.priority = interface.default_priority
|
|
427
|
+
assert_equal(interface.default_priority, interface.priority)
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
def test_shutdown
|
|
431
|
+
ospf = create_routerospf
|
|
432
|
+
interface = create_interfaceospf(ospf)
|
|
433
|
+
assert_equal(interface.default_shutdown, interface.shutdown)
|
|
434
|
+
interface.shutdown = true
|
|
435
|
+
assert_equal(true, interface.shutdown)
|
|
436
|
+
interface.shutdown = interface.default_shutdown
|
|
437
|
+
assert_equal(interface.default_shutdown, interface.shutdown)
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def test_transmit_delay
|
|
441
|
+
ospf = create_routerospf
|
|
442
|
+
interface = create_interfaceospf(ospf)
|
|
443
|
+
assert_equal(interface.default_transmit_delay, interface.transmit_delay)
|
|
444
|
+
interface.transmit_delay = 400
|
|
445
|
+
assert_equal(400, interface.transmit_delay)
|
|
446
|
+
interface.transmit_delay = interface.default_transmit_delay
|
|
447
|
+
assert_equal(interface.default_transmit_delay, interface.transmit_delay)
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
def test_mult
|
|
335
451
|
# ospf and interfaces[0]
|
|
336
452
|
ospf = create_routerospf
|
|
337
453
|
interface = create_interfaceospf(ospf)
|
|
@@ -339,7 +455,6 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
339
455
|
pattern: /\s+ip router ospf #{ospf.name} area #{interface.area}/,
|
|
340
456
|
msg: "'ip router ospf #{ospf.name} default area' not configured")
|
|
341
457
|
|
|
342
|
-
# ospf and interfaces_id[2]
|
|
343
458
|
ifname = interfaces[2]
|
|
344
459
|
area = '1.1.1.1'
|
|
345
460
|
create_interfaceospf(ospf, ifname, area)
|
|
@@ -348,12 +463,11 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
348
463
|
msg: "'ip router ospf #{ospf.name} area #{area}' is not configured")
|
|
349
464
|
end
|
|
350
465
|
|
|
351
|
-
def
|
|
466
|
+
def test_mult_delete_one
|
|
352
467
|
# ospf and interfaces[0]
|
|
353
468
|
ospf = create_routerospf
|
|
354
469
|
interface = create_interfaceospf(ospf)
|
|
355
470
|
|
|
356
|
-
# ospf and interfaces_id[2]
|
|
357
471
|
ifname = interfaces[2]
|
|
358
472
|
area = '1.1.1.1'
|
|
359
473
|
interface1 = create_interfaceospf(ospf, ifname, area)
|
|
@@ -361,7 +475,6 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
361
475
|
"Error: 'ip router ospf #{ospf.name} area #{area}' " \
|
|
362
476
|
'not configured')
|
|
363
477
|
|
|
364
|
-
# delete ospf instance from interfaces_id[2]
|
|
365
478
|
interface1.destroy
|
|
366
479
|
refute_show_match(
|
|
367
480
|
command: show_cmd(ifname),
|
|
@@ -389,9 +502,14 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
389
502
|
end
|
|
390
503
|
# puts "k1: #{k1}, k: #{k}, area #{v1[:area]}"
|
|
391
504
|
cfg << "ip router ospf #{k} area #{v1[:area]}"
|
|
505
|
+
cfg << 'ip ospf bfd' if v1[:bfd]
|
|
506
|
+
cfg << 'ip ospf bfd disable' if v1[:bfd] == false
|
|
507
|
+
cfg << 'no ip ospf bfd' if v1[:bfd].nil?
|
|
392
508
|
cfg << "ip ospf cost #{v1[:cost]}" unless v1[:cost] == 0
|
|
393
509
|
cfg << "ip ospf hello-interval #{v1[:hello]}" unless v1[:hello].nil?
|
|
394
510
|
cfg << "ip ospf dead-interval #{v1[:dead]}" unless v1[:dead].nil?
|
|
511
|
+
cfg << 'ip ospf network point-to-point' if v1[:net] == 'p2p'
|
|
512
|
+
cfg << 'no ip ospf network' if v1[:net] == 'broadcast'
|
|
395
513
|
cfg << 'ip ospf passive-interface' if !v1[:pass].nil? &&
|
|
396
514
|
v1[:pass] == true
|
|
397
515
|
config(*cfg)
|
|
@@ -404,37 +522,44 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
404
522
|
hash = {
|
|
405
523
|
'ospfTest' => {
|
|
406
524
|
interfaces[0].downcase => {
|
|
407
|
-
area: '0.0.0.0', cost: 10, hello: 30,
|
|
525
|
+
area: '0.0.0.0', bfd: true, cost: 10, hello: 30,
|
|
526
|
+
dead: 120, net: 'p2p', pass: true },
|
|
408
527
|
interfaces[1].downcase => {
|
|
409
|
-
area: '1.1.1.38', dead: 40, pass: false },
|
|
528
|
+
area: '1.1.1.38', bfd: false, dead: 40, net: 'p2p', pass: false },
|
|
410
529
|
'vlan101' => {
|
|
411
|
-
area: '2.2.2.101', cost: 5, hello: 20, dead: 80,
|
|
530
|
+
area: '2.2.2.101', bfd: true, cost: 5, hello: 20, dead: 80,
|
|
531
|
+
net: 'p2p', pass: true },
|
|
412
532
|
},
|
|
413
533
|
'TestOspfInt' => {
|
|
414
534
|
interfaces[2].downcase => {
|
|
415
535
|
area: '0.0.0.19' },
|
|
416
536
|
'vlan290' => {
|
|
417
|
-
area: '2.2.2.29', cost: 200, hello: 30,
|
|
537
|
+
area: '2.2.2.29', bfd: true, cost: 200, hello: 30,
|
|
538
|
+
dead: 120, net: 'broadcast', pass: true },
|
|
418
539
|
'port-channel100' => {
|
|
419
|
-
area: '3.2.2.29', cost: 25, hello: 50, dead: 200,
|
|
540
|
+
area: '3.2.2.29', bfd: false, cost: 25, hello: 50, dead: 200,
|
|
541
|
+
net: 'p2p', pass: false },
|
|
420
542
|
},
|
|
421
543
|
}
|
|
422
544
|
# rubocop:enable Style/AlignHash
|
|
423
545
|
# Set defaults
|
|
424
546
|
hash.each_key do |name|
|
|
425
547
|
hash[name].each_value do |hv|
|
|
548
|
+
hv[:bfd] ||= node.config_get_default('interface_ospf', 'bfd')
|
|
426
549
|
hv[:cost] ||= node.config_get_default('interface_ospf', 'cost')
|
|
427
550
|
hv[:hello] ||= node.config_get_default('interface_ospf',
|
|
428
551
|
'hello_interval')
|
|
429
552
|
hv[:dead] ||= node.config_get_default('interface_ospf',
|
|
430
553
|
'dead_interval')
|
|
554
|
+
hv[:net] ||= node.config_get_default('interface_ospf',
|
|
555
|
+
'network_type_default')
|
|
431
556
|
hv[:pass] ||= node.config_get_default('interface_ospf',
|
|
432
557
|
'passive_interface')
|
|
433
558
|
end
|
|
434
559
|
end
|
|
435
560
|
end
|
|
436
561
|
|
|
437
|
-
def
|
|
562
|
+
def test_collect_mult_intf
|
|
438
563
|
s = config('int port-channel 42', 'descr foo')
|
|
439
564
|
known_failure = s[/ERROR:.*port channel not present/]
|
|
440
565
|
refute(known_failure, 'ERROR: port channel not present')
|
|
@@ -444,6 +569,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
444
569
|
# enable feature ospf
|
|
445
570
|
config('no feature ospf',
|
|
446
571
|
'feature ospf',
|
|
572
|
+
'feature bfd',
|
|
447
573
|
'feature interface-vlan',
|
|
448
574
|
"default interface #{interfaces[0]}",
|
|
449
575
|
"default interface #{interfaces[1]}",
|
|
@@ -471,11 +597,14 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
471
597
|
msg: "Error: ip router ospf #{name} area #{hv[:area]} "\
|
|
472
598
|
"not found under #{ifname}")
|
|
473
599
|
|
|
600
|
+
assert_equal(hv[:bfd], interface.bfd, 'Error: get bfd failed')
|
|
474
601
|
assert_equal(hv[:cost], interface.cost, 'Error: get cost failed')
|
|
475
602
|
assert_equal(hv[:hello], interface.hello_interval,
|
|
476
603
|
'Error: get hello interval failed')
|
|
477
604
|
assert_equal(hv[:dead], interface.dead_interval,
|
|
478
605
|
'Error: get dead interval failed')
|
|
606
|
+
assert_equal(hv[:net], interface.network_type,
|
|
607
|
+
'Error: network_type get failed')
|
|
479
608
|
assert_equal(hv[:pass], interface.passive_interface,
|
|
480
609
|
'Error: passive interface get failed')
|
|
481
610
|
end
|
|
@@ -484,6 +613,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
484
613
|
|
|
485
614
|
# disable feature interface-vlan
|
|
486
615
|
config('no feature interface-vlan')
|
|
616
|
+
config('no feature bfd')
|
|
487
617
|
# clean up port channel
|
|
488
618
|
ospf_h.each_value do |v|
|
|
489
619
|
v.each_key do |k1|
|
|
@@ -577,7 +707,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
577
707
|
assert_equal(encr, interface.message_digest_encryption_type)
|
|
578
708
|
end
|
|
579
709
|
|
|
580
|
-
def
|
|
710
|
+
def test_message_digest_key_inv
|
|
581
711
|
ospf = create_routerospf
|
|
582
712
|
interface = create_interfaceospf(ospf)
|
|
583
713
|
|
|
@@ -41,7 +41,16 @@ class TestInterfacePortChannel < CiscoTestCase
|
|
|
41
41
|
InterfacePortChannel.new(ifname)
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
def
|
|
44
|
+
def test_bfd_per_link
|
|
45
|
+
interface = create_port_channel
|
|
46
|
+
assert_equal(interface.default_bfd_per_link, interface.bfd_per_link)
|
|
47
|
+
interface.bfd_per_link = true
|
|
48
|
+
assert_equal(true, interface.bfd_per_link)
|
|
49
|
+
interface.bfd_per_link = interface.default_bfd_per_link
|
|
50
|
+
assert_equal(interface.default_bfd_per_link, interface.bfd_per_link)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_port_hash_distribution
|
|
45
54
|
skip('Platform does not support this property') if n6k_platform?
|
|
46
55
|
interface = create_port_channel
|
|
47
56
|
interface.port_hash_distribution = 'adaptive'
|
|
@@ -54,7 +63,7 @@ class TestInterfacePortChannel < CiscoTestCase
|
|
|
54
63
|
interface.port_hash_distribution)
|
|
55
64
|
end
|
|
56
65
|
|
|
57
|
-
def
|
|
66
|
+
def test_lacp_graceful_convergence
|
|
58
67
|
interface = create_port_channel
|
|
59
68
|
interface.lacp_graceful_convergence = false
|
|
60
69
|
assert_equal(false, interface.lacp_graceful_convergence)
|
|
@@ -64,7 +73,7 @@ class TestInterfacePortChannel < CiscoTestCase
|
|
|
64
73
|
interface.lacp_graceful_convergence)
|
|
65
74
|
end
|
|
66
75
|
|
|
67
|
-
def
|
|
76
|
+
def test_lacp_min_links
|
|
68
77
|
interface = create_port_channel
|
|
69
78
|
interface.lacp_min_links = 5
|
|
70
79
|
assert_equal(5, interface.lacp_min_links)
|
|
@@ -73,7 +82,7 @@ class TestInterfacePortChannel < CiscoTestCase
|
|
|
73
82
|
interface.lacp_min_links)
|
|
74
83
|
end
|
|
75
84
|
|
|
76
|
-
def
|
|
85
|
+
def test_lacp_max_bundle
|
|
77
86
|
interface = create_port_channel
|
|
78
87
|
interface.lacp_max_bundle = 10
|
|
79
88
|
assert_equal(10, interface.lacp_max_bundle)
|
|
@@ -83,7 +92,7 @@ class TestInterfacePortChannel < CiscoTestCase
|
|
|
83
92
|
interface.lacp_max_bundle)
|
|
84
93
|
end
|
|
85
94
|
|
|
86
|
-
def
|
|
95
|
+
def test_lacp_suspend_individual
|
|
87
96
|
interface = create_port_channel
|
|
88
97
|
interface.lacp_suspend_individual = false
|
|
89
98
|
assert_equal(false, interface.lacp_suspend_individual)
|
|
@@ -93,7 +102,7 @@ class TestInterfacePortChannel < CiscoTestCase
|
|
|
93
102
|
interface.lacp_suspend_individual)
|
|
94
103
|
end
|
|
95
104
|
|
|
96
|
-
def
|
|
105
|
+
def test_port_load_defer
|
|
97
106
|
skip('Platform does not support this property') if n6k_platform?
|
|
98
107
|
interface = create_port_channel
|
|
99
108
|
interface.port_load_defer = true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c)
|
|
1
|
+
# Copyright (c) 2016 Cisco and/or its affiliates.
|
|
2
2
|
#
|
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
# you may not use this file except in compliance with the License.
|
|
@@ -18,18 +18,25 @@ require_relative '../lib/cisco_node_utils/vlan'
|
|
|
18
18
|
|
|
19
19
|
include Cisco
|
|
20
20
|
|
|
21
|
-
#
|
|
21
|
+
# TestInterfacePrivateVlan
|
|
22
22
|
# Parent class for specific types of switchport tests (below)
|
|
23
|
-
class
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
class TestInterfacePVlan < CiscoTestCase
|
|
24
|
+
# rubocop:disable Style/ClassVars
|
|
25
|
+
@@pre_clean_needed = true
|
|
26
|
+
attr_reader :i
|
|
27
|
+
|
|
28
|
+
def i
|
|
29
|
+
@@interface
|
|
30
|
+
end
|
|
26
31
|
|
|
27
32
|
def setup
|
|
28
33
|
super
|
|
29
|
-
|
|
30
|
-
cleanup
|
|
31
|
-
@@
|
|
34
|
+
return unless @@pre_clean_needed
|
|
35
|
+
cleanup
|
|
36
|
+
@@interface = Interface.new(interfaces[0])
|
|
37
|
+
@@pre_clean_needed = false
|
|
32
38
|
end
|
|
39
|
+
# rubocop:enable Style/ClassVars
|
|
33
40
|
|
|
34
41
|
def teardown
|
|
35
42
|
cleanup
|
|
@@ -37,688 +44,305 @@ class TestInterfaceSwitchport < CiscoTestCase
|
|
|
37
44
|
end
|
|
38
45
|
|
|
39
46
|
def cleanup
|
|
40
|
-
|
|
41
|
-
cleanup_pvlan_intfs
|
|
47
|
+
interface_cleanup_pvlan
|
|
42
48
|
remove_all_vlans
|
|
43
49
|
config_no_warn('no feature private-vlan', 'no feature vtp')
|
|
44
50
|
end
|
|
45
51
|
|
|
46
|
-
def
|
|
47
|
-
Interface.interfaces
|
|
48
|
-
next unless name[/vlan/] || name.match(/^vlan1$/)
|
|
49
|
-
config("no interface #{name}")
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def cleanup_pvlan_intfs
|
|
54
|
-
pvlan_intfs = Interface.interfaces(:private_vlan_any)
|
|
52
|
+
def interface_cleanup_pvlan
|
|
53
|
+
pvlan_intfs = Interface.interfaces(:pvlan_any)
|
|
55
54
|
pvlan_intfs.keys.each { |name| interface_cleanup(name) }
|
|
56
55
|
end
|
|
57
|
-
end
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if validate_property_excluded?('interface',
|
|
63
|
-
'switchport_mode_private_vlan_host')
|
|
57
|
+
def test_pvlan_mapping
|
|
58
|
+
# This is an SVI property
|
|
59
|
+
svi = Interface.new('vlan13')
|
|
60
|
+
if validate_property_excluded?('interface', 'pvlan_mapping')
|
|
64
61
|
assert_raises(Cisco::UnsupportedError) do
|
|
65
|
-
|
|
62
|
+
svi.pvlan_mapping = ['10-11,4-7,8']
|
|
66
63
|
end
|
|
67
64
|
return
|
|
68
65
|
end
|
|
69
|
-
switchport_modes = [
|
|
70
|
-
:host,
|
|
71
|
-
:promiscuous,
|
|
72
|
-
]
|
|
73
|
-
|
|
74
|
-
switchport_modes.each do |start|
|
|
75
|
-
interface.switchport_mode_private_vlan_host = start
|
|
76
|
-
assert_equal(start, interface.switchport_mode_private_vlan_host,
|
|
77
|
-
"Err: Switchport mode, #{start}, not as expected")
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
66
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
'interface',
|
|
84
|
-
'switchport_mode_private_vlan_trunk_secondary')
|
|
85
|
-
assert_raises(Cisco::UnsupportedError) do
|
|
86
|
-
interface.switchport_mode_private_vlan_trunk_promiscuous = true
|
|
87
|
-
end
|
|
88
|
-
return
|
|
89
|
-
end
|
|
90
|
-
interface.switchport_mode_private_vlan_trunk_promiscuous = true
|
|
91
|
-
assert(interface.switchport_mode_private_vlan_trunk_promiscuous,
|
|
92
|
-
'Err: Switchport mode, not as expected')
|
|
93
|
-
end
|
|
67
|
+
default = svi.default_pvlan_mapping
|
|
68
|
+
assert_equal(default, svi.pvlan_mapping)
|
|
94
69
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
'switchport_mode_private_vlan_trunk_secondary')
|
|
99
|
-
assert_raises(Cisco::UnsupportedError) do
|
|
100
|
-
interface.switchport_mode_private_vlan_trunk_secondary = true
|
|
101
|
-
end
|
|
102
|
-
return
|
|
103
|
-
end
|
|
104
|
-
interface.switchport_mode_private_vlan_trunk_secondary = true
|
|
105
|
-
assert(interface.switchport_mode_private_vlan_trunk_secondary,
|
|
106
|
-
'Err: Switchport mode, not as expected')
|
|
107
|
-
end
|
|
70
|
+
# Input can be Array or String
|
|
71
|
+
svi.pvlan_mapping = ['10-11,4-7,8']
|
|
72
|
+
assert_equal(['4-8,10-11'], svi.pvlan_mapping)
|
|
108
73
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
assert_raises(Cisco::UnsupportedError) do
|
|
113
|
-
interface.switchport_mode_private_vlan_host = :host
|
|
114
|
-
end
|
|
115
|
-
return
|
|
116
|
-
end
|
|
117
|
-
switchport_modes = [
|
|
118
|
-
:host,
|
|
119
|
-
:promiscuous,
|
|
120
|
-
]
|
|
121
|
-
|
|
122
|
-
switchport_modes.each do |start|
|
|
123
|
-
interface.switchport_mode_private_vlan_host = start
|
|
124
|
-
assert_equal(start, interface.switchport_mode_private_vlan_host,
|
|
125
|
-
"Err: Switchport mode, #{start}, not as expected")
|
|
126
|
-
interface.switchport_mode_private_vlan_host = :disabled
|
|
127
|
-
assert_equal(:disabled, interface.switchport_mode_private_vlan_host,
|
|
128
|
-
'Error: Switchport mode not disabled')
|
|
129
|
-
end
|
|
130
|
-
end
|
|
74
|
+
# Change range
|
|
75
|
+
svi.pvlan_mapping = '11,4-6,8'
|
|
76
|
+
assert_equal(['4-6,8,11'], svi.pvlan_mapping)
|
|
131
77
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
'interface',
|
|
135
|
-
'switchport_mode_private_vlan_trunk_secondary')
|
|
136
|
-
assert_raises(Cisco::UnsupportedError) do
|
|
137
|
-
interface.switchport_mode_private_vlan_trunk_secondary = true
|
|
138
|
-
end
|
|
139
|
-
return
|
|
140
|
-
end
|
|
141
|
-
interface.switchport_mode_private_vlan_trunk_secondary = true
|
|
142
|
-
assert(interface.switchport_mode_private_vlan_trunk_secondary,
|
|
143
|
-
'Err: Switchport mode not as expected')
|
|
144
|
-
interface.switchport_mode_private_vlan_trunk_secondary = false
|
|
145
|
-
refute(interface.switchport_mode_private_vlan_trunk_secondary,
|
|
146
|
-
'Err: Switchport mode not disabled')
|
|
78
|
+
svi.pvlan_mapping = default
|
|
79
|
+
assert_equal(default, svi.pvlan_mapping)
|
|
147
80
|
end
|
|
148
81
|
|
|
149
|
-
def
|
|
82
|
+
def test_switchport_pvlan_host
|
|
150
83
|
if validate_property_excluded?('interface',
|
|
151
|
-
'
|
|
84
|
+
'switchport_pvlan_host')
|
|
152
85
|
assert_raises(Cisco::UnsupportedError) do
|
|
153
|
-
|
|
86
|
+
i.switchport_pvlan_host = true
|
|
154
87
|
end
|
|
155
88
|
return
|
|
156
89
|
end
|
|
157
|
-
v1 = Vlan.new(10)
|
|
158
|
-
v1.private_vlan_type = 'primary'
|
|
159
|
-
v2 = Vlan.new(11)
|
|
160
|
-
v2.private_vlan_type = 'community'
|
|
161
|
-
v1.private_vlan_association = ['11']
|
|
162
|
-
|
|
163
|
-
interface.switchport_mode_private_vlan_host = :host
|
|
164
|
-
assert_equal(:host, interface.switchport_mode_private_vlan_host,
|
|
165
|
-
'Err: Switchport mode not as expected')
|
|
166
|
-
|
|
167
|
-
input = %w(10 11)
|
|
168
|
-
|
|
169
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
170
|
-
assert_equal(input,
|
|
171
|
-
interface.switchport_mode_private_vlan_host_association,
|
|
172
|
-
'Err: switchport private host_association not configured')
|
|
173
|
-
end
|
|
174
90
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
'switchport_mode_private_vlan_host')
|
|
178
|
-
assert_raises(Cisco::UnsupportedError) do
|
|
179
|
-
interface.switchport_mode_private_vlan_host = :host
|
|
180
|
-
end
|
|
181
|
-
return
|
|
182
|
-
end
|
|
183
|
-
v1 = Vlan.new(10)
|
|
184
|
-
v1.private_vlan_type = 'primary'
|
|
185
|
-
v2 = Vlan.new(11)
|
|
186
|
-
v2.private_vlan_type = 'community'
|
|
187
|
-
v1.private_vlan_association = ['11']
|
|
188
|
-
|
|
189
|
-
interface.switchport_mode_private_vlan_host = :host
|
|
190
|
-
assert_equal(:host, interface.switchport_mode_private_vlan_host,
|
|
191
|
-
'Error: Switchport mode not as expected')
|
|
192
|
-
|
|
193
|
-
input = %w(10 11)
|
|
194
|
-
|
|
195
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
196
|
-
assert_equal(input,
|
|
197
|
-
interface.switchport_mode_private_vlan_host_association,
|
|
198
|
-
'Err: switchport private host_association not configured')
|
|
199
|
-
|
|
200
|
-
v3 = Vlan.new(20)
|
|
201
|
-
v3.private_vlan_type = 'primary'
|
|
202
|
-
|
|
203
|
-
v4 = Vlan.new(21)
|
|
204
|
-
v4.private_vlan_type = 'community'
|
|
205
|
-
v3.private_vlan_association = ['21']
|
|
206
|
-
|
|
207
|
-
input = %w(20 21)
|
|
208
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
209
|
-
assert_equal(input,
|
|
210
|
-
interface.switchport_mode_private_vlan_host_association,
|
|
211
|
-
'Err: switchport private host_association not configured')
|
|
212
|
-
|
|
213
|
-
input = []
|
|
214
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
215
|
-
assert_equal(input,
|
|
216
|
-
interface.switchport_mode_private_vlan_host_association,
|
|
217
|
-
'Err: switchport private host_association not configured')
|
|
218
|
-
end
|
|
91
|
+
assert_equal(i.default_switchport_pvlan_host,
|
|
92
|
+
i.switchport_pvlan_host)
|
|
219
93
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
'switchport_mode_private_vlan_host')
|
|
94
|
+
i.switchport_pvlan_host = true
|
|
95
|
+
assert(i.switchport_pvlan_host)
|
|
223
96
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
end
|
|
227
|
-
return
|
|
228
|
-
end
|
|
229
|
-
v1 = Vlan.new(10)
|
|
230
|
-
v1.private_vlan_type = 'primary'
|
|
231
|
-
v2 = Vlan.new(11)
|
|
232
|
-
v2.private_vlan_type = 'community'
|
|
233
|
-
v1.private_vlan_association = ['11']
|
|
234
|
-
|
|
235
|
-
input = %w(10 11)
|
|
236
|
-
interface.switchport_mode_private_vlan_host = :host
|
|
237
|
-
assert_equal(:host, interface.switchport_mode_private_vlan_host,
|
|
238
|
-
'Err: Switchport mode not as expected')
|
|
239
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
240
|
-
assert_equal(input,
|
|
241
|
-
interface.switchport_mode_private_vlan_host_association,
|
|
242
|
-
'Err: switchport private host_association not configured')
|
|
243
|
-
input = []
|
|
244
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
245
|
-
assert_equal(input,
|
|
246
|
-
interface.switchport_mode_private_vlan_host_association,
|
|
247
|
-
'Err: switchport private host_association not configured')
|
|
97
|
+
i.switchport_pvlan_host = false
|
|
98
|
+
refute(i.switchport_pvlan_host)
|
|
248
99
|
end
|
|
249
100
|
|
|
250
|
-
def
|
|
101
|
+
def test_sw_pvlan_promiscuous
|
|
251
102
|
if validate_property_excluded?('interface',
|
|
252
|
-
'
|
|
253
|
-
|
|
103
|
+
'switchport_pvlan_promiscuous')
|
|
254
104
|
assert_raises(Cisco::UnsupportedError) do
|
|
255
|
-
|
|
105
|
+
i.switchport_pvlan_promiscuous = true
|
|
256
106
|
end
|
|
257
107
|
return
|
|
258
108
|
end
|
|
259
|
-
|
|
260
|
-
assert_equal(
|
|
261
|
-
|
|
109
|
+
|
|
110
|
+
assert_equal(i.default_switchport_pvlan_promiscuous,
|
|
111
|
+
i.switchport_pvlan_promiscuous)
|
|
112
|
+
|
|
113
|
+
i.switchport_pvlan_promiscuous = true
|
|
114
|
+
assert(i.switchport_pvlan_promiscuous)
|
|
115
|
+
|
|
116
|
+
i.switchport_pvlan_promiscuous = false
|
|
117
|
+
refute(i.switchport_pvlan_promiscuous)
|
|
262
118
|
end
|
|
263
119
|
|
|
264
|
-
def
|
|
120
|
+
def test_sw_pvlan_trunk_promiscuous
|
|
265
121
|
if validate_property_excluded?('interface',
|
|
266
|
-
'
|
|
267
|
-
|
|
122
|
+
'switchport_pvlan_trunk_promiscuous')
|
|
268
123
|
assert_raises(Cisco::UnsupportedError) do
|
|
269
|
-
|
|
124
|
+
i.switchport_pvlan_trunk_promiscuous = true
|
|
270
125
|
end
|
|
271
126
|
return
|
|
272
127
|
end
|
|
273
|
-
interface.switchport_mode_private_vlan_host = :host
|
|
274
|
-
assert_equal(:host, interface.switchport_mode_private_vlan_host,
|
|
275
|
-
'Err: Switchport mode not as expected')
|
|
276
128
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
280
|
-
end
|
|
129
|
+
assert_equal(i.default_switchport_pvlan_trunk_promiscuous,
|
|
130
|
+
i.switchport_pvlan_trunk_promiscuous)
|
|
281
131
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
285
|
-
end
|
|
132
|
+
i.switchport_pvlan_trunk_promiscuous = true
|
|
133
|
+
assert(i.switchport_pvlan_trunk_promiscuous)
|
|
286
134
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
input = %w(10 10)
|
|
293
|
-
assert_raises(RuntimeError,
|
|
294
|
-
'host association did not raise RuntimeError') do
|
|
295
|
-
interface.switchport_mode_private_vlan_host_association = input
|
|
296
|
-
end
|
|
135
|
+
i.switchport_pvlan_trunk_promiscuous = false
|
|
136
|
+
refute(i.switchport_pvlan_trunk_promiscuous)
|
|
297
137
|
end
|
|
298
138
|
|
|
299
|
-
def
|
|
139
|
+
def test_sw_pvlan_trunk_secondary
|
|
300
140
|
if validate_property_excluded?('interface',
|
|
301
|
-
'
|
|
302
|
-
|
|
141
|
+
'switchport_pvlan_trunk_secondary')
|
|
303
142
|
assert_raises(Cisco::UnsupportedError) do
|
|
304
|
-
|
|
143
|
+
i.switchport_pvlan_trunk_secondary = true
|
|
305
144
|
end
|
|
306
145
|
return
|
|
307
146
|
end
|
|
308
|
-
|
|
309
|
-
assert_equal(
|
|
310
|
-
|
|
147
|
+
|
|
148
|
+
assert_equal(i.default_switchport_pvlan_trunk_secondary,
|
|
149
|
+
i.switchport_pvlan_trunk_secondary)
|
|
150
|
+
|
|
151
|
+
i.switchport_pvlan_trunk_secondary = true
|
|
152
|
+
assert(i.switchport_pvlan_trunk_secondary)
|
|
153
|
+
|
|
154
|
+
i.switchport_pvlan_trunk_secondary = false
|
|
155
|
+
refute(i.switchport_pvlan_trunk_secondary)
|
|
311
156
|
end
|
|
312
157
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
158
|
+
# Helper to setup vlan associations
|
|
159
|
+
def vlan_associate(pri, range)
|
|
160
|
+
Vlan.new(pri).pvlan_type = 'primary'
|
|
161
|
+
secondaries = Utils.dash_range_to_elements(range)
|
|
162
|
+
secondaries.each { |vlan| Vlan.new(vlan).pvlan_type = 'community' }
|
|
316
163
|
|
|
317
|
-
|
|
318
|
-
interface.switchport_mode_private_vlan_host = :host
|
|
319
|
-
end
|
|
320
|
-
return
|
|
321
|
-
end
|
|
322
|
-
v1 = Vlan.new(10)
|
|
323
|
-
v1.private_vlan_type = 'primary'
|
|
324
|
-
v2 = Vlan.new(11)
|
|
325
|
-
v2.private_vlan_type = 'community'
|
|
326
|
-
v1.private_vlan_association = ['11']
|
|
327
|
-
|
|
328
|
-
input = %w(10 11)
|
|
329
|
-
interface.switchport_mode_private_vlan_host = :promiscuous
|
|
330
|
-
assert_equal(:promiscuous,
|
|
331
|
-
interface.switchport_mode_private_vlan_host,
|
|
332
|
-
'Error: Switchport mode not as expected')
|
|
333
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
334
|
-
assert_equal(input,
|
|
335
|
-
interface.switchport_mode_private_vlan_host_promisc,
|
|
336
|
-
'Error: switchport private host promisc not configured')
|
|
337
|
-
|
|
338
|
-
v3 = Vlan.new(12)
|
|
339
|
-
v3.private_vlan_type = 'community'
|
|
340
|
-
|
|
341
|
-
v1.private_vlan_association = ['12']
|
|
342
|
-
input = %w(10 12)
|
|
343
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
344
|
-
assert_equal(input,
|
|
345
|
-
interface.switchport_mode_private_vlan_host_promisc,
|
|
346
|
-
'Error: switchport private host promisc not configured')
|
|
347
|
-
|
|
348
|
-
v4 = Vlan.new(12)
|
|
349
|
-
v4.private_vlan_type = 'community'
|
|
350
|
-
|
|
351
|
-
v5 = Vlan.new(13)
|
|
352
|
-
v5.private_vlan_type = 'community'
|
|
353
|
-
|
|
354
|
-
v6 = Vlan.new(18)
|
|
355
|
-
v6.private_vlan_type = 'community'
|
|
356
|
-
|
|
357
|
-
v7 = Vlan.new(30)
|
|
358
|
-
v7.private_vlan_type = 'community'
|
|
359
|
-
|
|
360
|
-
v1.private_vlan_association = ['12-13', '18', '30']
|
|
361
|
-
input = %w(10 12-13,18,30)
|
|
362
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
363
|
-
assert_equal(input,
|
|
364
|
-
interface.switchport_mode_private_vlan_host_promisc,
|
|
365
|
-
'Error: switchport private host promisc not configured')
|
|
164
|
+
Vlan.new(pri).pvlan_association = range
|
|
366
165
|
end
|
|
367
166
|
|
|
368
|
-
def
|
|
167
|
+
def test_sw_pvlan_host_association
|
|
168
|
+
# Supports single instance of [pri, sec]
|
|
369
169
|
if validate_property_excluded?('interface',
|
|
370
|
-
'
|
|
371
|
-
|
|
170
|
+
'switchport_pvlan_host_association')
|
|
372
171
|
assert_raises(Cisco::UnsupportedError) do
|
|
373
|
-
|
|
172
|
+
i.switchport_pvlan_host_association = %w(2 3)
|
|
374
173
|
end
|
|
375
174
|
return
|
|
376
175
|
end
|
|
377
176
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
assert_equal(:promiscuous, interface.switchport_mode_private_vlan_host,
|
|
381
|
-
'Error: Switchport mode not as expected')
|
|
177
|
+
default = i.default_switchport_pvlan_host_association
|
|
178
|
+
assert_equal(default, i.switchport_pvlan_host_association)
|
|
382
179
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
end
|
|
386
|
-
|
|
387
|
-
input = %w(10,)
|
|
388
|
-
assert_raises(TypeError, 'private vlan host promisc raise typeError') do
|
|
389
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
input = %w(10 11 12)
|
|
393
|
-
|
|
394
|
-
assert_raises(TypeError, 'private vlan host promisc raise typeError') do
|
|
395
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
396
|
-
end
|
|
397
|
-
|
|
398
|
-
input = %w(10 ten)
|
|
399
|
-
assert_raises(CliError) do
|
|
400
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
401
|
-
end
|
|
180
|
+
# Setup prerequisites
|
|
181
|
+
vlan_associate('2', '3')
|
|
402
182
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
406
|
-
end
|
|
183
|
+
i.switchport_pvlan_host_association = %w(2 3)
|
|
184
|
+
assert_equal(%w(2 3), i.switchport_pvlan_host_association)
|
|
407
185
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
'promisc association did not raise RuntimeError') do
|
|
411
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
412
|
-
end
|
|
186
|
+
i.switchport_pvlan_host_association = default
|
|
187
|
+
assert_equal(default, i.switchport_pvlan_host_association)
|
|
413
188
|
end
|
|
414
189
|
|
|
415
|
-
def
|
|
190
|
+
def test_sw_pvlan_trunk_association
|
|
191
|
+
# Supports multiple instances of [[pri, sec], [pri2, sec2]]
|
|
416
192
|
if validate_property_excluded?('interface',
|
|
417
|
-
'
|
|
418
|
-
|
|
193
|
+
'switchport_pvlan_trunk_association')
|
|
419
194
|
assert_raises(Cisco::UnsupportedError) do
|
|
420
|
-
|
|
195
|
+
i.switchport_pvlan_trunk_association = %w(2 3)
|
|
421
196
|
end
|
|
422
197
|
return
|
|
423
198
|
end
|
|
424
|
-
v1 = Vlan.new(10)
|
|
425
|
-
v1.private_vlan_type = 'primary'
|
|
426
|
-
|
|
427
|
-
v2 = Vlan.new(11)
|
|
428
|
-
v2.private_vlan_type = 'community'
|
|
429
|
-
v1.private_vlan_association = ['11']
|
|
430
|
-
|
|
431
|
-
input = %w(10 11)
|
|
432
|
-
interface.switchport_mode_private_vlan_host = :promiscuous
|
|
433
|
-
assert_equal(:promiscuous, interface.switchport_mode_private_vlan_host,
|
|
434
|
-
'Error: Switchport mode not as expected')
|
|
435
|
-
|
|
436
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
437
|
-
assert_equal(input, interface.switchport_mode_private_vlan_host_promisc,
|
|
438
|
-
'Error: switchport private host promisc not configured')
|
|
439
|
-
input = []
|
|
440
|
-
interface.switchport_mode_private_vlan_host_promisc = input
|
|
441
|
-
assert_equal(input, interface.switchport_mode_private_vlan_host_promisc,
|
|
442
|
-
'Error: switchport private host promisc not configured')
|
|
443
|
-
end
|
|
444
199
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
'switchport_mode_private_vlan_host')
|
|
200
|
+
default = i.default_switchport_pvlan_trunk_association
|
|
201
|
+
assert_equal(default, i.switchport_pvlan_trunk_association)
|
|
448
202
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return
|
|
453
|
-
end
|
|
454
|
-
val = interface.default_switchport_private_vlan_trunk_allowed_vlan
|
|
455
|
-
assert_equal(val, interface.switchport_private_vlan_trunk_allowed_vlan,
|
|
456
|
-
'Err: trunk allowed vlan failed')
|
|
457
|
-
end
|
|
203
|
+
pairs = %w(2 3)
|
|
204
|
+
i.switchport_pvlan_trunk_association = pairs
|
|
205
|
+
assert_equal([pairs], i.switchport_pvlan_trunk_association)
|
|
458
206
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
207
|
+
# Add a second pairs
|
|
208
|
+
pairs = [%w(2 3), %w(4 5)]
|
|
209
|
+
i.switchport_pvlan_trunk_association = pairs
|
|
210
|
+
assert_equal(pairs, i.switchport_pvlan_trunk_association)
|
|
462
211
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
end
|
|
468
|
-
input = %w(ten)
|
|
469
|
-
assert_raises(CliError) do
|
|
470
|
-
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
471
|
-
end
|
|
212
|
+
# New pair
|
|
213
|
+
pairs = [%w(6 7)]
|
|
214
|
+
i.switchport_pvlan_trunk_association = pairs
|
|
215
|
+
assert_equal(pairs, i.switchport_pvlan_trunk_association)
|
|
472
216
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
476
|
-
end
|
|
217
|
+
i.switchport_pvlan_trunk_association = default
|
|
218
|
+
assert_equal(default, i.switchport_pvlan_trunk_association)
|
|
477
219
|
end
|
|
478
220
|
|
|
479
|
-
def
|
|
480
|
-
if validate_property_excluded?('interface',
|
|
481
|
-
'switchport_mode_private_vlan_host')
|
|
482
|
-
|
|
221
|
+
def test_sw_pvlan_mapping
|
|
222
|
+
if validate_property_excluded?('interface', 'switchport_pvlan_mapping')
|
|
483
223
|
assert_raises(Cisco::UnsupportedError) do
|
|
484
|
-
|
|
224
|
+
i.switchport_pvlan_mapping = ['2', '10-11,4-7,8']
|
|
485
225
|
end
|
|
486
226
|
return
|
|
487
227
|
end
|
|
488
|
-
input = %w(10)
|
|
489
|
-
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
490
|
-
assert_equal(input, interface.switchport_private_vlan_trunk_allowed_vlan,
|
|
491
|
-
'Error: switchport private trunk allow vlan not configured')
|
|
492
|
-
|
|
493
|
-
input = %w(10-20)
|
|
494
|
-
result = %w(10-20)
|
|
495
|
-
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
496
|
-
assert_equal(result, interface.switchport_private_vlan_trunk_allowed_vlan,
|
|
497
|
-
'Error: switchport private trunk allow vlan not configured')
|
|
498
|
-
|
|
499
|
-
input = %w(10 13-14 40)
|
|
500
|
-
result = %w(10 13-14 40)
|
|
501
|
-
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
502
|
-
assert_equal(result, interface.switchport_private_vlan_trunk_allowed_vlan,
|
|
503
|
-
'Error: switchport private trunk allow vlan not configured')
|
|
504
|
-
|
|
505
|
-
input = []
|
|
506
|
-
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
507
|
-
assert_equal(input, interface.switchport_private_vlan_trunk_allowed_vlan,
|
|
508
|
-
'Error: switchport private trunk allow vlan not configured')
|
|
509
|
-
end
|
|
510
228
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
'switchport_mode_private_vlan_host')
|
|
229
|
+
default = i.default_switchport_pvlan_mapping
|
|
230
|
+
assert_equal(default, i.switchport_pvlan_mapping)
|
|
514
231
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
end
|
|
518
|
-
return
|
|
519
|
-
end
|
|
520
|
-
input = 'ten'
|
|
521
|
-
assert_raises(CliError) do
|
|
522
|
-
interface.switchport_private_vlan_trunk_native_vlan = input
|
|
523
|
-
end
|
|
232
|
+
# Setup prerequisites
|
|
233
|
+
vlan_associate('2', '3-4')
|
|
524
234
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
interface.switchport_private_vlan_trunk_native_vlan = input
|
|
528
|
-
end
|
|
529
|
-
end
|
|
235
|
+
i.switchport_pvlan_mapping = %w(2 3)
|
|
236
|
+
assert_equal(%w(2 3), i.switchport_pvlan_mapping)
|
|
530
237
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
'switchport_mode_private_vlan_host')
|
|
238
|
+
i.switchport_pvlan_mapping = %w(2 3-4)
|
|
239
|
+
assert_equal(%w(2 3-4), i.switchport_pvlan_mapping)
|
|
534
240
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
val = interface.default_switchport_private_vlan_trunk_native_vlan
|
|
541
|
-
assert_equal(val, interface.switchport_private_vlan_trunk_native_vlan,
|
|
542
|
-
'Err: trunk native vlan failed')
|
|
241
|
+
i.switchport_pvlan_mapping = %w(2 3)
|
|
242
|
+
assert_equal(%w(2 3), i.switchport_pvlan_mapping)
|
|
243
|
+
|
|
244
|
+
i.switchport_pvlan_mapping = default
|
|
245
|
+
assert_equal(default, i.switchport_pvlan_mapping)
|
|
543
246
|
end
|
|
544
247
|
|
|
545
|
-
def
|
|
248
|
+
def test_sw_pvlan_mapping_trunk
|
|
546
249
|
if validate_property_excluded?('interface',
|
|
547
|
-
'
|
|
548
|
-
|
|
250
|
+
'switchport_pvlan_mapping_trunk')
|
|
549
251
|
assert_raises(Cisco::UnsupportedError) do
|
|
550
|
-
|
|
252
|
+
i.switchport_pvlan_mapping_trunk = [['2', '10-11']]
|
|
551
253
|
end
|
|
552
254
|
return
|
|
553
255
|
end
|
|
256
|
+
default = i.default_switchport_pvlan_mapping_trunk
|
|
257
|
+
assert_equal(default, i.switchport_pvlan_mapping_trunk)
|
|
554
258
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
assert_equal(input, interface.switchport_private_vlan_trunk_native_vlan,
|
|
559
|
-
'Error: switchport private trunk native vlan not configured')
|
|
560
|
-
input = 1
|
|
561
|
-
interface.switchport_private_vlan_trunk_native_vlan = input
|
|
562
|
-
assert_equal(input, interface.switchport_private_vlan_trunk_native_vlan,
|
|
563
|
-
'Error: switchport private trunk native vlan not configured')
|
|
564
|
-
input = 40
|
|
565
|
-
interface.switchport_private_vlan_trunk_native_vlan = input
|
|
566
|
-
assert_equal(input, interface.switchport_private_vlan_trunk_native_vlan,
|
|
567
|
-
'Error: switchport private trunk native vlan not configured')
|
|
568
|
-
|
|
569
|
-
input = 50
|
|
570
|
-
interface.switchport_private_vlan_trunk_native_vlan = input
|
|
571
|
-
assert_equal(input,
|
|
572
|
-
interface.switchport_private_vlan_trunk_native_vlan,
|
|
573
|
-
'Error: switchport private trunk native vlan not configured')
|
|
574
|
-
end
|
|
259
|
+
# Basic, non-nested array
|
|
260
|
+
i.switchport_pvlan_mapping_trunk = ['2', '10-11,4-7,8']
|
|
261
|
+
assert_equal([['2', '4-8,10-11']], i.switchport_pvlan_mapping_trunk)
|
|
575
262
|
|
|
576
|
-
|
|
577
|
-
if validate_property_excluded?('interface',
|
|
578
|
-
'switchport_private_vlan_association_trunk')
|
|
579
|
-
assert_nil(interface.switchport_private_vlan_association_trunk)
|
|
580
|
-
return
|
|
581
|
-
end
|
|
582
|
-
input = %w(10 12)
|
|
583
|
-
result = ['10 12']
|
|
584
|
-
interface.switchport_private_vlan_association_trunk = input
|
|
585
|
-
input = interface.switchport_private_vlan_association_trunk
|
|
586
|
-
refute((result & input).empty?,
|
|
587
|
-
'Err: wrong config for switchport private trunk association')
|
|
588
|
-
input = %w(20 30)
|
|
589
|
-
result = ['20 30']
|
|
590
|
-
interface.switchport_private_vlan_association_trunk = input
|
|
591
|
-
input = interface.switchport_private_vlan_association_trunk
|
|
592
|
-
refute((result & input).empty?,
|
|
593
|
-
'Err: wrong config for switchport private trunk association')
|
|
594
|
-
|
|
595
|
-
input = %w(10 13)
|
|
596
|
-
result = ['10 13']
|
|
597
|
-
interface.switchport_private_vlan_association_trunk = input
|
|
598
|
-
input = interface.switchport_private_vlan_association_trunk
|
|
599
|
-
refute((result & input).empty?,
|
|
600
|
-
'Err: wrong config for switchport private trunk association')
|
|
601
|
-
|
|
602
|
-
input = []
|
|
603
|
-
interface.switchport_private_vlan_association_trunk = input
|
|
604
|
-
assert_equal(input, interface.switchport_private_vlan_association_trunk,
|
|
605
|
-
'Err: wrong config for switchport private trunk association')
|
|
606
|
-
end
|
|
263
|
+
# Same primary, but change range
|
|
607
264
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
'switchport_private_vlan_association_trunk')
|
|
611
|
-
assert_nil(interface.switchport_private_vlan_association_trunk)
|
|
612
|
-
return
|
|
613
|
-
end
|
|
614
|
-
input = %w(10 10)
|
|
615
|
-
assert_raises(CliError) do
|
|
616
|
-
interface.switchport_private_vlan_association_trunk = input
|
|
617
|
-
end
|
|
265
|
+
i.switchport_pvlan_mapping_trunk = ['2', '11,4-6,8']
|
|
266
|
+
assert_equal([['2', '4-6,8,11']], i.switchport_pvlan_mapping_trunk)
|
|
618
267
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
268
|
+
# Change primary
|
|
269
|
+
array = ['3', '4-6,8,11']
|
|
270
|
+
i.switchport_pvlan_mapping_trunk = array
|
|
271
|
+
assert_equal([array], i.switchport_pvlan_mapping_trunk)
|
|
623
272
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
273
|
+
# Multiple: basic
|
|
274
|
+
nest = Array[%w(4 14), %w(5 25)]
|
|
275
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
276
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
628
277
|
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
end
|
|
634
|
-
end
|
|
278
|
+
# Multiple: change only one range
|
|
279
|
+
nest = Array[%w(4 14), %w(5 7-9)]
|
|
280
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
281
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
635
282
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
return
|
|
641
|
-
end
|
|
642
|
-
val = interface.default_switchport_private_vlan_association_trunk
|
|
643
|
-
assert_equal(val, interface.switchport_private_vlan_association_trunk,
|
|
644
|
-
'Err: association trunk failed')
|
|
645
|
-
end
|
|
283
|
+
# Multiple: Move part of one range to a new primary
|
|
284
|
+
nest = Array[%w(4 14), %w(5 7,9), %w(6 8)]
|
|
285
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
286
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
646
287
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
288
|
+
# Multiple: Move part of one range from one primary to an existing primary
|
|
289
|
+
nest = Array[%w(3 14), %w(5 7,9), %w(6 8)]
|
|
290
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
291
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
650
292
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
293
|
+
# Multiple: Leave out a set while changing another
|
|
294
|
+
nest = Array[%w(5 7), %w(6 8-9,11)]
|
|
295
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
296
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
297
|
+
|
|
298
|
+
# Explicitly set the default
|
|
299
|
+
i.switchport_pvlan_mapping_trunk = default
|
|
300
|
+
assert_equal(default, i.switchport_pvlan_mapping_trunk)
|
|
657
301
|
end
|
|
658
302
|
|
|
659
|
-
def
|
|
303
|
+
def test_sw_pvlan_trunk_allowed_vlan
|
|
660
304
|
if validate_property_excluded?('interface',
|
|
661
|
-
'
|
|
662
|
-
|
|
305
|
+
'switchport_pvlan_trunk_allowed_vlan')
|
|
306
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
307
|
+
i.switchport_pvlan_trunk_allowed_vlan = '8-9,4,2-3'
|
|
308
|
+
end
|
|
663
309
|
return
|
|
664
310
|
end
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
input = interface.switchport_private_vlan_mapping_trunk
|
|
683
|
-
assert_includes(input, result,
|
|
684
|
-
'Err: wrong config for switchport private mapping trunk ')
|
|
685
|
-
|
|
686
|
-
input = []
|
|
687
|
-
interface.switchport_private_vlan_mapping_trunk = input
|
|
688
|
-
assert_equal(input, interface.switchport_private_vlan_mapping_trunk)
|
|
311
|
+
|
|
312
|
+
default = i.default_switchport_pvlan_trunk_allowed_vlan
|
|
313
|
+
assert_equal(default, i.switchport_pvlan_trunk_allowed_vlan)
|
|
314
|
+
|
|
315
|
+
i.switchport_pvlan_trunk_allowed_vlan = '8-9,4,2-3'
|
|
316
|
+
assert_equal('2-4,8-9', i.switchport_pvlan_trunk_allowed_vlan)
|
|
317
|
+
|
|
318
|
+
# Change range
|
|
319
|
+
i.switchport_pvlan_trunk_allowed_vlan = '9-10,2'
|
|
320
|
+
assert_equal('2,9-10', i.switchport_pvlan_trunk_allowed_vlan)
|
|
321
|
+
|
|
322
|
+
i.switchport_pvlan_trunk_allowed_vlan = default
|
|
323
|
+
assert_equal(default, i.switchport_pvlan_trunk_allowed_vlan)
|
|
324
|
+
|
|
325
|
+
vlans = '500-528,530,532,534,587,590-593,597-598,600,602,604'
|
|
326
|
+
i.switchport_pvlan_trunk_allowed_vlan = vlans
|
|
327
|
+
assert_equal(vlans, i.switchport_pvlan_trunk_allowed_vlan)
|
|
689
328
|
end
|
|
690
329
|
|
|
691
|
-
def
|
|
330
|
+
def test_sw_pvlan_trunk_native_vlan
|
|
692
331
|
if validate_property_excluded?('interface',
|
|
693
|
-
'
|
|
694
|
-
|
|
332
|
+
'switchport_pvlan_trunk_native_vlan')
|
|
333
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
334
|
+
i.switchport_pvlan_trunk_native_vlan = '2'
|
|
335
|
+
end
|
|
695
336
|
return
|
|
696
337
|
end
|
|
697
|
-
input = %w(10 10)
|
|
698
|
-
assert_raises(CliError) do
|
|
699
|
-
interface.switchport_private_vlan_mapping_trunk = input
|
|
700
|
-
end
|
|
701
|
-
|
|
702
|
-
input = %w(10 5000)
|
|
703
|
-
assert_raises(CliError) do
|
|
704
|
-
interface.switchport_private_vlan_mapping_trunk = input
|
|
705
|
-
end
|
|
706
338
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
interface.switchport_private_vlan_mapping_trunk = input
|
|
710
|
-
end
|
|
339
|
+
default = i.default_switchport_pvlan_trunk_native_vlan
|
|
340
|
+
assert_equal(default, i.switchport_pvlan_trunk_native_vlan)
|
|
711
341
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
'private vlan mapping trunk raise typeError') do
|
|
715
|
-
interface.switchport_private_vlan_mapping_trunk = input
|
|
716
|
-
end
|
|
342
|
+
i.switchport_pvlan_trunk_native_vlan = '2'
|
|
343
|
+
assert_equal('2', i.switchport_pvlan_trunk_native_vlan)
|
|
717
344
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
'mapping trunk did not raise RuntimeError') do
|
|
721
|
-
interface.switchport_private_vlan_mapping_trunk = input
|
|
722
|
-
end
|
|
345
|
+
i.switchport_pvlan_trunk_native_vlan = default
|
|
346
|
+
assert_equal(default, i.switchport_pvlan_trunk_native_vlan)
|
|
723
347
|
end
|
|
724
348
|
end
|