cisco_node_utils_mgx 2.1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,108 @@
|
|
1
|
+
# Copyright (c) 2017 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/bgp_af'
|
17
|
+
require_relative '../lib/cisco_node_utils/bgp_af_aggr_addr'
|
18
|
+
|
19
|
+
include Cisco
|
20
|
+
# TestBgpAfAggrAddr - Minitest for BgpAFAggrAddr class
|
21
|
+
class TestBgpAfAggrAddr < CiscoTestCase
|
22
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
23
|
+
|
24
|
+
def setup
|
25
|
+
super
|
26
|
+
config('no feature bgp')
|
27
|
+
remove_all_vrfs if @@pre_clean_needed
|
28
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
29
|
+
end
|
30
|
+
|
31
|
+
def teardown
|
32
|
+
config('no feature bgp')
|
33
|
+
remove_all_vrfs
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_collection_empty
|
38
|
+
node.cache_flush
|
39
|
+
aas = RouterBgpAFAggrAddr.aas
|
40
|
+
assert_empty(aas, 'BGP AF Aggregate Address collection is not empty')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_collection_not_empty
|
44
|
+
bgp_af = []
|
45
|
+
bgp_af_aa = []
|
46
|
+
%w(default red).each do |vrf|
|
47
|
+
[%w(ipv4 unicast), %w(ipv6 unicast),
|
48
|
+
%w(ipv4 multicast), %w(ipv6 multicast)].each do |af|
|
49
|
+
bgp_af.push(RouterBgpAF.new(55, vrf, af))
|
50
|
+
if af[0] == 'ipv4'
|
51
|
+
['1.1.1.0/24', '2.2.2.2/32'].each do |addr|
|
52
|
+
bgp_af_aa.push(RouterBgpAFAggrAddr.new(55, vrf, af, addr))
|
53
|
+
end
|
54
|
+
else
|
55
|
+
['2001::12/128', '2000::31/128'].each do |addr|
|
56
|
+
bgp_af_aa.push(RouterBgpAFAggrAddr.new(55, vrf, af, addr))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
assert_equal(2, RouterBgpAFAggrAddr.aas[55][vrf][af].size)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_destroy
|
65
|
+
af = %w(ipv4 unicast)
|
66
|
+
RouterBgpAF.new(55, 'red', af)
|
67
|
+
obj = RouterBgpAFAggrAddr.new(55, 'red', af, '1.1.1.0/24')
|
68
|
+
aas = RouterBgpAFAggrAddr.aas[55]['red'][af]
|
69
|
+
assert_equal(1, aas.size)
|
70
|
+
obj.destroy
|
71
|
+
aas = RouterBgpAFAggrAddr.aas[55]['red'][af]
|
72
|
+
assert_empty(aas, 'BGP AF Aggregate Address collection is not empty')
|
73
|
+
end
|
74
|
+
|
75
|
+
def aa_helper(props)
|
76
|
+
af = %w(ipv4 unicast)
|
77
|
+
RouterBgpAF.new(55, 'red', af)
|
78
|
+
obj = RouterBgpAFAggrAddr.new(55, 'red', af, '1.1.1.0/24')
|
79
|
+
test_hash = {
|
80
|
+
advertise_map: obj.default_advertise_map,
|
81
|
+
as_set: obj.default_as_set,
|
82
|
+
attribute_map: obj.default_attribute_map,
|
83
|
+
summary_only: obj.default_summary_only,
|
84
|
+
suppress_map: obj.default_suppress_map,
|
85
|
+
}.merge!(props)
|
86
|
+
obj.aa_set(test_hash)
|
87
|
+
obj
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_aa
|
91
|
+
obj = aa_helper(advertise_map: 'adm',
|
92
|
+
as_set: true,
|
93
|
+
attribute_map: 'atm',
|
94
|
+
suppress_map: 'sum')
|
95
|
+
assert(obj.as_set)
|
96
|
+
assert_equal('adm', obj.advertise_map)
|
97
|
+
assert_equal('atm', obj.attribute_map)
|
98
|
+
assert_equal('sum', obj.suppress_map)
|
99
|
+
obj = aa_helper(advertise_map: 'adm',
|
100
|
+
as_set: true,
|
101
|
+
attribute_map: 'atm',
|
102
|
+
summary_only: true)
|
103
|
+
assert(obj.as_set)
|
104
|
+
assert(obj.summary_only)
|
105
|
+
assert_equal('adm', obj.advertise_map)
|
106
|
+
assert_equal('atm', obj.attribute_map)
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,596 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# RouterBgpNeighbor Unit Tests
|
3
|
+
#
|
4
|
+
# Jie Yang, August 2015
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
require_relative 'ciscotest'
|
21
|
+
require_relative '../lib/cisco_node_utils/bgp'
|
22
|
+
require_relative '../lib/cisco_node_utils/bgp_neighbor'
|
23
|
+
require_relative '../lib/cisco_node_utils/logger'
|
24
|
+
|
25
|
+
# TestBgpNeighbor - Minitest for RouterBgpNeighbor node utility class
|
26
|
+
class TestBgpNeighbor < CiscoTestCase
|
27
|
+
ASN = 55
|
28
|
+
ADDR = '1.1.1.1'
|
29
|
+
REMOTE_ASN = 99
|
30
|
+
@@pre_clean_needed = true # rubocop:disable Style/ClassVars
|
31
|
+
|
32
|
+
def setup
|
33
|
+
super
|
34
|
+
remove_all_bgps if @@pre_clean_needed
|
35
|
+
@@pre_clean_needed = false # rubocop:disable Style/ClassVars
|
36
|
+
# BGP Neighbor requires the presence of a basic bgp global config
|
37
|
+
RouterBgp.new(ASN)
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
remove_all_bgps
|
42
|
+
super
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns some test data for use in several tests.
|
46
|
+
def test_data
|
47
|
+
test_data = []
|
48
|
+
test_data << { vrf: 'default', neighbors: ['1.1.1.1'] }
|
49
|
+
|
50
|
+
if platform == :ios_xr
|
51
|
+
# XR doesn't support prefix/len addresses
|
52
|
+
test_data << { vrf: 'red',
|
53
|
+
neighbors: ['2.2.2.0', '2000::2'] }
|
54
|
+
else
|
55
|
+
test_data << { vrf: 'red',
|
56
|
+
neighbors: ['2.2.2.0/24', '2000::2', '2000:123:38::/64'] }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Finds and returns the neighbor with the specified address
|
61
|
+
# and vrf, or nil if it is not found.
|
62
|
+
def find_neighbor(addr, vrf='default',
|
63
|
+
bgp_neighbors=RouterBgpNeighbor.neighbors)
|
64
|
+
bgp_neighbors.each_value do |vrfs|
|
65
|
+
vrfs.each do |vrf_name, neighbors|
|
66
|
+
next unless vrf_name == vrf
|
67
|
+
neighbors.each_value do |neighbor|
|
68
|
+
next unless neighbor.nbr == addr
|
69
|
+
Cisco::Logger.debug("neighbor '#{addr}' with vrf '#{vrf}' found")
|
70
|
+
return neighbor
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
Cisco::Logger.debug("neighbor '#{addr}' with vrf '#{vrf}' not found")
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
|
78
|
+
# Does the neighbor with the specified address and vrf exist?
|
79
|
+
def neighbor_exists?(addr, vrf='default',
|
80
|
+
bgp_neighbors=RouterBgpNeighbor.neighbors)
|
81
|
+
find_neighbor(addr, vrf, bgp_neighbors) != nil
|
82
|
+
end
|
83
|
+
|
84
|
+
# Finds the neighbor with the specified address in the
|
85
|
+
# output from a show cmd. Returns the matching line of
|
86
|
+
# output if found, otherwise nil.
|
87
|
+
def get_bgpneighbor_match_line(addr, vrf='default')
|
88
|
+
regex = /neighbor #{addr}/
|
89
|
+
if vrf == 'default'
|
90
|
+
if platform == :ios_xr
|
91
|
+
cmd = 'show run router bgp'
|
92
|
+
regex = /^ neighbor #{addr}/
|
93
|
+
else
|
94
|
+
cmd = "show run bgp all | section 'router bgp' | no-more"
|
95
|
+
end
|
96
|
+
else
|
97
|
+
if platform == :ios_xr
|
98
|
+
cmd = "show run router bgp #{ASN} vrf #{vrf}"
|
99
|
+
else
|
100
|
+
cmd = "show run bgp all | section 'vrf #{vrf}' | no-more"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
s = @device.cmd("#{cmd}")
|
104
|
+
Cisco::Logger.debug("matching '#{addr}' with vrf '#{vrf}', output: \n#{s}")
|
105
|
+
line = regex.match(s)
|
106
|
+
Cisco::Logger.debug(line)
|
107
|
+
line
|
108
|
+
end
|
109
|
+
|
110
|
+
# Creates a neighbor for use in tests, and sets its remote_as.
|
111
|
+
def create_neighbor(vrf, addr=ADDR)
|
112
|
+
neighbor = RouterBgpNeighbor.new(ASN, vrf, addr)
|
113
|
+
|
114
|
+
# XR requires a remote_as in order to set other properties
|
115
|
+
# (description, password, etc.)
|
116
|
+
neighbor.remote_as = REMOTE_ASN
|
117
|
+
neighbor
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_collection_empty
|
121
|
+
remove_all_bgps
|
122
|
+
neighbors = RouterBgpNeighbor.neighbors
|
123
|
+
assert_empty(neighbors, 'BGP neighbor collection is not empty')
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_collection_not_empty
|
127
|
+
test_data_hash = {}
|
128
|
+
|
129
|
+
cmds = ['router bgp 55']
|
130
|
+
|
131
|
+
test = test_data
|
132
|
+
test.each do |d|
|
133
|
+
test_data_hash[d[:vrf]] = d[:neighbors]
|
134
|
+
cmds << "vrf #{d[:vrf]}" unless d[:vrf] == 'default'
|
135
|
+
d[:neighbors].each do |neighbor|
|
136
|
+
cmds << "neighbor #{neighbor}" << "remote-as #{REMOTE_ASN}"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
config(*cmds)
|
141
|
+
|
142
|
+
bgp_neighbors = RouterBgpNeighbor.neighbors
|
143
|
+
refute_empty(bgp_neighbors, 'BGP neighbor collection is empty')
|
144
|
+
|
145
|
+
# see if all expected neighbors are there
|
146
|
+
test.each do |d|
|
147
|
+
d[:neighbors].each do |neighbor|
|
148
|
+
# see if the neighbor exists in the list returned by the API
|
149
|
+
assert(neighbor_exists?(neighbor, d[:vrf], bgp_neighbors),
|
150
|
+
'Did not find in neighbor list: '\
|
151
|
+
"nbr '#{neighbor}', vrf '#{d[:vrf]}'")
|
152
|
+
|
153
|
+
# see if the neighbor exists via show cmd output
|
154
|
+
line = get_bgpneighbor_match_line(neighbor, d[:vrf])
|
155
|
+
refute_nil(line, 'Did not find in show output: '\
|
156
|
+
"nbr '#{neighbor}', vrf '#{d[:vrf]}'")
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_create_destroy
|
162
|
+
test_data.each do |d|
|
163
|
+
d[:neighbors].each do |addr|
|
164
|
+
neighbor = create_neighbor(d[:vrf], addr)
|
165
|
+
exists = neighbor_exists?(addr, d[:vrf])
|
166
|
+
assert(exists, "Failed to create bgp neighbor #{addr}")
|
167
|
+
line = get_bgpneighbor_match_line(addr, d[:vrf])
|
168
|
+
refute_nil(line, "failed to create bgp neighbor #{addr}")
|
169
|
+
neighbor.destroy
|
170
|
+
exists = neighbor_exists?(addr, d[:vrf])
|
171
|
+
refute(exists, "Failed to delete bgp neighbor #{addr}")
|
172
|
+
line = get_bgpneighbor_match_line(addr, d[:vrf])
|
173
|
+
assert_nil(line, "failed to delete bgp neighbor #{addr}")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_description
|
179
|
+
%w(default test_vrf).each do |vrf|
|
180
|
+
neighbor = create_neighbor(vrf)
|
181
|
+
description = "tested by mini test for vrf #{vrf}"
|
182
|
+
neighbor.description = description
|
183
|
+
assert_equal(description, neighbor.description)
|
184
|
+
neighbor.description = ' '
|
185
|
+
assert(neighbor.description.empty?)
|
186
|
+
neighbor.description = neighbor.default_description
|
187
|
+
assert_equal(neighbor.description, neighbor.default_description)
|
188
|
+
neighbor.destroy
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_multiple_descriptions
|
193
|
+
# First create multiple routers with multiple descriptions.
|
194
|
+
test_data.each do |d|
|
195
|
+
d[:neighbors].each do |addr|
|
196
|
+
neighbor = create_neighbor(d[:vrf], addr)
|
197
|
+
neighbor.description = "#{d[:vrf]}:#{addr}"
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Now test if the description has been correctly set
|
202
|
+
RouterBgpNeighbor.neighbors.each_value do |bgp_vrfs|
|
203
|
+
bgp_vrfs.each do |vrf, neighbors|
|
204
|
+
neighbors.each do |addr, neighbor|
|
205
|
+
assert_equal("#{vrf}:#{addr}", neighbor.description)
|
206
|
+
neighbor.description = ''
|
207
|
+
assert(neighbor.description.empty?)
|
208
|
+
neighbor.description = neighbor.default_description
|
209
|
+
assert_equal(neighbor.description, neighbor.default_description)
|
210
|
+
neighbor.destroy
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_connected_check
|
217
|
+
%w(default test_vrf).each do |vrf|
|
218
|
+
neighbor = create_neighbor(vrf)
|
219
|
+
check = [true, false, neighbor.default_connected_check]
|
220
|
+
check.each do |value|
|
221
|
+
neighbor.connected_check = value
|
222
|
+
assert_equal(value, neighbor.connected_check)
|
223
|
+
end
|
224
|
+
neighbor.destroy
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_capability_negotiation
|
229
|
+
%w(default test_vrf).each do |vrf|
|
230
|
+
neighbor = create_neighbor(vrf)
|
231
|
+
if platform == :ios_xr
|
232
|
+
assert_nil(neighbor.capability_negotiation)
|
233
|
+
assert_nil(neighbor.default_capability_negotiation)
|
234
|
+
assert_raises(Cisco::UnsupportedError) do
|
235
|
+
neighbor.capability_negotiation = true
|
236
|
+
end
|
237
|
+
else
|
238
|
+
check = [true, false, neighbor.default_capability_negotiation]
|
239
|
+
check.each do |value|
|
240
|
+
neighbor.capability_negotiation = value
|
241
|
+
assert_equal(value, neighbor.capability_negotiation)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
neighbor.destroy
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_dynamic_capability
|
249
|
+
%w(default test_vrf).each do |vrf|
|
250
|
+
neighbor = create_neighbor(vrf)
|
251
|
+
if platform == :ios_xr
|
252
|
+
assert_nil(neighbor.dynamic_capability)
|
253
|
+
assert_nil(neighbor.default_dynamic_capability)
|
254
|
+
assert_raises(Cisco::UnsupportedError) do
|
255
|
+
neighbor.dynamic_capability = true
|
256
|
+
end
|
257
|
+
else
|
258
|
+
check = [true, false, neighbor.default_dynamic_capability]
|
259
|
+
check.each do |value|
|
260
|
+
neighbor.dynamic_capability = value
|
261
|
+
assert_equal(value, neighbor.dynamic_capability)
|
262
|
+
end
|
263
|
+
end
|
264
|
+
neighbor.destroy
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
268
|
+
def test_bfd
|
269
|
+
%w(default test_vrf).each do |vrf|
|
270
|
+
neighbor = create_neighbor(vrf)
|
271
|
+
if validate_property_excluded?('bgp_neighbor', 'bfd')
|
272
|
+
assert_nil(neighbor.bfd)
|
273
|
+
assert_nil(neighbor.default_bfd)
|
274
|
+
assert_raises(Cisco::UnsupportedError) do
|
275
|
+
neighbor.bfd = true
|
276
|
+
end
|
277
|
+
else
|
278
|
+
check = [false, true, neighbor.default_bfd]
|
279
|
+
check.each do |value|
|
280
|
+
neighbor.bfd = value
|
281
|
+
assert_equal(value, neighbor.bfd)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
neighbor.destroy
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def test_ebgp_multihop
|
289
|
+
%w(default test_vrf).each do |vrf|
|
290
|
+
neighbor = create_neighbor(vrf)
|
291
|
+
ttls = [24, neighbor.default_ebgp_multihop]
|
292
|
+
ttls.each do |ebgp_multihop|
|
293
|
+
neighbor.ebgp_multihop = ebgp_multihop
|
294
|
+
assert_equal(ebgp_multihop, neighbor.ebgp_multihop)
|
295
|
+
end
|
296
|
+
neighbor.destroy
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
def test_local_as
|
301
|
+
%w(default test_vrf).each do |vrf|
|
302
|
+
neighbor = create_neighbor(vrf)
|
303
|
+
local_asnum = [42, '52', '1.1', neighbor.default_local_as]
|
304
|
+
local_asnum.each do |asnum|
|
305
|
+
neighbor.local_as = asnum
|
306
|
+
assert_equal(asnum.to_s, neighbor.local_as)
|
307
|
+
end
|
308
|
+
|
309
|
+
# test a negative value
|
310
|
+
assert_raises(CliError) do
|
311
|
+
neighbor.local_as = '52 15'
|
312
|
+
end
|
313
|
+
neighbor.destroy
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_log_neighbor_changes
|
318
|
+
if platform == :ios_xr || node.product_id[/N(5|6)/]
|
319
|
+
b = create_neighbor('blue')
|
320
|
+
assert_nil(b.log_neighbor_changes)
|
321
|
+
assert_nil(b.default_log_neighbor_changes)
|
322
|
+
assert_raises(Cisco::UnsupportedError) do
|
323
|
+
b.log_neighbor_changes = :enable
|
324
|
+
end
|
325
|
+
return
|
326
|
+
end
|
327
|
+
skip_incompat_version?('bgp_neighbor', 'log_neighbor_changes')
|
328
|
+
%w(default test_vrf).each do |vrf|
|
329
|
+
neighbor = create_neighbor(vrf)
|
330
|
+
check = [:enable, :disable, :inherit, 'enable', 'disable', 'inherit',
|
331
|
+
neighbor.default_log_neighbor_changes]
|
332
|
+
|
333
|
+
check.each do |value|
|
334
|
+
neighbor.log_neighbor_changes = value
|
335
|
+
assert_equal(value.to_sym, neighbor.log_neighbor_changes)
|
336
|
+
end
|
337
|
+
neighbor.destroy
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_low_memory_exempt
|
342
|
+
%w(default test_vrf).each do |vrf|
|
343
|
+
neighbor = create_neighbor(vrf)
|
344
|
+
if platform == :ios_xr
|
345
|
+
assert_nil(neighbor.low_memory_exempt)
|
346
|
+
assert_nil(neighbor.default_low_memory_exempt)
|
347
|
+
assert_raises(Cisco::UnsupportedError) do
|
348
|
+
neighbor.low_memory_exempt = true
|
349
|
+
end
|
350
|
+
else
|
351
|
+
check = [true, false, neighbor.default_low_memory_exempt]
|
352
|
+
check.each do |value|
|
353
|
+
neighbor.low_memory_exempt = value
|
354
|
+
assert_equal(value, neighbor.low_memory_exempt)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
neighbor.destroy
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
def test_maximum_peers
|
362
|
+
skip('Maximum-peers does not apply to IOS XR') if platform == :ios_xr
|
363
|
+
|
364
|
+
# only "address/prefix" type of neighbor address will accept
|
365
|
+
# maximum_peers command, so not supported on XR
|
366
|
+
addr = '1.1.1.0/24'
|
367
|
+
%w(default test_vrf).each do |vrf|
|
368
|
+
neighbor = create_neighbor(vrf, addr)
|
369
|
+
peers = [200, neighbor.default_maximum_peers]
|
370
|
+
peers.each do |num|
|
371
|
+
neighbor.maximum_peers = num
|
372
|
+
assert_equal(num, neighbor.maximum_peers)
|
373
|
+
end
|
374
|
+
neighbor.destroy
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
def test_password
|
379
|
+
%w(default test_vrf).each do |vrf|
|
380
|
+
neighbor = create_neighbor(vrf)
|
381
|
+
passwords = {}
|
382
|
+
if platform == :ios_xr
|
383
|
+
passwords[:cleartext] = 'test'
|
384
|
+
passwords[:md5] = '386c0565965f89de'
|
385
|
+
# not currently supporting XR specific 'password inheritance-disable'
|
386
|
+
else
|
387
|
+
passwords[:cleartext] = 'test'
|
388
|
+
passwords[:"3des"] = '386c0565965f89de'
|
389
|
+
passwords[:cisco_type_7] = '046E1803362E595C260E0B240619050A2D'
|
390
|
+
end
|
391
|
+
|
392
|
+
passwords.each do |type, password|
|
393
|
+
neighbor.password_set(password, type)
|
394
|
+
if platform == :ios_xr
|
395
|
+
if type == :cleartext
|
396
|
+
# will always be type "encrypted" on XR
|
397
|
+
assert_equal(:md5, neighbor.password_type)
|
398
|
+
# don't know what the encrypted password will look like
|
399
|
+
# so just make sure it is not empty
|
400
|
+
refute_empty(neighbor.password)
|
401
|
+
else
|
402
|
+
assert_equal(type, neighbor.password_type)
|
403
|
+
assert_equal(password, neighbor.password)
|
404
|
+
end
|
405
|
+
else
|
406
|
+
if type == :cleartext
|
407
|
+
assert_equal(:"3des", neighbor.password_type)
|
408
|
+
assert_equal(passwords[:"3des"], neighbor.password)
|
409
|
+
else
|
410
|
+
assert_equal(type, neighbor.password_type)
|
411
|
+
assert_equal(password, neighbor.password)
|
412
|
+
end
|
413
|
+
end
|
414
|
+
# now test removing the password setting
|
415
|
+
neighbor.password_set(' ')
|
416
|
+
assert(neighbor.password.empty?)
|
417
|
+
# now test default password
|
418
|
+
neighbor.password_set(neighbor.default_password)
|
419
|
+
assert_equal(neighbor.default_password, neighbor.password)
|
420
|
+
end
|
421
|
+
neighbor.destroy
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
def test_default_password_type
|
426
|
+
%w(default test_vrf).each do |vrf|
|
427
|
+
neighbor = create_neighbor(vrf)
|
428
|
+
password = 'test'
|
429
|
+
expected_password = '386c0565965f89de'
|
430
|
+
|
431
|
+
test = proc do
|
432
|
+
if platform == :ios_xr
|
433
|
+
assert_equal(:md5, neighbor.password_type)
|
434
|
+
refute_empty(neighbor.password)
|
435
|
+
else
|
436
|
+
assert_equal(expected_password, neighbor.password)
|
437
|
+
assert_equal(:"3des", neighbor.password_type)
|
438
|
+
end
|
439
|
+
# clear password
|
440
|
+
neighbor.password_set('')
|
441
|
+
assert(neighbor.password.empty?)
|
442
|
+
end
|
443
|
+
|
444
|
+
# Test 1: if we don't set password type, default should be cleartext,
|
445
|
+
# we can verify by checking return type to be
|
446
|
+
# :3des/:md5, and encrypted text.
|
447
|
+
neighbor.password_set(password)
|
448
|
+
test.call
|
449
|
+
|
450
|
+
# Test 2: we set explicitly the password type to be default password type:
|
451
|
+
# cleartext, and verify.
|
452
|
+
neighbor.password_set(password, neighbor.default_password_type)
|
453
|
+
test.call
|
454
|
+
neighbor.destroy
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
def test_remote_as
|
459
|
+
%w(default test_vrf).each do |vrf|
|
460
|
+
neighbor = RouterBgpNeighbor.new(ASN, vrf, ADDR)
|
461
|
+
[42, '1.1', neighbor.default_remote_as].each do |asnum|
|
462
|
+
neighbor.remote_as = asnum
|
463
|
+
assert_equal(asnum.to_s, neighbor.remote_as)
|
464
|
+
end
|
465
|
+
neighbor.destroy
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
def test_remove_private_as_options
|
470
|
+
%w(default test_vrf).each do |vrf|
|
471
|
+
neighbor = create_neighbor(vrf)
|
472
|
+
if platform == :ios_xr
|
473
|
+
assert_nil(neighbor.remove_private_as)
|
474
|
+
assert_nil(neighbor.default_remove_private_as)
|
475
|
+
assert_raises(Cisco::UnsupportedError) do
|
476
|
+
neighbor.remove_private_as = :enable
|
477
|
+
end
|
478
|
+
else
|
479
|
+
options = [:enable, :disable, :all, :"replace-as", 'enable', 'disable',
|
480
|
+
'all', 'replace-as', neighbor.default_remove_private_as]
|
481
|
+
|
482
|
+
options.each do |option|
|
483
|
+
neighbor.remove_private_as = option
|
484
|
+
assert_equal(option.to_sym, neighbor.remove_private_as)
|
485
|
+
end
|
486
|
+
|
487
|
+
neighbor.remove_private_as = neighbor.default_remove_private_as
|
488
|
+
assert_equal(neighbor.default_remove_private_as,
|
489
|
+
neighbor.remove_private_as)
|
490
|
+
end
|
491
|
+
neighbor.destroy
|
492
|
+
end
|
493
|
+
end
|
494
|
+
|
495
|
+
def test_shutdown
|
496
|
+
%w(default test_vrf).each do |vrf|
|
497
|
+
neighbor = create_neighbor(vrf)
|
498
|
+
check = [true, false, neighbor.default_shutdown]
|
499
|
+
check.each do |value|
|
500
|
+
neighbor.shutdown = value
|
501
|
+
assert_equal(value, neighbor.shutdown)
|
502
|
+
end
|
503
|
+
neighbor.destroy
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
def test_suppress_4_byte_as
|
508
|
+
%w(default test_vrf).each do |vrf|
|
509
|
+
neighbor = create_neighbor(vrf)
|
510
|
+
check = [true, false, neighbor.default_suppress_4_byte_as]
|
511
|
+
check.each do |value|
|
512
|
+
neighbor.suppress_4_byte_as = value
|
513
|
+
assert_equal(value, neighbor.suppress_4_byte_as)
|
514
|
+
end
|
515
|
+
neighbor.destroy
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_timers
|
520
|
+
%w(default test_vrf).each do |vrf|
|
521
|
+
neighbor = create_neighbor(vrf)
|
522
|
+
timers = [{ keep: 40, hold: 90 },
|
523
|
+
{ keep: neighbor.default_timers_keepalive,
|
524
|
+
hold: neighbor.default_timers_holdtime },
|
525
|
+
{ keep: neighbor.default_timers_keepalive,
|
526
|
+
hold: 90 },
|
527
|
+
{ keep: 40, hold: neighbor.default_timers_holdtime },
|
528
|
+
]
|
529
|
+
timers.each do |timer|
|
530
|
+
neighbor.timers_set(timer[:keep], timer[:hold])
|
531
|
+
assert_equal(timer[:keep], neighbor.timers_keepalive)
|
532
|
+
assert_equal(timer[:hold], neighbor.timers_holdtime)
|
533
|
+
end
|
534
|
+
neighbor.destroy
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
def test_transport_passive_mode
|
539
|
+
%w(default test_vrf).each do |vrf|
|
540
|
+
neighbor = create_neighbor(vrf)
|
541
|
+
check = []
|
542
|
+
if platform == :ios_xr
|
543
|
+
check = [:active_only, :passive_only, :both, :none,
|
544
|
+
neighbor.default_transport_passive_mode]
|
545
|
+
else
|
546
|
+
check = [:passive_only, :none,
|
547
|
+
neighbor.default_transport_passive_mode]
|
548
|
+
end
|
549
|
+
check.each do |value|
|
550
|
+
neighbor.transport_passive_mode = value
|
551
|
+
assert_equal(value, neighbor.transport_passive_mode)
|
552
|
+
end
|
553
|
+
neighbor.destroy
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
557
|
+
def test_transport_passive_only
|
558
|
+
%w(default test_vrf).each do |vrf|
|
559
|
+
neighbor = create_neighbor(vrf)
|
560
|
+
check = [true, false, neighbor.default_transport_passive_only]
|
561
|
+
check.each do |value|
|
562
|
+
neighbor.transport_passive_only = value
|
563
|
+
assert_equal(value, neighbor.transport_passive_only)
|
564
|
+
end
|
565
|
+
neighbor.destroy
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
569
|
+
def test_update_source
|
570
|
+
%w(default test_vrf).each do |vrf|
|
571
|
+
neighbor = create_neighbor(vrf)
|
572
|
+
test_interfaces = ['loopback1', interfaces[0], interfaces[0].downcase,
|
573
|
+
neighbor.default_update_source]
|
574
|
+
test_interfaces.each do |interface|
|
575
|
+
neighbor.update_source = interface
|
576
|
+
assert_equal(interface.downcase, neighbor.update_source)
|
577
|
+
end
|
578
|
+
neighbor.destroy
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
def test_peer_type
|
583
|
+
skip("#{node.product_id} doesn't support this feature") unless
|
584
|
+
node.product_id[/N9K.*EX/]
|
585
|
+
%w(default test_vrf).each do |vrf|
|
586
|
+
neighbor = RouterBgpNeighbor.new(ASN, vrf, ADDR)
|
587
|
+
check = ['fabric-border-leaf', 'fabric-external',
|
588
|
+
neighbor.default_peer_type]
|
589
|
+
check.each do |val|
|
590
|
+
neighbor.peer_type = val
|
591
|
+
assert_equal(val, neighbor.peer_type)
|
592
|
+
end
|
593
|
+
neighbor.destroy
|
594
|
+
end
|
595
|
+
end
|
596
|
+
end
|