cisco_node_utils 1.1.0 → 1.2.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 +2 -1
- data/CHANGELOG.md +126 -1
- data/README.md +19 -12
- data/Rakefile +1 -0
- data/bin/git/hooks/commit-msg/enforce_style +8 -0
- data/cisco_node_utils.gemspec +4 -3
- data/docs/README-develop-best-practices.md +127 -109
- data/docs/README-develop-node-utils-APIs.md +47 -39
- data/docs/template-router.rb +3 -7
- data/lib/.rubocop.yml +4 -4
- data/lib/cisco_node_utils.rb +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
- data/lib/cisco_node_utils/ace.rb +196 -0
- data/lib/cisco_node_utils/acl.rb +100 -0
- data/lib/cisco_node_utils/bgp.rb +301 -163
- data/lib/cisco_node_utils/bgp_af.rb +187 -19
- data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
- data/lib/cisco_node_utils/command_reference.rb +359 -187
- data/lib/cisco_node_utils/configparser_lib.rb +1 -1
- data/lib/cisco_node_utils/dns_domain.rb +19 -5
- data/lib/cisco_node_utils/domain_name.rb +4 -8
- data/lib/cisco_node_utils/evpn_vni.rb +157 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
- data/lib/cisco_node_utils/feature.rb +111 -0
- data/lib/cisco_node_utils/interface.rb +390 -97
- data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
- data/lib/cisco_node_utils/interface_ospf.rb +11 -34
- data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/name_server.rb +1 -1
- data/lib/cisco_node_utils/node.rb +55 -249
- data/lib/cisco_node_utils/node_util.rb +5 -1
- data/lib/cisco_node_utils/ntp_config.rb +2 -2
- data/lib/cisco_node_utils/ntp_server.rb +14 -5
- data/lib/cisco_node_utils/overlay_global.rb +153 -0
- data/lib/cisco_node_utils/pim.rb +124 -0
- data/lib/cisco_node_utils/pim_group_list.rb +108 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
- data/lib/cisco_node_utils/platform.rb +8 -9
- data/lib/cisco_node_utils/portchannel_global.rb +277 -0
- data/lib/cisco_node_utils/radius_global.rb +9 -19
- data/lib/cisco_node_utils/radius_server.rb +31 -41
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
- data/lib/cisco_node_utils/snmpgroup.rb +1 -1
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +8 -17
- data/lib/cisco_node_utils/snmpuser.rb +67 -28
- data/lib/cisco_node_utils/syslog_server.rb +3 -9
- data/lib/cisco_node_utils/syslog_settings.rb +2 -10
- data/lib/cisco_node_utils/tacacs_server.rb +9 -14
- data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
- data/lib/cisco_node_utils/vdc.rb +88 -0
- data/lib/cisco_node_utils/version.rb +5 -2
- data/lib/cisco_node_utils/vlan.rb +71 -8
- data/lib/cisco_node_utils/vni.rb +227 -0
- data/lib/cisco_node_utils/vpc.rb +377 -0
- data/lib/cisco_node_utils/vrf.rb +60 -9
- data/lib/cisco_node_utils/vrf_af.rb +191 -0
- data/lib/cisco_node_utils/vtp.rb +8 -6
- data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
- data/lib/cisco_node_utils/yum.rb +1 -1
- data/tests/.rubocop.yml +1 -1
- data/tests/basetest.rb +16 -7
- data/tests/ciscotest.rb +55 -13
- data/tests/cmd_config.yaml +2 -2
- data/tests/platform_info.rb +3 -2
- data/tests/test_aaa_authentication_login.rb +219 -0
- data/tests/test_aaa_authentication_login_service.rb +759 -0
- data/tests/test_aaa_authorization_service.rb +1041 -0
- data/tests/test_ace.rb +160 -0
- data/tests/test_acl.rb +176 -0
- data/tests/test_bgp_af.rb +269 -13
- data/tests/test_bgp_neighbor.rb +38 -40
- data/tests/test_bgp_neighbor_af.rb +92 -32
- data/tests/test_command_config.rb +5 -5
- data/tests/test_command_reference.rb +284 -101
- data/tests/test_dns_domain.rb +1 -1
- data/tests/test_domain_name.rb +1 -1
- data/tests/test_evpn_vni.rb +106 -0
- data/tests/test_fabricpath_global.rb +243 -0
- data/tests/test_fabricpath_topology.rb +98 -0
- data/tests/test_interface.rb +292 -74
- data/tests/test_interface_channel_group.rb +74 -0
- data/tests/test_interface_ospf.rb +9 -4
- data/tests/test_interface_portchannel.rb +105 -0
- data/tests/test_interface_service_vni.rb +232 -0
- data/tests/test_interface_svi.rb +77 -62
- data/tests/test_interface_switchport.rb +17 -5
- data/tests/test_name_server.rb +1 -1
- data/tests/test_node.rb +1 -1
- data/tests/test_node_ext.rb +10 -20
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +18 -6
- data/tests/test_overlay_global.rb +102 -0
- data/tests/test_pim.rb +177 -0
- data/tests/test_pim_group_list.rb +181 -0
- data/tests/test_pim_rp_address.rb +153 -0
- data/tests/test_platform.rb +3 -3
- data/tests/test_portchannel_global.rb +202 -0
- data/tests/test_radius_global.rb +1 -1
- data/tests/test_radius_server.rb +92 -57
- data/tests/test_radius_server_group.rb +149 -0
- data/tests/test_router_bgp.rb +283 -112
- data/tests/test_router_ospf.rb +2 -2
- data/tests/test_router_ospf_vrf.rb +4 -4
- data/tests/test_snmp_notification_receiver.rb +167 -0
- data/tests/test_snmpcommunity.rb +1 -1
- data/tests/test_snmpgroup.rb +1 -1
- data/tests/test_snmpnotification.rb +72 -0
- data/tests/test_snmpserver.rb +29 -105
- data/tests/test_snmpuser.rb +32 -30
- data/tests/test_syslog_server.rb +36 -10
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_server.rb +1 -1
- data/tests/test_tacacs_server_group.rb +405 -0
- data/tests/test_tacacs_server_host.rb +1 -1
- data/tests/test_vdc.rb +78 -0
- data/tests/test_vlan.rb +74 -19
- data/tests/test_vlan_mt_full.rb +95 -0
- data/tests/test_vni.rb +106 -0
- data/tests/test_vpc.rb +361 -0
- data/tests/test_vrf.rb +172 -29
- data/tests/test_vtp.rb +1 -1
- data/tests/test_vxlan_vtep.rb +214 -0
- data/tests/test_vxlan_vtep_vni.rb +201 -0
- data/tests/test_yum.rb +1 -1
- metadata +120 -11
- data/lib/cisco_node_utils/README_YAML.md +0 -325
- data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
- data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
- data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
- data/tests/platform_info.yaml +0 -10
data/tests/test_interface.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Copyright (c) 2013-
|
|
1
|
+
# Copyright (c) 2013-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.
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/acl'
|
|
16
17
|
require_relative '../lib/cisco_node_utils/interface'
|
|
18
|
+
require_relative '../lib/cisco_node_utils/overlay_global'
|
|
17
19
|
|
|
18
20
|
include Cisco
|
|
19
21
|
|
|
@@ -39,7 +41,6 @@ class TestInterface < CiscoTestCase
|
|
|
39
41
|
DEFAULT_IF_IP_PROXY_ARP = false
|
|
40
42
|
DEFAULT_IF_IP_REDIRECTS = true
|
|
41
43
|
DEFAULT_IF_VRF = ''
|
|
42
|
-
IF_DESCRIPTION_SIZE = 243 # SIZE = VSH Max 255 - "description " keyword
|
|
43
44
|
IF_VRF_MAX_LENGTH = 32
|
|
44
45
|
|
|
45
46
|
def interface_ipv4_config(ifname, address, length,
|
|
@@ -62,7 +63,8 @@ class TestInterface < CiscoTestCase
|
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
def show_cmd(name)
|
|
65
|
-
|
|
66
|
+
all = (name =~ /port-channel\d/ && node.product_id =~ /N7/) ? '' : 'all'
|
|
67
|
+
"show run interface #{name} #{all} | no-more"
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
def interface_count
|
|
@@ -75,6 +77,17 @@ class TestInterface < CiscoTestCase
|
|
|
75
77
|
arr.count
|
|
76
78
|
end
|
|
77
79
|
|
|
80
|
+
# Helper to check for misc speed change disallowed error messages.
|
|
81
|
+
def speed_change_disallowed(message)
|
|
82
|
+
patterns = ['port doesn t support this speed',
|
|
83
|
+
'Changing interface speed is not permitted',
|
|
84
|
+
'requested config change not allowed',
|
|
85
|
+
/does not match the (transceiver speed|port capability)/]
|
|
86
|
+
skip('Skip test: Interface type does not allow config change') if
|
|
87
|
+
message[Regexp.union(patterns)]
|
|
88
|
+
flunk(message)
|
|
89
|
+
end
|
|
90
|
+
|
|
78
91
|
def create_interface(ifname=interfaces[0])
|
|
79
92
|
@default_show_command = show_cmd(ifname)
|
|
80
93
|
Interface.new(ifname)
|
|
@@ -165,6 +178,10 @@ class TestInterface < CiscoTestCase
|
|
|
165
178
|
"Error: #{interface.name}, switchport mode, default, " \
|
|
166
179
|
'not correct')
|
|
167
180
|
end
|
|
181
|
+
rescue RuntimeError => e
|
|
182
|
+
skip('NX-OS defect: system default switchport nvgens twice') if
|
|
183
|
+
e.message[/Expected zero.one value/]
|
|
184
|
+
flunk(e.message)
|
|
168
185
|
end
|
|
169
186
|
|
|
170
187
|
def validate_description(inttype_h)
|
|
@@ -247,7 +264,7 @@ class TestInterface < CiscoTestCase
|
|
|
247
264
|
# Validate the collection
|
|
248
265
|
inttype_h.each do |k, v|
|
|
249
266
|
# Skipping loopback, proxy arp not supported
|
|
250
|
-
next if
|
|
267
|
+
next if k == 'loopback0'
|
|
251
268
|
|
|
252
269
|
interface = v[:interface]
|
|
253
270
|
cmd = show_cmd(interface.name)
|
|
@@ -305,36 +322,25 @@ class TestInterface < CiscoTestCase
|
|
|
305
322
|
assert_equal(ref.default_value, interface.default_ipv4_redirects,
|
|
306
323
|
"ipv4 redirects default incorrect for interface #{k}")
|
|
307
324
|
|
|
308
|
-
|
|
309
|
-
config_set = ref.config_set
|
|
310
|
-
rescue IndexError
|
|
311
|
-
config_set = nil
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
if config_set
|
|
315
|
-
pattern = ref.test_config_get_regex[0]
|
|
325
|
+
if ref.config_set?
|
|
316
326
|
cmd = show_cmd(interface.name)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
interface.ipv4_redirects = true
|
|
321
|
-
assert(interface.ipv4_redirects, "Couldn't set redirects to true")
|
|
322
|
-
refute_show_match(command: cmd, pattern: pattern)
|
|
327
|
+
interface.ipv4_redirects = true
|
|
328
|
+
assert(interface.ipv4_redirects, "Couldn't set redirects to true")
|
|
329
|
+
refute_show_match(command: cmd, pattern: ref.test_config_get_regex[1])
|
|
323
330
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
end
|
|
331
|
+
interface.ipv4_redirects = false
|
|
332
|
+
refute(interface.ipv4_redirects, "Couldn't set redirects to false")
|
|
333
|
+
refute_show_match(command: cmd, pattern: ref.test_config_get_regex[0])
|
|
328
334
|
else
|
|
329
335
|
# Getter should return same value as default if setter isn't supported
|
|
330
336
|
assert_equal(interface.ipv4_redirects, interface.default_ipv4_redirects,
|
|
331
337
|
'ipv4 redirects default incorrect')
|
|
332
338
|
|
|
333
339
|
# Make sure setter fails
|
|
334
|
-
assert_raises(
|
|
340
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
335
341
|
interface.ipv4_redirects = true
|
|
336
342
|
end
|
|
337
|
-
assert_raises(
|
|
343
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
338
344
|
interface.ipv4_redirects = false
|
|
339
345
|
end
|
|
340
346
|
end
|
|
@@ -394,24 +400,11 @@ class TestInterface < CiscoTestCase
|
|
|
394
400
|
assert_equal('', interface.description)
|
|
395
401
|
end
|
|
396
402
|
|
|
397
|
-
def test_interface_description_too_long
|
|
398
|
-
interface = Interface.new(interfaces[0])
|
|
399
|
-
description = 'a' * (IF_DESCRIPTION_SIZE + 1)
|
|
400
|
-
assert_raises(RuntimeError) { interface.description = description }
|
|
401
|
-
interface_ethernet_default(interfaces_id[0])
|
|
402
|
-
end
|
|
403
|
-
|
|
404
403
|
def test_interface_description_valid
|
|
405
404
|
interface = Interface.new(interfaces[0])
|
|
406
|
-
|
|
407
|
-
description =
|
|
408
|
-
|
|
409
|
-
description += alphabet[i % alphabet.size, 1]
|
|
410
|
-
next unless i == IF_DESCRIPTION_SIZE
|
|
411
|
-
# puts("description (#{i}): #{description}")
|
|
412
|
-
interface.description = description
|
|
413
|
-
assert_equal(description.rstrip, interface.description)
|
|
414
|
-
end
|
|
405
|
+
description = 'This is a test description ! '
|
|
406
|
+
interface.description = description
|
|
407
|
+
assert_equal(description.rstrip, interface.description)
|
|
415
408
|
interface_ethernet_default(interfaces_id[0])
|
|
416
409
|
end
|
|
417
410
|
|
|
@@ -448,6 +441,7 @@ class TestInterface < CiscoTestCase
|
|
|
448
441
|
|
|
449
442
|
def test_interface_mtu_change
|
|
450
443
|
interface = Interface.new(interfaces[0])
|
|
444
|
+
interface.switchport_mode = :disabled
|
|
451
445
|
interface.mtu = 1520
|
|
452
446
|
assert_equal(1520, interface.mtu)
|
|
453
447
|
interface.mtu = 1580
|
|
@@ -457,16 +451,76 @@ class TestInterface < CiscoTestCase
|
|
|
457
451
|
|
|
458
452
|
def test_interface_mtu_invalid
|
|
459
453
|
interface = Interface.new(interfaces[0])
|
|
454
|
+
interface.switchport_mode = :disabled
|
|
460
455
|
assert_raises(RuntimeError) { interface.mtu = 'hello' }
|
|
461
456
|
end
|
|
462
457
|
|
|
463
458
|
def test_interface_mtu_valid
|
|
464
459
|
interface = Interface.new(interfaces[0])
|
|
460
|
+
interface.switchport_mode = :disabled
|
|
465
461
|
interface.mtu = 1550
|
|
466
462
|
assert_equal(1550, interface.mtu)
|
|
467
463
|
interface_ethernet_default(interfaces_id[0])
|
|
468
464
|
end
|
|
469
465
|
|
|
466
|
+
def test_interface_speed_change
|
|
467
|
+
interface = Interface.new(interfaces[0])
|
|
468
|
+
begin
|
|
469
|
+
interface.speed = 100
|
|
470
|
+
assert_equal('100', interface.speed)
|
|
471
|
+
interface.speed = 1000
|
|
472
|
+
assert_equal('1000', interface.speed)
|
|
473
|
+
interface_ethernet_default(interfaces_id[0])
|
|
474
|
+
rescue RuntimeError => e
|
|
475
|
+
speed_change_disallowed(e.message)
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
def test_interface_speed_invalid
|
|
480
|
+
interface = Interface.new(interfaces[0])
|
|
481
|
+
assert_raises(RuntimeError) { interface.speed = 'hello' }
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
def test_interface_speed_valid
|
|
485
|
+
interface = Interface.new(interfaces[0])
|
|
486
|
+
interface.speed = 1000
|
|
487
|
+
assert_equal('1000', interface.speed)
|
|
488
|
+
interface_ethernet_default(interfaces_id[0])
|
|
489
|
+
rescue RuntimeError => e
|
|
490
|
+
speed_change_disallowed(e.message)
|
|
491
|
+
end
|
|
492
|
+
|
|
493
|
+
def test_interface_duplex_change
|
|
494
|
+
interface = Interface.new(interfaces[0])
|
|
495
|
+
interface.speed = 1000
|
|
496
|
+
interface.duplex = 'full'
|
|
497
|
+
assert_equal('full', interface.duplex)
|
|
498
|
+
interface.duplex = 'auto'
|
|
499
|
+
assert_equal('auto', interface.duplex)
|
|
500
|
+
interface_ethernet_default(interfaces_id[0])
|
|
501
|
+
rescue RuntimeError => e
|
|
502
|
+
speed_change_disallowed(e.message)
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
def test_interface_duplex_invalid
|
|
506
|
+
interface = Interface.new(interfaces[0])
|
|
507
|
+
interface.speed = 1000
|
|
508
|
+
assert_raises(RuntimeError) { interface.duplex = 'hello' }
|
|
509
|
+
interface_ethernet_default(interfaces_id[0])
|
|
510
|
+
rescue RuntimeError => e
|
|
511
|
+
speed_change_disallowed(e.message)
|
|
512
|
+
end
|
|
513
|
+
|
|
514
|
+
def test_interface_duplex_valid
|
|
515
|
+
interface = Interface.new(interfaces[0])
|
|
516
|
+
interface.speed = 1000
|
|
517
|
+
interface.duplex = 'full'
|
|
518
|
+
assert_equal('full', interface.duplex)
|
|
519
|
+
interface_ethernet_default(interfaces_id[0])
|
|
520
|
+
rescue RuntimeError => e
|
|
521
|
+
speed_change_disallowed(e.message)
|
|
522
|
+
end
|
|
523
|
+
|
|
470
524
|
def test_interface_shutdown_valid
|
|
471
525
|
interface = Interface.new(interfaces[0])
|
|
472
526
|
interface.shutdown = true
|
|
@@ -562,17 +616,12 @@ class TestInterface < CiscoTestCase
|
|
|
562
616
|
interface.negotiate_auto = default
|
|
563
617
|
# Delay as this change is sometimes too quick for some interfaces
|
|
564
618
|
sleep 1 unless default == interface.negotiate_auto
|
|
619
|
+
node.cache_flush
|
|
565
620
|
assert_equal(default, interface.negotiate_auto,
|
|
566
621
|
"Error: #{inf_name} negotiate auto value " \
|
|
567
622
|
'should be same as default')
|
|
568
623
|
|
|
569
|
-
|
|
570
|
-
config_set = cmd_ref.config_set
|
|
571
|
-
rescue IndexError
|
|
572
|
-
config_set = nil
|
|
573
|
-
end
|
|
574
|
-
|
|
575
|
-
unless config_set
|
|
624
|
+
unless cmd_ref.config_set?
|
|
576
625
|
# check the set for unsupported platforms
|
|
577
626
|
assert_raises(RuntimeError) do
|
|
578
627
|
interface.negotiate_auto = true
|
|
@@ -581,7 +630,7 @@ class TestInterface < CiscoTestCase
|
|
|
581
630
|
end
|
|
582
631
|
|
|
583
632
|
interface.negotiate_auto = default
|
|
584
|
-
assert_equal(interface.negotiate_auto,
|
|
633
|
+
assert_equal(default, interface.negotiate_auto,
|
|
585
634
|
"Error: #{inf_name} negotiate auto value not #{default}")
|
|
586
635
|
|
|
587
636
|
pattern = cmd_ref.test_config_get_regex[default ? 1 : 0]
|
|
@@ -594,11 +643,16 @@ class TestInterface < CiscoTestCase
|
|
|
594
643
|
begin
|
|
595
644
|
interface.negotiate_auto = non_default
|
|
596
645
|
rescue RuntimeError
|
|
597
|
-
assert_equal(interface.negotiate_auto,
|
|
646
|
+
assert_equal(default, interface.negotiate_auto,
|
|
598
647
|
"Error: #{inf_name} negotiate auto value not #{default}")
|
|
599
648
|
return
|
|
600
649
|
end
|
|
601
|
-
|
|
650
|
+
|
|
651
|
+
# Delay as this change is sometimes too quick for some interfaces
|
|
652
|
+
sleep 1 unless non_default == interface.negotiate_auto
|
|
653
|
+
node.cache_flush
|
|
654
|
+
|
|
655
|
+
assert_equal(non_default, interface.negotiate_auto,
|
|
602
656
|
"Error: #{inf_name} negotiate auto value not #{non_default}")
|
|
603
657
|
|
|
604
658
|
pattern = cmd_ref.test_config_get_regex[non_default ? 1 : 0]
|
|
@@ -606,7 +660,7 @@ class TestInterface < CiscoTestCase
|
|
|
606
660
|
|
|
607
661
|
# Clean up after ourselves
|
|
608
662
|
interface.negotiate_auto = default
|
|
609
|
-
assert_equal(interface.negotiate_auto,
|
|
663
|
+
assert_equal(default, interface.negotiate_auto,
|
|
610
664
|
"Error: #{inf_name} negotiate auto value not #{default}")
|
|
611
665
|
|
|
612
666
|
pattern = cmd_ref.test_config_get_regex[default ? 1 : 0]
|
|
@@ -640,6 +694,9 @@ class TestInterface < CiscoTestCase
|
|
|
640
694
|
'negotiate_auto_ethernet')
|
|
641
695
|
assert(ref, 'Error, reference not found')
|
|
642
696
|
|
|
697
|
+
# Cleanup
|
|
698
|
+
interface_ethernet_default(interfaces_id[0])
|
|
699
|
+
|
|
643
700
|
# Some platforms does not support negotiate auto
|
|
644
701
|
# if so then we abort the test.
|
|
645
702
|
|
|
@@ -649,9 +706,10 @@ class TestInterface < CiscoTestCase
|
|
|
649
706
|
# Some platforms/interfaces/versions do not support negotiation changes
|
|
650
707
|
begin
|
|
651
708
|
interface.negotiate_auto = false
|
|
652
|
-
rescue => e
|
|
709
|
+
rescue CliError => e
|
|
653
710
|
skip('Skip test: Interface type does not allow config change') if
|
|
654
711
|
e.message[/requested config change not allowed/]
|
|
712
|
+
flunk(e.message)
|
|
655
713
|
end
|
|
656
714
|
|
|
657
715
|
default = ref.default_value
|
|
@@ -680,10 +738,10 @@ class TestInterface < CiscoTestCase
|
|
|
680
738
|
assert_equal(interface.negotiate_auto, ref.default_value,
|
|
681
739
|
"Error: #{inf_name} negotiate auto value mismatch")
|
|
682
740
|
|
|
683
|
-
assert_raises(
|
|
741
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
684
742
|
interface.negotiate_auto = true
|
|
685
743
|
end
|
|
686
|
-
assert_raises(
|
|
744
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
687
745
|
interface.negotiate_auto = false
|
|
688
746
|
end
|
|
689
747
|
|
|
@@ -701,7 +759,6 @@ class TestInterface < CiscoTestCase
|
|
|
701
759
|
assert_raises(RuntimeError) do
|
|
702
760
|
interface.ipv4_addr_mask_set('', 14)
|
|
703
761
|
end
|
|
704
|
-
interface.switchport_mode = :access
|
|
705
762
|
interface_ethernet_default(interfaces_id[0])
|
|
706
763
|
end
|
|
707
764
|
|
|
@@ -711,17 +768,90 @@ class TestInterface < CiscoTestCase
|
|
|
711
768
|
assert_raises(RuntimeError) do
|
|
712
769
|
interface.ipv4_addr_mask_set('8.1.1.2', DEFAULT_IF_IP_NETMASK_LEN)
|
|
713
770
|
end
|
|
714
|
-
interface.switchport_mode = :access
|
|
715
771
|
interface_ethernet_default(interfaces_id[0])
|
|
716
772
|
end
|
|
717
773
|
|
|
774
|
+
def test_ipv4_acl
|
|
775
|
+
# Sample cli:
|
|
776
|
+
#
|
|
777
|
+
# interface Ethernet1/1
|
|
778
|
+
# ip access-group v4acl1 in
|
|
779
|
+
# ip access-group v4acl2 out
|
|
780
|
+
#
|
|
781
|
+
|
|
782
|
+
# create acls first
|
|
783
|
+
%w(v4acl1 v4acl2 v4acl3 v4acl4).each do |acl_name|
|
|
784
|
+
Acl.new('ipv4', acl_name)
|
|
785
|
+
end
|
|
786
|
+
interface_ethernet_default(interfaces[0])
|
|
787
|
+
intf = Interface.new(interfaces[0])
|
|
788
|
+
|
|
789
|
+
intf.ipv4_acl_in = 'v4acl1'
|
|
790
|
+
assert_equal('v4acl1', intf.ipv4_acl_in)
|
|
791
|
+
intf.ipv4_acl_out = 'v4acl2'
|
|
792
|
+
assert_equal('v4acl2', intf.ipv4_acl_out)
|
|
793
|
+
|
|
794
|
+
intf.ipv4_acl_in = 'v4acl3'
|
|
795
|
+
assert_equal('v4acl3', intf.ipv4_acl_in)
|
|
796
|
+
intf.ipv4_acl_out = 'v4acl4'
|
|
797
|
+
assert_equal('v4acl4', intf.ipv4_acl_out)
|
|
798
|
+
|
|
799
|
+
intf.ipv4_acl_in = intf.default_ipv4_acl_in
|
|
800
|
+
assert_equal('', intf.ipv4_acl_in)
|
|
801
|
+
intf.ipv4_acl_out = intf.default_ipv4_acl_out
|
|
802
|
+
assert_equal('', intf.ipv4_acl_out)
|
|
803
|
+
|
|
804
|
+
# delete acls
|
|
805
|
+
%w(v4acl1 v4acl2 v4acl3 v4acl4).each do |acl_name|
|
|
806
|
+
config('no ip access-list ' + acl_name)
|
|
807
|
+
end
|
|
808
|
+
end
|
|
809
|
+
|
|
810
|
+
def test_ipv6_acl
|
|
811
|
+
# Sample cli:
|
|
812
|
+
#
|
|
813
|
+
# interface Ethernet1/1
|
|
814
|
+
# ipv6 traffic-filter v6acl1 in
|
|
815
|
+
# ipv6 traffic-filter v6acl2 out
|
|
816
|
+
#
|
|
817
|
+
interface_ethernet_default(interfaces[0])
|
|
818
|
+
intf = Interface.new(interfaces[0])
|
|
819
|
+
|
|
820
|
+
# create acls first
|
|
821
|
+
%w(v6acl1 v6acl2 v6acl3 v6acl4).each do |acl_name|
|
|
822
|
+
Acl.new('ipv6', acl_name)
|
|
823
|
+
end
|
|
824
|
+
|
|
825
|
+
intf.ipv6_acl_in = 'v6acl1'
|
|
826
|
+
assert_equal('v6acl1', intf.ipv6_acl_in)
|
|
827
|
+
intf.ipv6_acl_out = 'v6acl2'
|
|
828
|
+
assert_equal('v6acl2', intf.ipv6_acl_out)
|
|
829
|
+
|
|
830
|
+
intf.ipv6_acl_in = 'v6acl3'
|
|
831
|
+
assert_equal('v6acl3', intf.ipv6_acl_in)
|
|
832
|
+
intf.ipv6_acl_out = 'v6acl4'
|
|
833
|
+
assert_equal('v6acl4', intf.ipv6_acl_out)
|
|
834
|
+
|
|
835
|
+
intf.ipv6_acl_in = intf.default_ipv6_acl_in
|
|
836
|
+
assert_equal('', intf.ipv6_acl_in)
|
|
837
|
+
intf.ipv6_acl_out = intf.default_ipv6_acl_out
|
|
838
|
+
assert_equal('', intf.ipv6_acl_out)
|
|
839
|
+
|
|
840
|
+
# delete acls
|
|
841
|
+
%w(v6acl1 v6acl2 v6acl3 v6acl4).each do |acl_name|
|
|
842
|
+
config('no ipv6 access-list ' + acl_name)
|
|
843
|
+
end
|
|
844
|
+
end
|
|
845
|
+
|
|
718
846
|
def test_interface_ipv4_address
|
|
719
847
|
interface = create_interface
|
|
720
848
|
interface.switchport_mode = :disabled
|
|
721
849
|
address = '8.7.1.1'
|
|
850
|
+
sec_addr = '10.5.5.1'
|
|
851
|
+
secondary = true
|
|
722
852
|
length = 15
|
|
723
853
|
|
|
724
|
-
# setter, getter
|
|
854
|
+
# Primary: setter, getter
|
|
725
855
|
interface.ipv4_addr_mask_set(address, length)
|
|
726
856
|
pattern = %r{^\s+ip address #{address}/#{length}}
|
|
727
857
|
assert_show_match(pattern: pattern,
|
|
@@ -730,6 +860,17 @@ class TestInterface < CiscoTestCase
|
|
|
730
860
|
'Error: ipv4 address get value mismatch')
|
|
731
861
|
assert_equal(length, interface.ipv4_netmask_length,
|
|
732
862
|
'Error: ipv4 netmask length get value mismatch')
|
|
863
|
+
|
|
864
|
+
# Secondary: setter, getter
|
|
865
|
+
interface.ipv4_addr_mask_set(sec_addr, length, secondary)
|
|
866
|
+
pattern = %r{^\s+ip address #{sec_addr}/#{length} secondary}
|
|
867
|
+
assert_show_match(pattern: pattern,
|
|
868
|
+
msg: 'Error: ipv4 address missing in CLI')
|
|
869
|
+
assert_equal(sec_addr, interface.ipv4_address_secondary,
|
|
870
|
+
'Error: ipv4 address get value mismatch')
|
|
871
|
+
assert_equal(length, interface.ipv4_netmask_length,
|
|
872
|
+
'Error: ipv4 netmask length get value mismatch')
|
|
873
|
+
|
|
733
874
|
# get default
|
|
734
875
|
assert_equal(DEFAULT_IF_IP_ADDRESS, interface.default_ipv4_address,
|
|
735
876
|
'Error: ipv4 address get default value mismatch')
|
|
@@ -739,7 +880,13 @@ class TestInterface < CiscoTestCase
|
|
|
739
880
|
interface.default_ipv4_netmask_length,
|
|
740
881
|
'Error: ipv4 netmask length get default value mismatch')
|
|
741
882
|
|
|
742
|
-
# unconfigure ipaddress
|
|
883
|
+
# unconfigure ipaddress - secondary must be removed first
|
|
884
|
+
interface.ipv4_addr_mask_set(interface.default_ipv4_address, length,
|
|
885
|
+
secondary)
|
|
886
|
+
interface.ipv4_addr_mask_set(interface.default_ipv4_address, length)
|
|
887
|
+
# unconfigure should be safely idempotent
|
|
888
|
+
interface.ipv4_addr_mask_set(interface.default_ipv4_address, length,
|
|
889
|
+
secondary)
|
|
743
890
|
interface.ipv4_addr_mask_set(interface.default_ipv4_address, length)
|
|
744
891
|
pattern = (/^\s+ip address (.*)/)
|
|
745
892
|
refute_show_match(pattern: pattern,
|
|
@@ -750,7 +897,6 @@ class TestInterface < CiscoTestCase
|
|
|
750
897
|
interface.ipv4_netmask_length,
|
|
751
898
|
'Error: ipv4 netmask length default get value mismatch')
|
|
752
899
|
|
|
753
|
-
interface.switchport_mode = :access
|
|
754
900
|
interface_ethernet_default(interfaces_id[0])
|
|
755
901
|
end
|
|
756
902
|
|
|
@@ -794,6 +940,56 @@ class TestInterface < CiscoTestCase
|
|
|
794
940
|
interface_ethernet_default(interfaces_id[0])
|
|
795
941
|
end
|
|
796
942
|
|
|
943
|
+
def test_interface_ipv4_arp_timeout
|
|
944
|
+
# Setup
|
|
945
|
+
config('no interface vlan11')
|
|
946
|
+
int = Interface.new('vlan11')
|
|
947
|
+
|
|
948
|
+
# Test default
|
|
949
|
+
assert_equal(int.default_ipv4_arp_timeout, int.ipv4_arp_timeout)
|
|
950
|
+
# Test non-default
|
|
951
|
+
int.ipv4_arp_timeout = 300
|
|
952
|
+
assert_equal(300, int.ipv4_arp_timeout)
|
|
953
|
+
# Set back to default
|
|
954
|
+
int.ipv4_arp_timeout = int.default_ipv4_arp_timeout
|
|
955
|
+
assert_equal(int.default_ipv4_arp_timeout, int.ipv4_arp_timeout)
|
|
956
|
+
|
|
957
|
+
# Attempt to configure on a non-vlan interface
|
|
958
|
+
nonvlanint = create_interface
|
|
959
|
+
assert_raises(RuntimeError) { nonvlanint.ipv4_arp_timeout = 300 }
|
|
960
|
+
end
|
|
961
|
+
|
|
962
|
+
def test_interface_fabric_forwarding_anycast_gateway
|
|
963
|
+
# Setup
|
|
964
|
+
config('no interface vlan11')
|
|
965
|
+
int = Interface.new('vlan11')
|
|
966
|
+
foo = OverlayGlobal.new
|
|
967
|
+
foo.anycast_gateway_mac = '1223.3445.5668'
|
|
968
|
+
|
|
969
|
+
# 1. Testing default for newly created vlan
|
|
970
|
+
assert_equal(int.default_fabric_forwarding_anycast_gateway,
|
|
971
|
+
int.fabric_forwarding_anycast_gateway)
|
|
972
|
+
|
|
973
|
+
# 2. Testing non-default:true
|
|
974
|
+
int.fabric_forwarding_anycast_gateway = true
|
|
975
|
+
assert(int.fabric_forwarding_anycast_gateway)
|
|
976
|
+
|
|
977
|
+
# 3. Setting back to false
|
|
978
|
+
int.fabric_forwarding_anycast_gateway = false
|
|
979
|
+
refute(int.fabric_forwarding_anycast_gateway)
|
|
980
|
+
|
|
981
|
+
# 4. Attempt to configure on a non-vlan interface
|
|
982
|
+
nonvlanint = create_interface
|
|
983
|
+
assert_raises(RuntimeError) do
|
|
984
|
+
nonvlanint.fabric_forwarding_anycast_gateway = true
|
|
985
|
+
end
|
|
986
|
+
|
|
987
|
+
# 5. Attempt to set 'fabric forwarding anycast gateway' while the
|
|
988
|
+
# overlay gateway mac is not set.
|
|
989
|
+
foo.anycast_gateway_mac = foo.default_anycast_gateway_mac
|
|
990
|
+
assert_raises(RuntimeError) { int.fabric_forwarding_anycast_gateway = true }
|
|
991
|
+
end
|
|
992
|
+
|
|
797
993
|
def test_interface_ipv4_proxy_arp
|
|
798
994
|
interface = create_interface
|
|
799
995
|
interface.switchport_mode = :disabled
|
|
@@ -826,7 +1022,6 @@ class TestInterface < CiscoTestCase
|
|
|
826
1022
|
interface.ipv4_proxy_arp,
|
|
827
1023
|
'Error: ip proxy-arp default get value mismatch')
|
|
828
1024
|
|
|
829
|
-
interface.switchport_mode = :access
|
|
830
1025
|
interface_ethernet_default(interfaces_id[0])
|
|
831
1026
|
end
|
|
832
1027
|
|
|
@@ -861,7 +1056,6 @@ class TestInterface < CiscoTestCase
|
|
|
861
1056
|
assert_equal(DEFAULT_IF_IP_REDIRECTS, interface.ipv4_redirects,
|
|
862
1057
|
'Error: ip redirects default get value mismatch')
|
|
863
1058
|
|
|
864
|
-
interface.switchport_mode = :access
|
|
865
1059
|
interface_ethernet_default(interfaces_id[0])
|
|
866
1060
|
end
|
|
867
1061
|
|
|
@@ -970,24 +1164,30 @@ class TestInterface < CiscoTestCase
|
|
|
970
1164
|
# pre-configure
|
|
971
1165
|
inttype_h = config_from_hash(inttype_h)
|
|
972
1166
|
|
|
973
|
-
#
|
|
974
|
-
validate_interfaces_not_empty
|
|
975
|
-
validate_get_switchport(inttype_h)
|
|
976
|
-
validate_description(inttype_h)
|
|
977
|
-
validate_get_access_vlan(inttype_h)
|
|
978
|
-
validate_ipv4_address(inttype_h)
|
|
979
|
-
validate_ipv4_proxy_arp(inttype_h)
|
|
980
|
-
validate_ipv4_redirects(inttype_h)
|
|
981
|
-
validate_interface_shutdown(inttype_h)
|
|
982
|
-
validate_vrf(inttype_h)
|
|
983
|
-
|
|
984
|
-
# Cleanup the preload configuration
|
|
1167
|
+
# Steps to cleanup the preload configuration
|
|
985
1168
|
cfg = []
|
|
986
1169
|
inttype_h.each_key do |k|
|
|
987
1170
|
cfg << "#{/^Ethernet/.match(k) ? 'default' : 'no'} interface #{k}"
|
|
988
1171
|
end
|
|
989
1172
|
cfg << 'no feature interface-vlan'
|
|
990
|
-
|
|
1173
|
+
|
|
1174
|
+
begin
|
|
1175
|
+
# Validate the collection
|
|
1176
|
+
validate_interfaces_not_empty
|
|
1177
|
+
validate_get_switchport(inttype_h)
|
|
1178
|
+
validate_description(inttype_h)
|
|
1179
|
+
validate_get_access_vlan(inttype_h)
|
|
1180
|
+
validate_ipv4_address(inttype_h)
|
|
1181
|
+
validate_ipv4_proxy_arp(inttype_h)
|
|
1182
|
+
validate_ipv4_redirects(inttype_h)
|
|
1183
|
+
validate_interface_shutdown(inttype_h)
|
|
1184
|
+
validate_vrf(inttype_h)
|
|
1185
|
+
config(*cfg)
|
|
1186
|
+
rescue Minitest::Assertion
|
|
1187
|
+
# clean up before failing
|
|
1188
|
+
config(*cfg)
|
|
1189
|
+
raise
|
|
1190
|
+
end
|
|
991
1191
|
end
|
|
992
1192
|
|
|
993
1193
|
def test_interface_vrf_default
|
|
@@ -1032,4 +1232,22 @@ class TestInterface < CiscoTestCase
|
|
|
1032
1232
|
assert_equal(vrf, interface.vrf)
|
|
1033
1233
|
interface.destroy
|
|
1034
1234
|
end
|
|
1235
|
+
|
|
1236
|
+
def test_ipv4_pim_sparse_mode
|
|
1237
|
+
# Sample cli:
|
|
1238
|
+
#
|
|
1239
|
+
# interface Ethernet1/1
|
|
1240
|
+
# ip pim sparse-mode
|
|
1241
|
+
#
|
|
1242
|
+
config('no feature pim')
|
|
1243
|
+
i = Interface.new(interfaces[0])
|
|
1244
|
+
i.ipv4_pim_sparse_mode = false
|
|
1245
|
+
refute(i.ipv4_pim_sparse_mode)
|
|
1246
|
+
|
|
1247
|
+
i.ipv4_pim_sparse_mode = true
|
|
1248
|
+
assert(i.ipv4_pim_sparse_mode)
|
|
1249
|
+
|
|
1250
|
+
i.ipv4_pim_sparse_mode = i.default_ipv4_pim_sparse_mode
|
|
1251
|
+
assert_equal(i.default_ipv4_pim_sparse_mode, i.ipv4_pim_sparse_mode)
|
|
1252
|
+
end
|
|
1035
1253
|
end
|