cisco_node_utils 1.2.0 → 1.3.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 -0
- data/.rspec +2 -0
- data/.rubocop.yml +13 -0
- data/.travis.yml +4 -1
- data/CHANGELOG.md +81 -2
- data/CONTRIBUTING.md +2 -17
- data/Gemfile +5 -0
- data/README.md +92 -47
- data/Rakefile +23 -1
- data/bin/git/hooks/hook_lib +7 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +7 -2
- data/bin/git/hooks/pre-commit/validate-diffs +18 -4
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/update-hooks +64 -6
- data/cisco_node_utils.gemspec +9 -6
- data/docs/README-develop-best-practices.md +149 -50
- data/docs/README-develop-node-utils-APIs.md +92 -42
- data/docs/README-maintainers.md +7 -4
- data/docs/README-test-execution.md +57 -0
- data/docs/cisco_node_utils.yaml.example +30 -0
- data/docs/template-router.rb +4 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +2 -2
- data/lib/cisco_node_utils.rb +5 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +5 -6
- data/lib/cisco_node_utils/aaa_authorization_service.rb +1 -1
- data/lib/cisco_node_utils/ace.rb +165 -12
- data/lib/cisco_node_utils/acl.rb +2 -1
- data/lib/cisco_node_utils/bgp.rb +184 -21
- data/lib/cisco_node_utils/bgp_af.rb +94 -249
- data/lib/cisco_node_utils/bgp_neighbor.rb +94 -14
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +75 -8
- data/lib/cisco_node_utils/bridge_domain.rb +183 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +85 -2
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/client/client.rb +234 -0
- data/lib/cisco_node_utils/client/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +311 -0
- data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
- data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
- data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
- data/lib/cisco_node_utils/client/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +305 -0
- data/lib/cisco_node_utils/client/utils.rb +164 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +222 -254
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +22 -15
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +11 -8
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +21 -16
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +239 -109
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +114 -55
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +76 -52
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +106 -62
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +35 -14
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +23 -17
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +94 -83
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +22 -17
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +76 -26
- data/lib/cisco_node_utils/cmd_ref/images.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +381 -153
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +21 -21
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +30 -21
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +18 -13
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +26 -31
- data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
- data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +17 -6
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +10 -3
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +17 -5
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +33 -29
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +12 -10
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +16 -19
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +40 -25
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +17 -12
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +71 -35
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +10 -5
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +6 -2
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +47 -43
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +13 -11
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +4 -2
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +23 -21
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +26 -22
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +19 -17
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +18 -6
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +234 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +24 -9
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +5 -3
- data/lib/cisco_node_utils/cmd_ref/system.yaml +4 -3
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +22 -20
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +27 -15
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +45 -16
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +21 -11
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +3 -2
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +60 -32
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +118 -101
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +54 -58
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +118 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +19 -25
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +28 -18
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +34 -17
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +6 -4
- data/lib/cisco_node_utils/command_reference.rb +261 -142
- data/lib/cisco_node_utils/constants.rb +33 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +102 -0
- data/lib/cisco_node_utils/evpn_vni.rb +5 -3
- data/lib/cisco_node_utils/exceptions.rb +111 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +52 -35
- data/lib/cisco_node_utils/fabricpath_topology.rb +44 -57
- data/lib/cisco_node_utils/feature.rb +165 -3
- data/lib/cisco_node_utils/interface.rb +1051 -260
- data/lib/cisco_node_utils/interface_channel_group.rb +11 -10
- data/lib/cisco_node_utils/interface_ospf.rb +1 -2
- data/lib/cisco_node_utils/interface_portchannel.rb +4 -12
- data/lib/cisco_node_utils/interface_service_vni.rb +7 -7
- data/lib/cisco_node_utils/itd_device_group.rb +248 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +523 -0
- data/lib/cisco_node_utils/logger.rb +75 -0
- data/lib/cisco_node_utils/node.rb +62 -192
- data/lib/cisco_node_utils/node_util.rb +56 -10
- data/lib/cisco_node_utils/overlay_global.rb +2 -2
- data/lib/cisco_node_utils/pim.rb +2 -13
- data/lib/cisco_node_utils/pim_group_list.rb +1 -1
- data/lib/cisco_node_utils/pim_rp_address.rb +1 -1
- data/lib/cisco_node_utils/platform.rb +52 -21
- data/lib/cisco_node_utils/portchannel_global.rb +89 -19
- data/lib/cisco_node_utils/radius_server.rb +168 -37
- data/lib/cisco_node_utils/router_ospf.rb +20 -35
- data/lib/cisco_node_utils/router_ospf_vrf.rb +4 -4
- data/lib/cisco_node_utils/snmpserver.rb +1 -6
- data/lib/cisco_node_utils/snmpuser.rb +6 -4
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_server.rb +77 -18
- data/lib/cisco_node_utils/syslog_settings.rb +1 -1
- data/lib/cisco_node_utils/tacacs_server_group.rb +8 -4
- data/lib/cisco_node_utils/tacacs_server_host.rb +115 -25
- data/lib/cisco_node_utils/vdc.rb +12 -0
- data/lib/cisco_node_utils/version.rb +1 -1
- data/lib/cisco_node_utils/vlan.rb +147 -29
- data/lib/cisco_node_utils/vpc.rb +55 -3
- data/lib/cisco_node_utils/vrf.rb +72 -11
- data/lib/cisco_node_utils/vrf_af.rb +114 -29
- data/lib/cisco_node_utils/vtp.rb +34 -52
- data/lib/cisco_node_utils/vxlan_vtep.rb +34 -8
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +36 -4
- data/lib/minitest/environment_plugin.rb +31 -0
- data/lib/minitest/log_level_plugin.rb +41 -0
- data/spec/client_spec.rb +7 -0
- data/spec/environment_spec.rb +263 -0
- data/spec/grpc_client_spec.rb +23 -0
- data/spec/isolate/all_clients_spec.rb +9 -0
- data/spec/isolate/grpc_only_spec.rb +16 -0
- data/spec/isolate/no_clients_spec.rb +26 -0
- data/spec/isolate/nxapi_only_spec.rb +16 -0
- data/spec/nxapi_client_spec.rb +42 -0
- data/spec/schema.yaml +75 -0
- data/spec/shared_examples_for_clients.rb +14 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/whitespace_spec.rb +10 -0
- data/spec/yaml_spec.rb +42 -0
- data/tests/.rubocop.yml +2 -2
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +96 -36
- data/tests/ciscotest.rb +220 -12
- data/tests/cmd_config.yaml +71 -49
- data/tests/cmd_config_invalid.yaml +1 -1
- data/tests/test_aaa_authentication_login.rb +1 -0
- data/tests/test_aaa_authentication_login_service.rb +9 -0
- data/tests/test_aaa_authorization_service.rb +173 -367
- data/tests/test_ace.rb +171 -100
- data/tests/test_acl.rb +10 -1
- data/tests/test_bgp_af.rb +395 -728
- data/tests/test_bgp_neighbor.rb +274 -115
- data/tests/test_bgp_neighbor_af.rb +178 -77
- data/tests/test_bridge_domain.rb +191 -0
- data/tests/test_bridge_domain_vni.rb +116 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_command_config.rb +9 -5
- data/tests/test_command_reference.rb +380 -102
- data/tests/test_dns_domain.rb +13 -3
- data/tests/test_domain_name.rb +13 -3
- data/tests/test_encapsulation.rb +77 -0
- data/tests/test_evpn_vni.rb +25 -7
- data/tests/test_fabricpath_global.rb +167 -163
- data/tests/test_fabricpath_topology.rb +12 -33
- data/tests/test_feature.rb +215 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_interface.rb +585 -344
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +6 -3
- data/tests/test_interface_ospf.rb +26 -24
- data/tests/test_interface_portchannel.rb +1 -0
- data/tests/test_interface_private_vlan.rb +724 -0
- data/tests/test_interface_service_vni.rb +37 -66
- data/tests/test_interface_svi.rb +98 -101
- data/tests/test_interface_switchport.rb +419 -549
- data/tests/test_itd_device_group.rb +145 -0
- data/tests/test_itd_device_group_node.rb +199 -0
- data/tests/test_itd_service.rb +298 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +11 -2
- data/tests/test_node.rb +16 -75
- data/tests/test_node_ext.rb +174 -163
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_config.rb +5 -1
- data/tests/test_ntp_server.rb +2 -2
- data/tests/test_nxapi.rb +221 -0
- data/tests/test_overlay_global.rb +47 -38
- data/tests/test_pim.rb +2 -0
- data/tests/test_pim_group_list.rb +2 -0
- data/tests/test_pim_rp_address.rb +2 -0
- data/tests/test_platform.rb +86 -39
- data/tests/test_portchannel_global.rb +211 -135
- data/tests/test_radius_global.rb +13 -5
- data/tests/test_radius_server.rb +256 -104
- data/tests/test_radius_server_group.rb +2 -0
- data/tests/test_router_bgp.rb +781 -485
- data/tests/test_router_ospf.rb +26 -103
- data/tests/test_router_ospf_vrf.rb +52 -57
- data/tests/test_snmp_notification_receiver.rb +2 -0
- data/tests/test_snmpcommunity.rb +2 -0
- data/tests/test_snmpgroup.rb +2 -0
- data/tests/test_snmpnotification.rb +40 -21
- data/tests/test_snmpserver.rb +2 -0
- data/tests/test_snmpuser.rb +2 -0
- data/tests/test_stp_global.rb +563 -0
- data/tests/test_syslog_server.rb +32 -8
- data/tests/test_syslog_settings.rb +22 -9
- data/tests/test_tacacs_server.rb +32 -27
- data/tests/test_tacacs_server_group.rb +100 -45
- data/tests/test_tacacs_server_host.rb +135 -43
- data/tests/test_vdc.rb +2 -16
- data/tests/test_vlan.rb +106 -54
- data/tests/test_vlan_mt_full.rb +11 -21
- data/tests/test_vlan_private.rb +669 -0
- data/tests/test_vpc.rb +312 -159
- data/tests/test_vrf.rb +122 -113
- data/tests/test_vrf_af.rb +238 -0
- data/tests/test_vtp.rb +58 -102
- data/tests/test_vxlan_vtep.rb +38 -17
- data/tests/test_vxlan_vtep_vni.rb +61 -9
- data/tests/test_yum.rb +49 -25
- metadata +122 -36
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +0 -9
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +0 -76
- data/lib/cisco_node_utils/vni.rb +0 -227
- data/tests/test_vni.rb +0 -106
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Copyright (c) 2016 Cisco and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/interface'
|
|
17
|
+
require_relative '../lib/cisco_node_utils/bridge_domain'
|
|
18
|
+
|
|
19
|
+
include Cisco
|
|
20
|
+
|
|
21
|
+
# TestBdi - Minitest for Interface configuration of BDI interfaces.
|
|
22
|
+
class TestBdi < CiscoTestCase
|
|
23
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
|
24
|
+
attr_reader :bdi
|
|
25
|
+
|
|
26
|
+
def self.runnable_methods
|
|
27
|
+
# We don't have a separate YAML file to key off, so we check platform
|
|
28
|
+
return super if node.product_id[/N7/]
|
|
29
|
+
remove_method :setup
|
|
30
|
+
remove_method :teardown
|
|
31
|
+
[:unsupported]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def unsupported
|
|
35
|
+
skip("Skipping #{self.class}; Bdi interfaces are not supported on the \
|
|
36
|
+
platform")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def setup
|
|
40
|
+
super
|
|
41
|
+
remove_all_bdis if @@pre_clean_needed
|
|
42
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
|
43
|
+
BridgeDomain.new('100')
|
|
44
|
+
@bdi = Interface.new('Bdi100')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def remove_all_bdis
|
|
48
|
+
Interface.interfaces.each do |int, obj|
|
|
49
|
+
next unless int[/bdi/i]
|
|
50
|
+
obj.destroy
|
|
51
|
+
end
|
|
52
|
+
remove_all_bridge_domains
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def teardown
|
|
56
|
+
remove_all_bdis
|
|
57
|
+
super
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_create_and_check_all_properties
|
|
61
|
+
# Check all the default values
|
|
62
|
+
assert_equal(@bdi.default_vrf, @bdi.vrf)
|
|
63
|
+
assert_equal(@bdi.default_ipv4_address, @bdi.ipv4_address)
|
|
64
|
+
assert_equal(@bdi.default_ipv4_netmask_length, @bdi.ipv4_netmask_length)
|
|
65
|
+
address = '8.7.1.1'
|
|
66
|
+
length = 15
|
|
67
|
+
|
|
68
|
+
@bdi.ipv4_addr_mask_set(address, length)
|
|
69
|
+
assert_equal(address, @bdi.ipv4_address,
|
|
70
|
+
'Error: ipv4 address get value mismatch')
|
|
71
|
+
assert_equal(length, @bdi.ipv4_netmask_length,
|
|
72
|
+
'Error: ipv4 netmask length get value mismatch')
|
|
73
|
+
|
|
74
|
+
vrf = 'test'
|
|
75
|
+
@bdi.vrf = vrf
|
|
76
|
+
assert_equal(vrf, @bdi.vrf)
|
|
77
|
+
@bdi.vrf = ''
|
|
78
|
+
assert_equal(@bdi.default_vrf, @bdi.vrf)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
@@ -23,12 +23,12 @@ class TestInterfaceChannelGroup < CiscoTestCase
|
|
|
23
23
|
@intf = InterfaceChannelGroup.new(interfaces[1])
|
|
24
24
|
|
|
25
25
|
# Only pre-clean interface on initial setup
|
|
26
|
-
|
|
26
|
+
interface_cleanup(@intf.name) unless @@clean
|
|
27
27
|
@@clean = true # rubocop:disable Style/ClassVars
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def teardown
|
|
31
|
-
|
|
31
|
+
interface_cleanup(@intf.name)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def test_channel_group
|
|
@@ -44,6 +44,9 @@ class TestInterfaceChannelGroup < CiscoTestCase
|
|
|
44
44
|
group = i.default_channel_group
|
|
45
45
|
i.channel_group = group
|
|
46
46
|
assert_equal(group, i.channel_group)
|
|
47
|
+
rescue Cisco::UnsupportedError => e
|
|
48
|
+
# Some platforms only support channel-group with certain software versions
|
|
49
|
+
skip(e.to_s)
|
|
47
50
|
end
|
|
48
51
|
|
|
49
52
|
def test_description
|
|
@@ -69,6 +72,6 @@ class TestInterfaceChannelGroup < CiscoTestCase
|
|
|
69
72
|
refute(i.shutdown)
|
|
70
73
|
|
|
71
74
|
i.shutdown = i.default_shutdown
|
|
72
|
-
|
|
75
|
+
assert_equal(i.default_shutdown, i.shutdown)
|
|
73
76
|
end
|
|
74
77
|
end
|
|
@@ -21,6 +21,8 @@ include Cisco
|
|
|
21
21
|
|
|
22
22
|
# TestInterfaceOspf - Minitest for InterfaceOspf node utility class.
|
|
23
23
|
class TestInterfaceOspf < CiscoTestCase
|
|
24
|
+
@skip_unless_supported = 'interface_ospf'
|
|
25
|
+
|
|
24
26
|
def setup
|
|
25
27
|
super
|
|
26
28
|
config 'no feature ospf'
|
|
@@ -83,7 +85,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
83
85
|
config('no interface loopback12')
|
|
84
86
|
end
|
|
85
87
|
|
|
86
|
-
def
|
|
88
|
+
def test_collection_empty
|
|
87
89
|
config('no feature ospf', 'feature ospf', 'router ospf TestOSPF')
|
|
88
90
|
|
|
89
91
|
routers = RouterOspf.routers()
|
|
@@ -94,7 +96,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
94
96
|
end
|
|
95
97
|
end
|
|
96
98
|
|
|
97
|
-
def
|
|
99
|
+
def test_collection_not_empty
|
|
98
100
|
ifname1 = interfaces[1].downcase
|
|
99
101
|
ifname2 = interfaces[2].downcase
|
|
100
102
|
ospf1 = 'TestOSPF'
|
|
@@ -152,13 +154,13 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
152
154
|
end
|
|
153
155
|
end
|
|
154
156
|
|
|
155
|
-
def
|
|
157
|
+
def test_create_routerospf_nil
|
|
156
158
|
assert_raises(TypeError) do
|
|
157
159
|
InterfaceOspf.new(interfaces[0], nil, '0.0.0.0')
|
|
158
160
|
end
|
|
159
161
|
end
|
|
160
162
|
|
|
161
|
-
def
|
|
163
|
+
def test_create_interface_name_zero_length
|
|
162
164
|
name = 'ospfTest'
|
|
163
165
|
ospf = RouterOspf.new(name)
|
|
164
166
|
assert_raises(ArgumentError) do
|
|
@@ -166,7 +168,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
166
168
|
end
|
|
167
169
|
end
|
|
168
170
|
|
|
169
|
-
def
|
|
171
|
+
def test_create_interface_area_zero_length
|
|
170
172
|
name = 'ospfTest'
|
|
171
173
|
ospf = RouterOspf.new(name)
|
|
172
174
|
assert_raises(ArgumentError) do
|
|
@@ -189,7 +191,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
189
191
|
'Error: area get value mismatch ')
|
|
190
192
|
end
|
|
191
193
|
|
|
192
|
-
def
|
|
194
|
+
def test_destroy
|
|
193
195
|
ifname = interfaces[1]
|
|
194
196
|
area = '0.0.0.0'
|
|
195
197
|
ospf = create_routerospf
|
|
@@ -219,7 +221,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
219
221
|
assert_equal(ospf.name, interface.ospf_name)
|
|
220
222
|
end
|
|
221
223
|
|
|
222
|
-
def
|
|
224
|
+
def test_cost_invalid_range
|
|
223
225
|
ospf = create_routerospf
|
|
224
226
|
interface = create_interfaceospf(ospf)
|
|
225
227
|
# upper range
|
|
@@ -232,7 +234,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
232
234
|
# end
|
|
233
235
|
end
|
|
234
236
|
|
|
235
|
-
def
|
|
237
|
+
def test_cost
|
|
236
238
|
ospf = create_routerospf
|
|
237
239
|
interface = create_interfaceospf(ospf)
|
|
238
240
|
cost = 1000
|
|
@@ -248,7 +250,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
248
250
|
msg: 'Error: default cost set failed')
|
|
249
251
|
end
|
|
250
252
|
|
|
251
|
-
def
|
|
253
|
+
def test_hello_interval_invalid_range
|
|
252
254
|
ospf = create_routerospf
|
|
253
255
|
interface = create_interfaceospf(ospf)
|
|
254
256
|
# upper range
|
|
@@ -261,7 +263,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
261
263
|
end
|
|
262
264
|
end
|
|
263
265
|
|
|
264
|
-
def
|
|
266
|
+
def test_hello_interval
|
|
265
267
|
ospf = create_routerospf
|
|
266
268
|
interface = create_interfaceospf(ospf)
|
|
267
269
|
interval = 90
|
|
@@ -278,7 +280,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
278
280
|
msg: 'Error: default hello-interval set failed')
|
|
279
281
|
end
|
|
280
282
|
|
|
281
|
-
def
|
|
283
|
+
def test_dead_interval_invalid_range
|
|
282
284
|
ospf = create_routerospf
|
|
283
285
|
interface = create_interfaceospf(ospf)
|
|
284
286
|
|
|
@@ -295,7 +297,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
295
297
|
end
|
|
296
298
|
end
|
|
297
299
|
|
|
298
|
-
def
|
|
300
|
+
def test_dead_interval
|
|
299
301
|
ospf = create_routerospf
|
|
300
302
|
interface = create_interfaceospf(ospf)
|
|
301
303
|
interval = 150
|
|
@@ -312,7 +314,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
312
314
|
msg: 'Error: default dead-interval set failed')
|
|
313
315
|
end
|
|
314
316
|
|
|
315
|
-
def
|
|
317
|
+
def test_passive_interface
|
|
316
318
|
ospf = create_routerospf
|
|
317
319
|
interface = create_interfaceospf(ospf)
|
|
318
320
|
|
|
@@ -329,7 +331,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
329
331
|
msg: 'default passive interface set failed')
|
|
330
332
|
end
|
|
331
333
|
|
|
332
|
-
def
|
|
334
|
+
def test_create_valid_multiple
|
|
333
335
|
# ospf and interfaces[0]
|
|
334
336
|
ospf = create_routerospf
|
|
335
337
|
interface = create_interfaceospf(ospf)
|
|
@@ -346,7 +348,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
346
348
|
msg: "'ip router ospf #{ospf.name} area #{area}' is not configured")
|
|
347
349
|
end
|
|
348
350
|
|
|
349
|
-
def
|
|
351
|
+
def test_create_multiple_delete_one
|
|
350
352
|
# ospf and interfaces[0]
|
|
351
353
|
ospf = create_routerospf
|
|
352
354
|
interface = create_interfaceospf(ospf)
|
|
@@ -387,7 +389,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
387
389
|
end
|
|
388
390
|
# puts "k1: #{k1}, k: #{k}, area #{v1[:area]}"
|
|
389
391
|
cfg << "ip router ospf #{k} area #{v1[:area]}"
|
|
390
|
-
cfg << "ip ospf cost #{v1[:cost]}" unless v1[:cost]
|
|
392
|
+
cfg << "ip ospf cost #{v1[:cost]}" unless v1[:cost] == 0
|
|
391
393
|
cfg << "ip ospf hello-interval #{v1[:hello]}" unless v1[:hello].nil?
|
|
392
394
|
cfg << "ip ospf dead-interval #{v1[:dead]}" unless v1[:dead].nil?
|
|
393
395
|
cfg << 'ip ospf passive-interface' if !v1[:pass].nil? &&
|
|
@@ -432,7 +434,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
432
434
|
end
|
|
433
435
|
end
|
|
434
436
|
|
|
435
|
-
def
|
|
437
|
+
def test_collection_multiple_interface
|
|
436
438
|
s = config('int port-channel 42', 'descr foo')
|
|
437
439
|
known_failure = s[/ERROR:.*port channel not present/]
|
|
438
440
|
refute(known_failure, 'ERROR: port channel not present')
|
|
@@ -443,9 +445,9 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
443
445
|
config('no feature ospf',
|
|
444
446
|
'feature ospf',
|
|
445
447
|
'feature interface-vlan',
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
448
|
+
"default interface #{interfaces[0]}",
|
|
449
|
+
"default interface #{interfaces[1]}",
|
|
450
|
+
"default interface #{interfaces[2]}",
|
|
449
451
|
)
|
|
450
452
|
|
|
451
453
|
# pre-configure
|
|
@@ -490,7 +492,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
490
492
|
end # ospf_h each
|
|
491
493
|
end
|
|
492
494
|
|
|
493
|
-
def
|
|
495
|
+
def test_message_digest
|
|
494
496
|
ospf = create_routerospf
|
|
495
497
|
interface = create_interfaceospf(ospf)
|
|
496
498
|
|
|
@@ -510,7 +512,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
510
512
|
'Error: message digest is true but should be false (default)')
|
|
511
513
|
end
|
|
512
514
|
|
|
513
|
-
def
|
|
515
|
+
def test_message_digest_key
|
|
514
516
|
ospf = create_routerospf
|
|
515
517
|
interface = create_interfaceospf(ospf)
|
|
516
518
|
# auth params
|
|
@@ -575,7 +577,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
575
577
|
assert_equal(encr, interface.message_digest_encryption_type)
|
|
576
578
|
end
|
|
577
579
|
|
|
578
|
-
def
|
|
580
|
+
def test_message_digest_key_invalid_password
|
|
579
581
|
ospf = create_routerospf
|
|
580
582
|
interface = create_interfaceospf(ospf)
|
|
581
583
|
|
|
@@ -596,7 +598,7 @@ class TestInterfaceOspf < CiscoTestCase
|
|
|
596
598
|
end
|
|
597
599
|
end
|
|
598
600
|
|
|
599
|
-
def
|
|
601
|
+
def test_nonexistent
|
|
600
602
|
# If the interface does exist but the OSPF instance does not, this is OK
|
|
601
603
|
config('interface loopback122')
|
|
602
604
|
interface = InterfaceOspf.new('loopback122', 'nonexistentOspf', '0')
|
|
@@ -18,6 +18,7 @@ require_relative '../lib/cisco_node_utils/interface_portchannel'
|
|
|
18
18
|
|
|
19
19
|
# TestX__CLASS_NAME__X - Minitest for X__CLASS_NAME__X node utility class
|
|
20
20
|
class TestInterfacePortChannel < CiscoTestCase
|
|
21
|
+
@skip_unless_supported = 'interface_portchannel'
|
|
21
22
|
# TESTS
|
|
22
23
|
|
|
23
24
|
DEFAULT_NAME = 'port-channel134'
|
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/interface'
|
|
17
|
+
require_relative '../lib/cisco_node_utils/vlan'
|
|
18
|
+
|
|
19
|
+
include Cisco
|
|
20
|
+
|
|
21
|
+
# TestInterfaceSwitchport
|
|
22
|
+
# Parent class for specific types of switchport tests (below)
|
|
23
|
+
class TestInterfaceSwitchport < CiscoTestCase
|
|
24
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
|
25
|
+
attr_reader :interface
|
|
26
|
+
|
|
27
|
+
def setup
|
|
28
|
+
super
|
|
29
|
+
@interface = Interface.new(interfaces[0])
|
|
30
|
+
cleanup if @@pre_clean_needed
|
|
31
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def teardown
|
|
35
|
+
cleanup
|
|
36
|
+
super
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def cleanup
|
|
40
|
+
remove_svis
|
|
41
|
+
cleanup_pvlan_intfs
|
|
42
|
+
remove_all_vlans
|
|
43
|
+
config_no_warn('no feature private-vlan', 'no feature vtp')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def remove_svis
|
|
47
|
+
Interface.interfaces.each do |name, _i|
|
|
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)
|
|
55
|
+
pvlan_intfs.keys.each { |name| interface_cleanup(name) }
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# TestSwitchport - general interface switchport tests.
|
|
60
|
+
class TestSwitchport < TestInterfaceSwitchport
|
|
61
|
+
def test_interface_switchport_private_host_mode
|
|
62
|
+
if validate_property_excluded?('interface',
|
|
63
|
+
'switchport_mode_private_vlan_host')
|
|
64
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
65
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
66
|
+
end
|
|
67
|
+
return
|
|
68
|
+
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
|
+
|
|
81
|
+
def test_interface_switchport_private_trunk_promisc
|
|
82
|
+
if validate_property_excluded?(
|
|
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
|
|
94
|
+
|
|
95
|
+
def test_interface_switchport_private_trunk_secondary
|
|
96
|
+
if validate_property_excluded?(
|
|
97
|
+
'interface',
|
|
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
|
|
108
|
+
|
|
109
|
+
def test_interface_no_switchport_private_host_mode
|
|
110
|
+
if validate_property_excluded?('interface',
|
|
111
|
+
'switchport_mode_private_vlan_host')
|
|
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
|
|
131
|
+
|
|
132
|
+
def test_interface_no_switchport_private_trunk_mode
|
|
133
|
+
if validate_property_excluded?(
|
|
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')
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_interface_switchport_private_host_association
|
|
150
|
+
if validate_property_excluded?('interface',
|
|
151
|
+
'switchport_mode_private_vlan_host')
|
|
152
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
153
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
154
|
+
end
|
|
155
|
+
return
|
|
156
|
+
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
|
+
|
|
175
|
+
def test_interface_switchport_pvlan_host_assoc_change
|
|
176
|
+
if validate_property_excluded?('interface',
|
|
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
|
|
219
|
+
|
|
220
|
+
def test_interface_switchport_no_pvlan_host_assoc
|
|
221
|
+
if validate_property_excluded?('interface',
|
|
222
|
+
'switchport_mode_private_vlan_host')
|
|
223
|
+
|
|
224
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
225
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
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')
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def test_interface_switchport_pvlan_host_assoc_default
|
|
251
|
+
if validate_property_excluded?('interface',
|
|
252
|
+
'switchport_mode_private_vlan_host')
|
|
253
|
+
|
|
254
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
255
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
256
|
+
end
|
|
257
|
+
return
|
|
258
|
+
end
|
|
259
|
+
val = interface.default_switchport_mode_private_vlan_host_association
|
|
260
|
+
assert_equal(val, interface.switchport_mode_private_vlan_host_association,
|
|
261
|
+
'Err: host association failed')
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def test_interface_switchport_pvlan_host_assoc_bad_arg
|
|
265
|
+
if validate_property_excluded?('interface',
|
|
266
|
+
'switchport_mode_private_vlan_host')
|
|
267
|
+
|
|
268
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
269
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
270
|
+
end
|
|
271
|
+
return
|
|
272
|
+
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
|
+
|
|
277
|
+
input = %w(10)
|
|
278
|
+
assert_raises(CliError) do
|
|
279
|
+
interface.switchport_mode_private_vlan_host_association = input
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
input = %w(10 ten)
|
|
283
|
+
assert_raises(CliError) do
|
|
284
|
+
interface.switchport_mode_private_vlan_host_association = input
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
input = %w(10,12)
|
|
288
|
+
assert_raises(CliError) do
|
|
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
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
def test_interface_switchport_pvlan_host_primisc_default
|
|
300
|
+
if validate_property_excluded?('interface',
|
|
301
|
+
'switchport_mode_private_vlan_host')
|
|
302
|
+
|
|
303
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
304
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
305
|
+
end
|
|
306
|
+
return
|
|
307
|
+
end
|
|
308
|
+
val = interface.default_switchport_mode_private_vlan_host_promisc
|
|
309
|
+
assert_equal(val, interface.switchport_mode_private_vlan_host_promisc,
|
|
310
|
+
'Err: promisc association failed')
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def test_interface_switchport_private_host_promisc
|
|
314
|
+
if validate_property_excluded?('interface',
|
|
315
|
+
'switchport_mode_private_vlan_host')
|
|
316
|
+
|
|
317
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
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')
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
def test_interface_switchport_private_host_promisc_bad_arg
|
|
369
|
+
if validate_property_excluded?('interface',
|
|
370
|
+
'switchport_mode_private_vlan_host')
|
|
371
|
+
|
|
372
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
373
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
374
|
+
end
|
|
375
|
+
return
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
input = %w(10)
|
|
379
|
+
interface.switchport_mode_private_vlan_host = :promiscuous
|
|
380
|
+
assert_equal(:promiscuous, interface.switchport_mode_private_vlan_host,
|
|
381
|
+
'Error: Switchport mode not as expected')
|
|
382
|
+
|
|
383
|
+
assert_raises(TypeError, 'private vlan host promisc raise typeError') do
|
|
384
|
+
interface.switchport_mode_private_vlan_host_promisc = input
|
|
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
|
|
402
|
+
|
|
403
|
+
input = %w(10 10)
|
|
404
|
+
assert_raises(CliError) do
|
|
405
|
+
interface.switchport_mode_private_vlan_host_promisc = input
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
input = %w(10 10)
|
|
409
|
+
assert_raises(RuntimeError,
|
|
410
|
+
'promisc association did not raise RuntimeError') do
|
|
411
|
+
interface.switchport_mode_private_vlan_host_promisc = input
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
def test_interface_no_switchport_private_host_promisc
|
|
416
|
+
if validate_property_excluded?('interface',
|
|
417
|
+
'switchport_mode_private_vlan_host')
|
|
418
|
+
|
|
419
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
420
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
421
|
+
end
|
|
422
|
+
return
|
|
423
|
+
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
|
+
|
|
445
|
+
def test_interface_switchport_pvlan_trunk_allow_default
|
|
446
|
+
if validate_property_excluded?('interface',
|
|
447
|
+
'switchport_mode_private_vlan_host')
|
|
448
|
+
|
|
449
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
450
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
451
|
+
end
|
|
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
|
|
458
|
+
|
|
459
|
+
def test_interface_switchport_pvlan_trunk_allow_bad_arg
|
|
460
|
+
if validate_property_excluded?('interface',
|
|
461
|
+
'switchport_mode_private_vlan_host')
|
|
462
|
+
|
|
463
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
464
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
465
|
+
end
|
|
466
|
+
return
|
|
467
|
+
end
|
|
468
|
+
input = %w(ten)
|
|
469
|
+
assert_raises(CliError) do
|
|
470
|
+
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
input = %w(5000)
|
|
474
|
+
assert_raises(CliError) do
|
|
475
|
+
interface.switchport_private_vlan_trunk_allowed_vlan = input
|
|
476
|
+
end
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
def test_interface_switchport_pvlan_trunk_allow
|
|
480
|
+
if validate_property_excluded?('interface',
|
|
481
|
+
'switchport_mode_private_vlan_host')
|
|
482
|
+
|
|
483
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
484
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
485
|
+
end
|
|
486
|
+
return
|
|
487
|
+
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
|
+
|
|
511
|
+
def test_interface_switchport_pvlan_trunk_native_vlan_bad_arg
|
|
512
|
+
if validate_property_excluded?('interface',
|
|
513
|
+
'switchport_mode_private_vlan_host')
|
|
514
|
+
|
|
515
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
516
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
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
|
|
524
|
+
|
|
525
|
+
input = 5000
|
|
526
|
+
assert_raises(CliError) do
|
|
527
|
+
interface.switchport_private_vlan_trunk_native_vlan = input
|
|
528
|
+
end
|
|
529
|
+
end
|
|
530
|
+
|
|
531
|
+
def test_interface_switchport_pvlan_trunk_native_default
|
|
532
|
+
if validate_property_excluded?('interface',
|
|
533
|
+
'switchport_mode_private_vlan_host')
|
|
534
|
+
|
|
535
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
536
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
537
|
+
end
|
|
538
|
+
return
|
|
539
|
+
end
|
|
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')
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
def test_interface_switchport_pvlan_trunk_native_vlan
|
|
546
|
+
if validate_property_excluded?('interface',
|
|
547
|
+
'switchport_mode_private_vlan_host')
|
|
548
|
+
|
|
549
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
550
|
+
interface.switchport_mode_private_vlan_host = :host
|
|
551
|
+
end
|
|
552
|
+
return
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
input = 10
|
|
556
|
+
interface.switchport_private_vlan_trunk_native_vlan = input
|
|
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
|
|
575
|
+
|
|
576
|
+
def test_interface_switchport_pvlan_association_trunk
|
|
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
|
|
607
|
+
|
|
608
|
+
def test_interface_switchport_pvlan_trunk_assoc_vlan_bad_arg
|
|
609
|
+
if validate_property_excluded?('interface',
|
|
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
|
|
618
|
+
|
|
619
|
+
input = %w(10 5000)
|
|
620
|
+
assert_raises(CliError) do
|
|
621
|
+
interface.switchport_private_vlan_association_trunk = input
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
input = %w(10)
|
|
625
|
+
assert_raises(CliError) do
|
|
626
|
+
interface.switchport_private_vlan_association_trunk = input
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
input = '10'
|
|
630
|
+
assert_raises(TypeError,
|
|
631
|
+
'private vlan trunk association raise typeError') do
|
|
632
|
+
interface.switchport_private_vlan_association_trunk = input
|
|
633
|
+
end
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
def test_interface_switchport_pvlan_trunk_assocciation_default
|
|
637
|
+
if validate_property_excluded?('interface',
|
|
638
|
+
'switchport_private_vlan_association_trunk')
|
|
639
|
+
assert_nil(interface.switchport_private_vlan_association_trunk)
|
|
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
|
|
646
|
+
|
|
647
|
+
def test_interface_switchport_pvlan_mapping_trunk_default
|
|
648
|
+
if validate_property_excluded?('interface',
|
|
649
|
+
'switchport_private_vlan_mapping_trunk')
|
|
650
|
+
|
|
651
|
+
assert_nil(interface.switchport_private_vlan_mapping_trunk)
|
|
652
|
+
return
|
|
653
|
+
end
|
|
654
|
+
val = interface.default_switchport_private_vlan_mapping_trunk
|
|
655
|
+
assert_equal(val, interface.switchport_private_vlan_mapping_trunk,
|
|
656
|
+
'Err: mapping trunk failed')
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
def test_interface_switchport_pvlan_mapping_trunk
|
|
660
|
+
if validate_property_excluded?('interface',
|
|
661
|
+
'switchport_private_vlan_mapping_trunk')
|
|
662
|
+
assert_nil(interface.switchport_private_vlan_mapping_trunk)
|
|
663
|
+
return
|
|
664
|
+
end
|
|
665
|
+
input = %w(10 11)
|
|
666
|
+
result = '10 11'
|
|
667
|
+
interface.switchport_private_vlan_mapping_trunk = input
|
|
668
|
+
input = interface.switchport_private_vlan_mapping_trunk
|
|
669
|
+
assert_includes(input, result,
|
|
670
|
+
'Err: wrong config for switchport private mapping trunk ')
|
|
671
|
+
|
|
672
|
+
input = %w(10 12)
|
|
673
|
+
result = '10 12'
|
|
674
|
+
interface.switchport_private_vlan_mapping_trunk = input
|
|
675
|
+
input = interface.switchport_private_vlan_mapping_trunk
|
|
676
|
+
assert_includes(input, result,
|
|
677
|
+
'Err: wrong config for switchport private mapping trunk ')
|
|
678
|
+
|
|
679
|
+
input = %w(20 21)
|
|
680
|
+
result = '20 21'
|
|
681
|
+
interface.switchport_private_vlan_mapping_trunk = input
|
|
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)
|
|
689
|
+
end
|
|
690
|
+
|
|
691
|
+
def test_interface_switchport_pvlan_mapping_trunk_bad_arg
|
|
692
|
+
if validate_property_excluded?('interface',
|
|
693
|
+
'switchport_private_vlan_mapping_trunk')
|
|
694
|
+
assert_nil(interface.switchport_private_vlan_mapping_trunk)
|
|
695
|
+
return
|
|
696
|
+
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
|
+
|
|
707
|
+
input = %w(10)
|
|
708
|
+
assert_raises(CliError) do
|
|
709
|
+
interface.switchport_private_vlan_mapping_trunk = input
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
input = '10'
|
|
713
|
+
assert_raises(TypeError,
|
|
714
|
+
'private vlan mapping trunk raise typeError') do
|
|
715
|
+
interface.switchport_private_vlan_mapping_trunk = input
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
input = %w(10 20-148)
|
|
719
|
+
assert_raises(RuntimeError,
|
|
720
|
+
'mapping trunk did not raise RuntimeError') do
|
|
721
|
+
interface.switchport_private_vlan_mapping_trunk = input
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
end
|