cisco_node_utils_mgx 2.1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +96 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +676 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +10 -0
- data/LICENSE +201 -0
- data/README.md +246 -0
- data/Rakefile +44 -0
- data/SUPPORT.md +3 -0
- data/bin/.rubocop.yml +18 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +89 -0
- data/bin/git/hooks/hook_lib +115 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +25 -0
- data/bin/git/hooks/pre-commit/validate-diffs +45 -0
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +123 -0
- data/bin/show_running_yang.rb +233 -0
- data/cisco_node_utils.gemspec +41 -0
- data/docs/README-develop-best-practices.md +521 -0
- data/docs/README-develop-node-utils-APIs.md +570 -0
- data/docs/README-maintainers.md +77 -0
- data/docs/README-test-execution.md +57 -0
- data/docs/README-utilities.md +14 -0
- data/docs/agent_files.png +0 -0
- data/docs/cisco_node_utils.yaml.example +36 -0
- data/docs/template-router.rb +123 -0
- data/docs/template-test_router.rb +104 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +95 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +138 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +156 -0
- data/lib/cisco_node_utils/ace.rb +467 -0
- data/lib/cisco_node_utils/acl.rb +101 -0
- data/lib/cisco_node_utils/banner.rb +63 -0
- data/lib/cisco_node_utils/bfd_global.rb +305 -0
- data/lib/cisco_node_utils/bgp.rb +988 -0
- data/lib/cisco_node_utils/bgp_af.rb +545 -0
- data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +527 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +780 -0
- data/lib/cisco_node_utils/bridge_domain.rb +178 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +444 -0
- data/lib/cisco_node_utils/client/client.rb +238 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +395 -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/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +368 -0
- data/lib/cisco_node_utils/client/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/utils.rb +180 -0
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +590 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/banner.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +383 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +223 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +174 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +236 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +128 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multicast.yaml +12 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multisite.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_stormcontrol.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +183 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +126 -0
- data/lib/cisco_node_utils/cmd_ref/hostname.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/hsrp_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +781 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/interface_evpn_multisite.yaml +17 -0
- data/lib/cisco_node_utils/cmd_ref/interface_hsrp_group.yaml +120 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +112 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +87 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/ip_multicast.yaml +22 -0
- 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 +24 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +27 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/object_group.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +91 -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 +37 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +100 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +19 -0
- data/lib/cisco_node_utils/cmd_ref/route_map.yaml +601 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +84 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +81 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +57 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +235 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_facility.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +63 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/upgrade.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +52 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +106 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +233 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +139 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +114 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +68 -0
- data/lib/cisco_node_utils/command_reference.rb +724 -0
- data/lib/cisco_node_utils/configparser_lib.rb +195 -0
- data/lib/cisco_node_utils/constants.rb +40 -0
- data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
- data/lib/cisco_node_utils/dns_domain.rb +93 -0
- data/lib/cisco_node_utils/domain_name.rb +82 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +110 -0
- data/lib/cisco_node_utils/evpn_multicast.rb +66 -0
- data/lib/cisco_node_utils/evpn_multisite.rb +96 -0
- data/lib/cisco_node_utils/evpn_stormcontrol.rb +84 -0
- data/lib/cisco_node_utils/evpn_vni.rb +159 -0
- data/lib/cisco_node_utils/exceptions.rb +140 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +405 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +137 -0
- data/lib/cisco_node_utils/feature.rb +377 -0
- data/lib/cisco_node_utils/hostname.rb +62 -0
- data/lib/cisco_node_utils/hsrp_global.rb +97 -0
- data/lib/cisco_node_utils/interface.rb +2128 -0
- data/lib/cisco_node_utils/interface_channel_group.rb +142 -0
- data/lib/cisco_node_utils/interface_evpn_multisite.rb +72 -0
- data/lib/cisco_node_utils/interface_hsrp_group.rb +557 -0
- data/lib/cisco_node_utils/interface_ospf.rb +378 -0
- data/lib/cisco_node_utils/interface_portchannel.rb +180 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/ip_multicast.rb +90 -0
- data/lib/cisco_node_utils/itd_device_group.rb +228 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +511 -0
- data/lib/cisco_node_utils/logger.rb +78 -0
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +443 -0
- data/lib/cisco_node_utils/node_util.rb +111 -0
- data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
- data/lib/cisco_node_utils/ntp_config.rb +83 -0
- data/lib/cisco_node_utils/ntp_server.rb +86 -0
- data/lib/cisco_node_utils/object_group.rb +75 -0
- data/lib/cisco_node_utils/object_group_entry.rb +143 -0
- data/lib/cisco_node_utils/overlay_global.rb +142 -0
- data/lib/cisco_node_utils/pim.rb +131 -0
- data/lib/cisco_node_utils/pim_group_list.rb +109 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +103 -0
- data/lib/cisco_node_utils/platform.rb +217 -0
- data/lib/cisco_node_utils/portchannel_global.rb +347 -0
- data/lib/cisco_node_utils/radius_global.rb +165 -0
- data/lib/cisco_node_utils/radius_server.rb +421 -0
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/route_map.rb +2540 -0
- data/lib/cisco_node_utils/router_ospf.rb +77 -0
- 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 +342 -0
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +176 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +109 -0
- data/lib/cisco_node_utils/snmpgroup.rb +54 -0
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +132 -0
- data/lib/cisco_node_utils/snmpuser.rb +403 -0
- data/lib/cisco_node_utils/span_session.rb +149 -0
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_facility.rb +64 -0
- data/lib/cisco_node_utils/syslog_server.rb +146 -0
- data/lib/cisco_node_utils/syslog_settings.rb +174 -0
- data/lib/cisco_node_utils/tacacs_global.rb +137 -0
- data/lib/cisco_node_utils/tacacs_server.rb +173 -0
- data/lib/cisco_node_utils/tacacs_server_group.rb +149 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +216 -0
- data/lib/cisco_node_utils/upgrade.rb +122 -0
- data/lib/cisco_node_utils/vdc.rb +118 -0
- data/lib/cisco_node_utils/version.rb +21 -0
- data/lib/cisco_node_utils/vlan.rb +301 -0
- data/lib/cisco_node_utils/vpc.rb +466 -0
- data/lib/cisco_node_utils/vrf.rb +192 -0
- data/lib/cisco_node_utils/vrf_af.rb +327 -0
- data/lib/cisco_node_utils/vtp.rb +125 -0
- data/lib/cisco_node_utils/vxlan_vtep.rb +286 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +331 -0
- data/lib/cisco_node_utils/yang.rb +160 -0
- data/lib/cisco_node_utils/yum.rb +213 -0
- data/lib/cisco_node_utils.rb +21 -0
- 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 +384 -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 +82 -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 +18 -0
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +243 -0
- data/tests/ciscotest.rb +577 -0
- data/tests/cmd_config.yaml +75 -0
- data/tests/cmd_config_invalid.yaml +16 -0
- data/tests/n9000_sample-1.0.0-7.0.3.x86_64.rpm +0 -0
- data/tests/noop.rb +7 -0
- data/tests/platform_info.rb +63 -0
- data/tests/tacacs_server.yaml.example +6 -0
- data/tests/test_aaa_authentication_login.rb +243 -0
- data/tests/test_aaa_authentication_login_service.rb +761 -0
- data/tests/test_aaa_authorization_service.rb +874 -0
- data/tests/test_ace.rb +304 -0
- data/tests/test_acl.rb +185 -0
- data/tests/test_banner.rb +85 -0
- data/tests/test_bfd_global.rb +272 -0
- data/tests/test_bgp_af.rb +875 -0
- data/tests/test_bgp_af_aa.rb +108 -0
- data/tests/test_bgp_neighbor.rb +596 -0
- data/tests/test_bgp_neighbor_af.rb +781 -0
- data/tests/test_bridge_domain.rb +198 -0
- data/tests/test_bridge_domain_vni.rb +109 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_cmn_utils.rb +76 -0
- data/tests/test_command_config.rb +206 -0
- data/tests/test_command_reference.rb +669 -0
- data/tests/test_dhcp_relay_global.rb +286 -0
- data/tests/test_dns_domain.rb +123 -0
- data/tests/test_domain_name.rb +96 -0
- data/tests/test_encapsulation.rb +75 -0
- data/tests/test_evpn_multicast.rb +65 -0
- data/tests/test_evpn_multisite.rb +70 -0
- data/tests/test_evpn_stormcontrol.rb +56 -0
- data/tests/test_evpn_vni.rb +131 -0
- data/tests/test_fabricpath_global.rb +246 -0
- data/tests/test_fabricpath_topology.rb +77 -0
- data/tests/test_feature.rb +272 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_hostname.rb +64 -0
- data/tests/test_hsrp_global.rb +79 -0
- data/tests/test_interface.rb +1958 -0
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +131 -0
- data/tests/test_interface_evpn_multisite.rb +94 -0
- data/tests/test_interface_hsrp.rb +134 -0
- data/tests/test_interface_hsrp_group.rb +570 -0
- data/tests/test_interface_ospf.rb +820 -0
- data/tests/test_interface_portchannel.rb +135 -0
- data/tests/test_interface_private_vlan.rb +365 -0
- data/tests/test_interface_service_vni.rb +203 -0
- data/tests/test_interface_svi.rb +210 -0
- data/tests/test_interface_switchport.rb +468 -0
- data/tests/test_ip_multicast.rb +80 -0
- 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 +314 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +94 -0
- data/tests/test_node.rb +50 -0
- data/tests/test_node_ext.rb +406 -0
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_auth_key.rb +77 -0
- data/tests/test_ntp_config.rb +100 -0
- data/tests/test_ntp_server.rb +146 -0
- data/tests/test_nxapi.rb +236 -0
- data/tests/test_object_group.rb +122 -0
- data/tests/test_overlay_global.rb +108 -0
- data/tests/test_pim.rb +203 -0
- data/tests/test_pim_group_list.rb +147 -0
- data/tests/test_pim_rp_address.rb +155 -0
- data/tests/test_platform.rb +254 -0
- data/tests/test_portchannel_global.rb +322 -0
- data/tests/test_radius_global.rb +108 -0
- data/tests/test_radius_server.rb +377 -0
- data/tests/test_radius_server_group.rb +151 -0
- data/tests/test_route_map.rb +1479 -0
- data/tests/test_router_bgp.rb +1325 -0
- data/tests/test_router_ospf.rb +56 -0
- 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 +690 -0
- data/tests/test_snmp_notification_receiver.rb +169 -0
- data/tests/test_snmpcommunity.rb +422 -0
- data/tests/test_snmpgroup.rb +71 -0
- data/tests/test_snmpnotification.rb +91 -0
- data/tests/test_snmpserver.rb +251 -0
- data/tests/test_snmpuser.rb +666 -0
- data/tests/test_span_session.rb +155 -0
- data/tests/test_stp_global.rb +575 -0
- data/tests/test_syslog_facility.rb +80 -0
- data/tests/test_syslog_server.rb +119 -0
- data/tests/test_syslog_settings.rb +123 -0
- data/tests/test_tacacs_global.rb +109 -0
- data/tests/test_tacacs_server.rb +436 -0
- data/tests/test_tacacs_server_group.rb +434 -0
- data/tests/test_tacacs_server_host.rb +427 -0
- data/tests/test_upgrade.rb +105 -0
- data/tests/test_vdc.rb +64 -0
- data/tests/test_vlan.rb +386 -0
- data/tests/test_vlan_private.rb +656 -0
- data/tests/test_vpc.rb +548 -0
- data/tests/test_vrf.rb +248 -0
- data/tests/test_vrf_af.rb +288 -0
- data/tests/test_vtp.rb +278 -0
- data/tests/test_vxlan_vtep.rb +327 -0
- data/tests/test_vxlan_vtep_vni.rb +326 -0
- data/tests/test_yang.rb +369 -0
- data/tests/test_yum.rb +109 -0
- data/tests/upgrade_info.yaml.example +3 -0
- data/tests/yum_package.yaml +94 -0
- metadata +534 -0
|
@@ -0,0 +1,135 @@
|
|
|
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/interface_portchannel'
|
|
18
|
+
|
|
19
|
+
# TestX__CLASS_NAME__X - Minitest for X__CLASS_NAME__X node utility class
|
|
20
|
+
class TestInterfacePortChannel < CiscoTestCase
|
|
21
|
+
@skip_unless_supported = 'interface_portchannel'
|
|
22
|
+
# TESTS
|
|
23
|
+
|
|
24
|
+
DEFAULT_NAME = 'port-channel134'
|
|
25
|
+
|
|
26
|
+
def setup
|
|
27
|
+
super
|
|
28
|
+
config "no interface #{DEFAULT_NAME}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def teardown
|
|
32
|
+
config "no interface #{DEFAULT_NAME}"
|
|
33
|
+
super
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def n6k_platform?
|
|
37
|
+
/N(5|6)/ =~ node.product_id
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def create_port_channel(ifname=DEFAULT_NAME)
|
|
41
|
+
InterfacePortChannel.new(ifname)
|
|
42
|
+
end
|
|
43
|
+
|
|
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
|
|
54
|
+
skip('Platform does not support this property') if n6k_platform?
|
|
55
|
+
interface = create_port_channel
|
|
56
|
+
interface.port_hash_distribution = 'adaptive'
|
|
57
|
+
assert_equal('adaptive', interface.port_hash_distribution)
|
|
58
|
+
interface.port_hash_distribution = 'fixed'
|
|
59
|
+
assert_equal('fixed', interface.port_hash_distribution)
|
|
60
|
+
interface.port_hash_distribution =
|
|
61
|
+
interface.default_port_hash_distribution
|
|
62
|
+
assert_equal(interface.default_port_hash_distribution,
|
|
63
|
+
interface.port_hash_distribution)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_lacp_graceful_convergence
|
|
67
|
+
interface = create_port_channel
|
|
68
|
+
interface.lacp_graceful_convergence = false
|
|
69
|
+
assert_equal(false, interface.lacp_graceful_convergence)
|
|
70
|
+
interface.lacp_graceful_convergence =
|
|
71
|
+
interface.default_lacp_graceful_convergence
|
|
72
|
+
assert_equal(interface.default_lacp_graceful_convergence,
|
|
73
|
+
interface.lacp_graceful_convergence)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_lacp_min_links
|
|
77
|
+
interface = create_port_channel
|
|
78
|
+
interface.lacp_min_links = 5
|
|
79
|
+
assert_equal(5, interface.lacp_min_links)
|
|
80
|
+
interface.lacp_min_links = interface.default_lacp_min_links
|
|
81
|
+
assert_equal(interface.default_lacp_min_links,
|
|
82
|
+
interface.lacp_min_links)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_lacp_max_bundle
|
|
86
|
+
interface = create_port_channel
|
|
87
|
+
interface.lacp_max_bundle = 10
|
|
88
|
+
assert_equal(10, interface.lacp_max_bundle)
|
|
89
|
+
interface.lacp_max_bundle =
|
|
90
|
+
interface.default_lacp_max_bundle
|
|
91
|
+
assert_equal(interface.default_lacp_max_bundle,
|
|
92
|
+
interface.lacp_max_bundle)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def test_lacp_suspend_individual
|
|
96
|
+
interface = create_port_channel
|
|
97
|
+
|
|
98
|
+
# Run this test with the portchannel in both a 'shutdown'
|
|
99
|
+
# and 'no shutdown' state.
|
|
100
|
+
int_obj = Interface.new(interface.name)
|
|
101
|
+
[true, false].each do |state|
|
|
102
|
+
int_obj.shutdown = state
|
|
103
|
+
|
|
104
|
+
# Test initial default case
|
|
105
|
+
assert_equal(interface.default_lacp_suspend_individual,
|
|
106
|
+
interface.lacp_suspend_individual)
|
|
107
|
+
|
|
108
|
+
# Test non-default value
|
|
109
|
+
val = !interface.default_lacp_suspend_individual
|
|
110
|
+
interface.lacp_suspend_individual = val
|
|
111
|
+
assert_equal(val, interface.lacp_suspend_individual)
|
|
112
|
+
|
|
113
|
+
# Set back to default
|
|
114
|
+
interface.lacp_suspend_individual =
|
|
115
|
+
interface.default_lacp_suspend_individual
|
|
116
|
+
assert_equal(interface.default_lacp_suspend_individual,
|
|
117
|
+
interface.lacp_suspend_individual)
|
|
118
|
+
|
|
119
|
+
# Make sure interface ends up in the same state.
|
|
120
|
+
assert_equal(state, int_obj.shutdown,
|
|
121
|
+
"Interface #{int_obj.name} incorrect state after setting property")
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def test_port_load_defer
|
|
126
|
+
skip('Platform does not support this property') if n6k_platform?
|
|
127
|
+
interface = create_port_channel
|
|
128
|
+
interface.port_load_defer = true
|
|
129
|
+
assert_equal(true, interface.port_load_defer)
|
|
130
|
+
interface.port_load_defer =
|
|
131
|
+
interface.default_port_load_defer
|
|
132
|
+
assert_equal(interface.default_port_load_defer,
|
|
133
|
+
interface.port_load_defer)
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -0,0 +1,365 @@
|
|
|
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/vlan'
|
|
18
|
+
|
|
19
|
+
include Cisco
|
|
20
|
+
|
|
21
|
+
# TestInterfacePrivateVlan
|
|
22
|
+
# Parent class for specific types of switchport tests (below)
|
|
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
|
|
31
|
+
|
|
32
|
+
def setup
|
|
33
|
+
super
|
|
34
|
+
return unless @@pre_clean_needed
|
|
35
|
+
cleanup
|
|
36
|
+
@@interface = Interface.new(interfaces[0])
|
|
37
|
+
@@pre_clean_needed = false
|
|
38
|
+
end
|
|
39
|
+
# rubocop:enable Style/ClassVars
|
|
40
|
+
|
|
41
|
+
def teardown
|
|
42
|
+
cleanup
|
|
43
|
+
super
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def cleanup
|
|
47
|
+
interface_cleanup_pvlan
|
|
48
|
+
remove_all_vlans
|
|
49
|
+
config_no_warn('no feature private-vlan', 'no feature vtp')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def interface_cleanup_pvlan
|
|
53
|
+
pvlan_intfs = Interface.interfaces(:pvlan_any)
|
|
54
|
+
pvlan_intfs.keys.each { |name| interface_cleanup(name) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def test_pvlan_mapping
|
|
58
|
+
# This is an SVI property
|
|
59
|
+
svi = Interface.new('vlan13')
|
|
60
|
+
if validate_property_excluded?('interface', 'pvlan_mapping')
|
|
61
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
62
|
+
svi.pvlan_mapping = ['10-11,4-7,8']
|
|
63
|
+
end
|
|
64
|
+
return
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
default = svi.default_pvlan_mapping
|
|
68
|
+
assert_equal(default, svi.pvlan_mapping)
|
|
69
|
+
|
|
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)
|
|
73
|
+
|
|
74
|
+
# Change range
|
|
75
|
+
svi.pvlan_mapping = '11,4-6,8'
|
|
76
|
+
assert_equal(['4-6,8,11'], svi.pvlan_mapping)
|
|
77
|
+
|
|
78
|
+
svi.pvlan_mapping = default
|
|
79
|
+
assert_equal(default, svi.pvlan_mapping)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def test_switchport_pvlan_host
|
|
83
|
+
if validate_property_excluded?('interface',
|
|
84
|
+
'switchport_pvlan_host')
|
|
85
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
86
|
+
i.switchport_pvlan_host = true
|
|
87
|
+
end
|
|
88
|
+
return
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
i.switchport_mode = :access
|
|
92
|
+
assert_equal(i.default_switchport_pvlan_host,
|
|
93
|
+
i.switchport_pvlan_host)
|
|
94
|
+
|
|
95
|
+
i.switchport_pvlan_host = true
|
|
96
|
+
assert(i.switchport_pvlan_host)
|
|
97
|
+
|
|
98
|
+
i.switchport_pvlan_host = false
|
|
99
|
+
refute(i.switchport_pvlan_host)
|
|
100
|
+
i.switchport_mode = :disabled
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def test_sw_pvlan_promiscuous
|
|
104
|
+
if validate_property_excluded?('interface',
|
|
105
|
+
'switchport_pvlan_promiscuous')
|
|
106
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
107
|
+
i.switchport_pvlan_promiscuous = true
|
|
108
|
+
end
|
|
109
|
+
return
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
i.switchport_mode = :access
|
|
113
|
+
assert_equal(i.default_switchport_pvlan_promiscuous,
|
|
114
|
+
i.switchport_pvlan_promiscuous)
|
|
115
|
+
|
|
116
|
+
i.switchport_pvlan_promiscuous = true
|
|
117
|
+
assert(i.switchport_pvlan_promiscuous)
|
|
118
|
+
|
|
119
|
+
i.switchport_pvlan_promiscuous = false
|
|
120
|
+
refute(i.switchport_pvlan_promiscuous)
|
|
121
|
+
i.switchport_mode = :disabled
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def test_sw_pvlan_trunk_promiscuous
|
|
125
|
+
if validate_property_excluded?('interface',
|
|
126
|
+
'switchport_pvlan_trunk_promiscuous')
|
|
127
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
128
|
+
i.switchport_pvlan_trunk_promiscuous = true
|
|
129
|
+
end
|
|
130
|
+
return
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
i.switchport_mode = :access
|
|
134
|
+
assert_equal(i.default_switchport_pvlan_trunk_promiscuous,
|
|
135
|
+
i.switchport_pvlan_trunk_promiscuous)
|
|
136
|
+
|
|
137
|
+
i.switchport_pvlan_trunk_promiscuous = true
|
|
138
|
+
assert(i.switchport_pvlan_trunk_promiscuous)
|
|
139
|
+
|
|
140
|
+
i.switchport_pvlan_trunk_promiscuous = false
|
|
141
|
+
refute(i.switchport_pvlan_trunk_promiscuous)
|
|
142
|
+
i.switchport_mode = :disabled
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def test_sw_pvlan_trunk_secondary
|
|
146
|
+
if validate_property_excluded?('interface',
|
|
147
|
+
'switchport_pvlan_trunk_secondary')
|
|
148
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
149
|
+
i.switchport_pvlan_trunk_secondary = true
|
|
150
|
+
end
|
|
151
|
+
return
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
i.switchport_mode = :access
|
|
155
|
+
assert_equal(i.default_switchport_pvlan_trunk_secondary,
|
|
156
|
+
i.switchport_pvlan_trunk_secondary)
|
|
157
|
+
|
|
158
|
+
i.switchport_pvlan_trunk_secondary = true
|
|
159
|
+
assert(i.switchport_pvlan_trunk_secondary)
|
|
160
|
+
|
|
161
|
+
i.switchport_pvlan_trunk_secondary = false
|
|
162
|
+
refute(i.switchport_pvlan_trunk_secondary)
|
|
163
|
+
i.switchport_mode = :disabled
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Helper to setup vlan associations
|
|
167
|
+
def vlan_associate(pri, range)
|
|
168
|
+
Vlan.new(pri).pvlan_type = 'primary'
|
|
169
|
+
secondaries = Utils.dash_range_to_elements(range)
|
|
170
|
+
secondaries.each { |vlan| Vlan.new(vlan).pvlan_type = 'community' }
|
|
171
|
+
|
|
172
|
+
Vlan.new(pri).pvlan_association = range
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def test_sw_pvlan_host_association
|
|
176
|
+
# Supports single instance of [pri, sec]
|
|
177
|
+
if validate_property_excluded?('interface',
|
|
178
|
+
'switchport_pvlan_host_association')
|
|
179
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
180
|
+
i.switchport_pvlan_host_association = %w(2 3)
|
|
181
|
+
end
|
|
182
|
+
return
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
default = i.default_switchport_pvlan_host_association
|
|
186
|
+
assert_equal(default, i.switchport_pvlan_host_association)
|
|
187
|
+
|
|
188
|
+
# Setup prerequisites
|
|
189
|
+
vlan_associate('2', '3')
|
|
190
|
+
|
|
191
|
+
i.switchport_pvlan_host_association = %w(2 3)
|
|
192
|
+
assert_equal(%w(2 3), i.switchport_pvlan_host_association)
|
|
193
|
+
|
|
194
|
+
i.switchport_pvlan_host_association = default
|
|
195
|
+
assert_equal(default, i.switchport_pvlan_host_association)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def test_sw_pvlan_trunk_association
|
|
199
|
+
# N6k trunk association does not update primary-secondary associations automatically
|
|
200
|
+
skip('Test behavior not supported on device') if node.product_id[/N(5|6)/]
|
|
201
|
+
|
|
202
|
+
# Supports multiple instances of [[pri, sec], [pri2, sec2]]
|
|
203
|
+
if validate_property_excluded?('interface',
|
|
204
|
+
'switchport_pvlan_trunk_association')
|
|
205
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
206
|
+
i.switchport_pvlan_trunk_association = %w(2 3)
|
|
207
|
+
end
|
|
208
|
+
return
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
default = i.default_switchport_pvlan_trunk_association
|
|
212
|
+
assert_equal(default, i.switchport_pvlan_trunk_association)
|
|
213
|
+
|
|
214
|
+
pairs = %w(2 3)
|
|
215
|
+
i.switchport_pvlan_trunk_association = pairs
|
|
216
|
+
assert_equal([pairs], i.switchport_pvlan_trunk_association)
|
|
217
|
+
|
|
218
|
+
# Add a second pairs
|
|
219
|
+
pairs = [%w(2 3), %w(4 5)]
|
|
220
|
+
i.switchport_pvlan_trunk_association = pairs
|
|
221
|
+
assert_equal(pairs, i.switchport_pvlan_trunk_association)
|
|
222
|
+
|
|
223
|
+
# New pair
|
|
224
|
+
pairs = [%w(6 7)]
|
|
225
|
+
i.switchport_pvlan_trunk_association = pairs
|
|
226
|
+
assert_equal(pairs, i.switchport_pvlan_trunk_association)
|
|
227
|
+
|
|
228
|
+
i.switchport_pvlan_trunk_association = default
|
|
229
|
+
assert_equal(default, i.switchport_pvlan_trunk_association)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def test_sw_pvlan_mapping
|
|
233
|
+
if validate_property_excluded?('interface', 'switchport_pvlan_mapping')
|
|
234
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
235
|
+
i.switchport_pvlan_mapping = ['2', '10-11,4-7,8']
|
|
236
|
+
end
|
|
237
|
+
return
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
default = i.default_switchport_pvlan_mapping
|
|
241
|
+
assert_equal(default, i.switchport_pvlan_mapping)
|
|
242
|
+
|
|
243
|
+
# Setup prerequisites
|
|
244
|
+
vlan_associate('2', '3-4')
|
|
245
|
+
|
|
246
|
+
i.switchport_pvlan_mapping = %w(2 3)
|
|
247
|
+
assert_equal(%w(2 3), i.switchport_pvlan_mapping)
|
|
248
|
+
|
|
249
|
+
i.switchport_pvlan_mapping = %w(2 3-4)
|
|
250
|
+
assert_equal(%w(2 3-4), i.switchport_pvlan_mapping)
|
|
251
|
+
|
|
252
|
+
i.switchport_pvlan_mapping = %w(2 3)
|
|
253
|
+
assert_equal(%w(2 3), i.switchport_pvlan_mapping)
|
|
254
|
+
|
|
255
|
+
i.switchport_pvlan_mapping = default
|
|
256
|
+
assert_equal(default, i.switchport_pvlan_mapping)
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
def test_sw_pvlan_mapping_trunk
|
|
260
|
+
# N6k mapping trunk does not update primary-secondary associations automatically
|
|
261
|
+
skip('Test behavior not supported on device') if node.product_id[/N(5|6)/]
|
|
262
|
+
|
|
263
|
+
if validate_property_excluded?('interface',
|
|
264
|
+
'switchport_pvlan_mapping_trunk')
|
|
265
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
266
|
+
i.switchport_pvlan_mapping_trunk = [['2', '10-11']]
|
|
267
|
+
end
|
|
268
|
+
return
|
|
269
|
+
end
|
|
270
|
+
default = i.default_switchport_pvlan_mapping_trunk
|
|
271
|
+
assert_equal(default, i.switchport_pvlan_mapping_trunk)
|
|
272
|
+
|
|
273
|
+
# Basic, non-nested array
|
|
274
|
+
i.switchport_pvlan_mapping_trunk = ['2', '10-11,4-7,8']
|
|
275
|
+
assert_equal([['2', '4-8,10-11']], i.switchport_pvlan_mapping_trunk)
|
|
276
|
+
|
|
277
|
+
# Same primary, but change range
|
|
278
|
+
i.switchport_pvlan_mapping_trunk = ['2', '11,4-6,8']
|
|
279
|
+
assert_equal([['2', '4-6,8,11']], i.switchport_pvlan_mapping_trunk)
|
|
280
|
+
|
|
281
|
+
# Change primary
|
|
282
|
+
array = ['3', '4-6,8,11']
|
|
283
|
+
i.switchport_pvlan_mapping_trunk = array
|
|
284
|
+
assert_equal([array], i.switchport_pvlan_mapping_trunk)
|
|
285
|
+
|
|
286
|
+
# Multiple: basic
|
|
287
|
+
nest = Array[%w(4 14), %w(5 25)]
|
|
288
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
289
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
290
|
+
|
|
291
|
+
# Multiple: change only one range
|
|
292
|
+
nest = Array[%w(4 14), %w(5 7-9)]
|
|
293
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
294
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
295
|
+
|
|
296
|
+
# Multiple: Move part of one range to a new primary
|
|
297
|
+
nest = Array[%w(4 14), %w(5 7,9), %w(6 8)]
|
|
298
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
299
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
300
|
+
|
|
301
|
+
# Multiple: Move part of one range from one primary to an existing primary
|
|
302
|
+
nest = Array[%w(3 14), %w(5 7,9), %w(6 8)]
|
|
303
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
304
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
305
|
+
|
|
306
|
+
# Multiple: Leave out a set while changing another
|
|
307
|
+
nest = Array[%w(5 7), %w(6 8-9,11)]
|
|
308
|
+
i.switchport_pvlan_mapping_trunk = nest
|
|
309
|
+
assert_equal(nest, i.switchport_pvlan_mapping_trunk)
|
|
310
|
+
|
|
311
|
+
# Explicitly set the default
|
|
312
|
+
i.switchport_pvlan_mapping_trunk = default
|
|
313
|
+
assert_equal(default, i.switchport_pvlan_mapping_trunk)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
def test_sw_pvlan_trunk_allowed_vlan
|
|
317
|
+
if validate_property_excluded?('interface',
|
|
318
|
+
'switchport_pvlan_trunk_allowed_vlan')
|
|
319
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
320
|
+
i.switchport_pvlan_trunk_allowed_vlan = '8-9,4,2-3'
|
|
321
|
+
end
|
|
322
|
+
return
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
i.switchport_mode = :access
|
|
326
|
+
default = i.default_switchport_pvlan_trunk_allowed_vlan
|
|
327
|
+
assert_equal(default, i.switchport_pvlan_trunk_allowed_vlan)
|
|
328
|
+
|
|
329
|
+
i.switchport_pvlan_trunk_allowed_vlan = '8-9,4,2-3'
|
|
330
|
+
assert_equal('2-4,8-9', i.switchport_pvlan_trunk_allowed_vlan)
|
|
331
|
+
|
|
332
|
+
# Change range
|
|
333
|
+
i.switchport_pvlan_trunk_allowed_vlan = '9-10,2'
|
|
334
|
+
assert_equal('2,9-10', i.switchport_pvlan_trunk_allowed_vlan)
|
|
335
|
+
|
|
336
|
+
i.switchport_pvlan_trunk_allowed_vlan = default
|
|
337
|
+
assert_equal(default, i.switchport_pvlan_trunk_allowed_vlan)
|
|
338
|
+
|
|
339
|
+
vlans = '500-528,530,532,534,587,590-593,597-598,600,602,604'
|
|
340
|
+
i.switchport_pvlan_trunk_allowed_vlan = vlans
|
|
341
|
+
assert_equal(vlans, i.switchport_pvlan_trunk_allowed_vlan)
|
|
342
|
+
i.switchport_mode = :disabled
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
def test_sw_pvlan_trunk_native_vlan
|
|
346
|
+
if validate_property_excluded?('interface',
|
|
347
|
+
'switchport_pvlan_trunk_native_vlan')
|
|
348
|
+
assert_raises(Cisco::UnsupportedError) do
|
|
349
|
+
i.switchport_pvlan_trunk_native_vlan = '2'
|
|
350
|
+
end
|
|
351
|
+
return
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
i.switchport_mode = :access
|
|
355
|
+
default = i.default_switchport_pvlan_trunk_native_vlan
|
|
356
|
+
assert_equal(default, i.switchport_pvlan_trunk_native_vlan)
|
|
357
|
+
|
|
358
|
+
i.switchport_pvlan_trunk_native_vlan = '2'
|
|
359
|
+
assert_equal('2', i.switchport_pvlan_trunk_native_vlan)
|
|
360
|
+
|
|
361
|
+
i.switchport_pvlan_trunk_native_vlan = default
|
|
362
|
+
assert_equal(default, i.switchport_pvlan_trunk_native_vlan)
|
|
363
|
+
i.switchport_mode = :disabled
|
|
364
|
+
end
|
|
365
|
+
end
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# Copyright (c) 2013-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/bridge_domain'
|
|
17
|
+
require_relative '../lib/cisco_node_utils/encapsulation'
|
|
18
|
+
require_relative '../lib/cisco_node_utils/interface'
|
|
19
|
+
require_relative '../lib/cisco_node_utils/interface_service_vni'
|
|
20
|
+
require_relative '../lib/cisco_node_utils/vdc'
|
|
21
|
+
|
|
22
|
+
include Cisco
|
|
23
|
+
|
|
24
|
+
# TestInterfaceServiceVni - Minitest for the InterfaceServiceVni class.
|
|
25
|
+
#
|
|
26
|
+
# Example cli tested by this minitest:
|
|
27
|
+
#
|
|
28
|
+
# encapsulation profile vni vni_500_5000
|
|
29
|
+
# dot1q 500 vni 5000
|
|
30
|
+
# interface Ethernet9/1
|
|
31
|
+
# service instance 5 vni
|
|
32
|
+
# encapsulation profile vni_500_5000 default
|
|
33
|
+
# shutdown
|
|
34
|
+
# service instance 6 vni
|
|
35
|
+
# encapsulation profile vni_600_6000 default
|
|
36
|
+
#
|
|
37
|
+
class TestInterfaceServiceVni < CiscoTestCase
|
|
38
|
+
# rubocop:disable Style/ClassVars
|
|
39
|
+
@skip_unless_supported = 'interface_service_vni'
|
|
40
|
+
@@pre_clean_needed = true
|
|
41
|
+
@@intf = nil
|
|
42
|
+
|
|
43
|
+
def setup
|
|
44
|
+
super
|
|
45
|
+
return unless @@pre_clean_needed
|
|
46
|
+
|
|
47
|
+
mt_full_env_setup
|
|
48
|
+
@@pre_clean_needed = false
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def teardown
|
|
52
|
+
config_no_warn("default interface #{@@intf}")
|
|
53
|
+
super
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def mt_full_env_setup
|
|
57
|
+
@@intf = mt_full_interface?
|
|
58
|
+
Vdc.new('default').limit_resource_module_type = 'f3'
|
|
59
|
+
config_no_warn("default interface #{@@intf}")
|
|
60
|
+
global_setup
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def global_setup
|
|
64
|
+
# Reset feature to clean up switch
|
|
65
|
+
config('no feature vni', 'feature vni')
|
|
66
|
+
|
|
67
|
+
# Create global encap profiles
|
|
68
|
+
Encapsulation.new('vni_500_5000').dot1q_map = %w(500 5000)
|
|
69
|
+
Encapsulation.new('vni_600_6000').dot1q_map = %w(600 6000)
|
|
70
|
+
Encapsulation.new('vni_700_7000').dot1q_map = %w(700 7000)
|
|
71
|
+
Encapsulation.new('vni_800_8000').dot1q_map = %w(800 8000)
|
|
72
|
+
|
|
73
|
+
# Create global bridge domains
|
|
74
|
+
remove_all_bridge_domains
|
|
75
|
+
BridgeDomain.new('100-113')
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_create_destroy
|
|
79
|
+
# TEST Create / Destroy and svc_vni_ids hash builder
|
|
80
|
+
i5 = InterfaceServiceVni.new(@@intf, 5)
|
|
81
|
+
assert_equal(1, InterfaceServiceVni.svc_vni_ids[@@intf].count)
|
|
82
|
+
i6 = InterfaceServiceVni.new(@@intf, 6)
|
|
83
|
+
i7 = InterfaceServiceVni.new(@@intf, 7)
|
|
84
|
+
assert_equal(3, InterfaceServiceVni.svc_vni_ids[@@intf].count)
|
|
85
|
+
i6.destroy
|
|
86
|
+
assert_equal(2, InterfaceServiceVni.svc_vni_ids[@@intf].count)
|
|
87
|
+
i5.destroy
|
|
88
|
+
i7.destroy
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def test_shutdown
|
|
92
|
+
i5 = InterfaceServiceVni.new(@@intf, 5)
|
|
93
|
+
assert_equal(i5.default_shutdown, i5.shutdown)
|
|
94
|
+
|
|
95
|
+
i5.shutdown = false
|
|
96
|
+
refute(i5.shutdown)
|
|
97
|
+
i5.shutdown = true
|
|
98
|
+
assert(i5.shutdown)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def test_encapsulation_profile_vni
|
|
102
|
+
i5 = InterfaceServiceVni.new(@@intf, 5)
|
|
103
|
+
assert_equal(i5.default_encapsulation_profile_vni,
|
|
104
|
+
i5.encapsulation_profile_vni)
|
|
105
|
+
|
|
106
|
+
# Test removal when profile not present
|
|
107
|
+
i5.encapsulation_profile_vni = ''
|
|
108
|
+
assert_empty(i5.encapsulation_profile_vni)
|
|
109
|
+
|
|
110
|
+
# Add one
|
|
111
|
+
i5.encapsulation_profile_vni = 'vni_500_5000'
|
|
112
|
+
assert_equal('vni_500_5000', i5.encapsulation_profile_vni)
|
|
113
|
+
|
|
114
|
+
# Change it
|
|
115
|
+
i5.encapsulation_profile_vni = 'vni_700_7000'
|
|
116
|
+
assert_equal('vni_700_7000', i5.encapsulation_profile_vni)
|
|
117
|
+
|
|
118
|
+
# Test default when profile present
|
|
119
|
+
i5.encapsulation_profile_vni = 'vni_700_7000'
|
|
120
|
+
i5.encapsulation_profile_vni = i5.default_encapsulation_profile_vni
|
|
121
|
+
assert_equal(i5.default_encapsulation_profile_vni,
|
|
122
|
+
i5.encapsulation_profile_vni)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# interface vlan_mapping is not technically part of the interface service
|
|
126
|
+
# but it shares most of the same dependencies so it is tested here instead
|
|
127
|
+
# of test_interface.rb
|
|
128
|
+
def test_vlan_mapping
|
|
129
|
+
# This test covers two properties:
|
|
130
|
+
# vlan_mapping & vlan_mapping_enabled
|
|
131
|
+
|
|
132
|
+
i = Interface.new(@@intf)
|
|
133
|
+
i.switchport_mode = :trunk
|
|
134
|
+
i.vlan_mapping = []
|
|
135
|
+
assert_equal([], i.vlan_mapping, 'Initial cleanup failed')
|
|
136
|
+
|
|
137
|
+
# Initial 'should' state
|
|
138
|
+
# rubocop:disable Style/WordArray
|
|
139
|
+
master = [['20', '21'],
|
|
140
|
+
['40', '41'],
|
|
141
|
+
['60', '61'],
|
|
142
|
+
['80', '81']]
|
|
143
|
+
# rubocop:enable Style/WordArray
|
|
144
|
+
|
|
145
|
+
# Test: Add all mappings when no cmds are present
|
|
146
|
+
should = master.clone
|
|
147
|
+
i.vlan_mapping = should
|
|
148
|
+
result = i.vlan_mapping
|
|
149
|
+
assert_equal(should.sort, result.sort,
|
|
150
|
+
'Test 1a. From empty, to all mappings')
|
|
151
|
+
i.vlan_mapping_enable = false
|
|
152
|
+
refute(i.vlan_mapping_enable,
|
|
153
|
+
'Test 1b. Initial test, set to disabled')
|
|
154
|
+
|
|
155
|
+
# Test: remove half of the mappings
|
|
156
|
+
should.shift(2)
|
|
157
|
+
i.vlan_mapping = should
|
|
158
|
+
result = i.vlan_mapping
|
|
159
|
+
assert_equal(should.sort, result.sort,
|
|
160
|
+
'Test 2a. Remove half of the mappings')
|
|
161
|
+
i.vlan_mapping_enable = true
|
|
162
|
+
assert(i.vlan_mapping_enable,
|
|
163
|
+
'Test 2b. Back to enabled')
|
|
164
|
+
|
|
165
|
+
# Test: restore the removed mappings
|
|
166
|
+
should = master.clone
|
|
167
|
+
i.vlan_mapping = should
|
|
168
|
+
result = i.vlan_mapping
|
|
169
|
+
assert_equal(should.sort, result.sort,
|
|
170
|
+
'Test 3a. Restore the removed mappings')
|
|
171
|
+
i.vlan_mapping_enable = false
|
|
172
|
+
refute(i.vlan_mapping_enable,
|
|
173
|
+
'Test 3b. Back to disabled')
|
|
174
|
+
|
|
175
|
+
# Test: Change original-vlan on existing commands
|
|
176
|
+
should = should.map do |original, translated|
|
|
177
|
+
[original + '1', translated]
|
|
178
|
+
end
|
|
179
|
+
i.vlan_mapping = should
|
|
180
|
+
result = i.vlan_mapping
|
|
181
|
+
assert_equal(should.sort, result.sort,
|
|
182
|
+
'Test 4. Change original-vlan on existing commands')
|
|
183
|
+
|
|
184
|
+
# Test: Change translated-vlan on existing commands
|
|
185
|
+
should = should.map do |original, translated|
|
|
186
|
+
[original, translated + '1']
|
|
187
|
+
end
|
|
188
|
+
i.vlan_mapping = should
|
|
189
|
+
result = i.vlan_mapping
|
|
190
|
+
assert_equal(should.sort, result.sort,
|
|
191
|
+
'Test 5. Change translated-vlan on existing commands')
|
|
192
|
+
|
|
193
|
+
# Test: 'default'
|
|
194
|
+
should = i.default_vlan_mapping
|
|
195
|
+
i.vlan_mapping = should
|
|
196
|
+
result = i.vlan_mapping
|
|
197
|
+
assert_equal(should.sort, result.sort,
|
|
198
|
+
"Test 6a. 'default'")
|
|
199
|
+
i.vlan_mapping_enable = i.default_vlan_mapping_enable
|
|
200
|
+
assert(i.vlan_mapping_enable,
|
|
201
|
+
"Test 6b. 'default'")
|
|
202
|
+
end
|
|
203
|
+
end
|