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,198 @@
|
|
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/bridge_domain'
|
17
|
+
require_relative '../lib/cisco_node_utils/vlan'
|
18
|
+
|
19
|
+
include Cisco
|
20
|
+
|
21
|
+
# TestBridgeDomain - Minitest for bridge domain class.
|
22
|
+
class TestBridgeDomain < CiscoTestCase
|
23
|
+
@skip_unless_supported = 'bridge_domain'
|
24
|
+
@@cleaned = false # rubocop:disable Style/ClassVars
|
25
|
+
|
26
|
+
def cleanup
|
27
|
+
remove_all_vlans
|
28
|
+
remove_all_bridge_domains
|
29
|
+
end
|
30
|
+
|
31
|
+
def setup
|
32
|
+
super
|
33
|
+
cleanup unless @@cleaned
|
34
|
+
@@cleaned = true # rubocop:disable Style/ClassVars
|
35
|
+
end
|
36
|
+
|
37
|
+
def teardown
|
38
|
+
cleanup
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_single_bd_create_destroy
|
43
|
+
bd = BridgeDomain.new('100', true)
|
44
|
+
bds = BridgeDomain.bds
|
45
|
+
assert(bds.key?('100'), 'Error: failed to create bridge-domain 100')
|
46
|
+
|
47
|
+
bd.destroy
|
48
|
+
bds = BridgeDomain.bds
|
49
|
+
refute(bds.key?('100'), 'Error: failed to destroy bridge-domain 100')
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_bd_create_if_vlan_exists
|
53
|
+
vlan = Vlan.new(100)
|
54
|
+
assert_raises(CliError,
|
55
|
+
'Vlan already exist did not raise CliError') do
|
56
|
+
BridgeDomain.new(100)
|
57
|
+
end
|
58
|
+
vlan.destroy
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_create_already_existing_bd
|
62
|
+
create = '100-120'
|
63
|
+
BridgeDomain.new('100-110,115')
|
64
|
+
bd = BridgeDomain.new('100-120')
|
65
|
+
bds = BridgeDomain.bds
|
66
|
+
BridgeDomain.bd_ids_to_array(create).each do |id|
|
67
|
+
assert(bds.key?(id.to_s), 'Error: failed to create bridge-domain ' << id)
|
68
|
+
end
|
69
|
+
bd.destroy
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_multiple_bd_create_destroy
|
73
|
+
create = '101-102,120'
|
74
|
+
bdlist = BridgeDomain.bd_ids_to_array(create)
|
75
|
+
|
76
|
+
bd = BridgeDomain.new(create, true)
|
77
|
+
bds = BridgeDomain.bds
|
78
|
+
bdlist.each do |id|
|
79
|
+
assert(bds.key?(id.to_s), 'Error: failed to create bridge-domain ' << id)
|
80
|
+
end
|
81
|
+
|
82
|
+
bd.destroy
|
83
|
+
bds = BridgeDomain.bds
|
84
|
+
bdlist.each do |id|
|
85
|
+
refute(bds.key?(id.to_s), 'Error: failed to destroy bridge-domain ' << id)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_bd_create_noorder_and_space
|
90
|
+
create = '100, 90, 200, 2-4'
|
91
|
+
bd = BridgeDomain.new(create)
|
92
|
+
bds = BridgeDomain.bds
|
93
|
+
BridgeDomain.bd_ids_to_array(create).each do |id|
|
94
|
+
assert(bds.key?(id.to_s), 'Error: failed to create bridge-domain ' << id)
|
95
|
+
end
|
96
|
+
bd.destroy
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_bd_shutdown
|
100
|
+
bd = BridgeDomain.new(101)
|
101
|
+
refute(bd.shutdown)
|
102
|
+
bd.shutdown = true
|
103
|
+
assert(bd.shutdown)
|
104
|
+
bd.shutdown = false
|
105
|
+
refute(bd.shutdown)
|
106
|
+
bd.destroy
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_bd_name
|
110
|
+
bd = BridgeDomain.new(101)
|
111
|
+
assert_equal(bd.default_bd_name, bd.bd_name,
|
112
|
+
'Error: Bridge-Domain name not initialized to default')
|
113
|
+
|
114
|
+
name = 'my_bridge'
|
115
|
+
bd.bd_name = name
|
116
|
+
assert_equal(name, bd.bd_name,
|
117
|
+
'Error: Bridge-Domain name not updated to #{name}')
|
118
|
+
|
119
|
+
name = ''
|
120
|
+
bd.bd_name = name
|
121
|
+
assert_equal(bd.default_bd_name, bd.default_bd_name,
|
122
|
+
'Error: Bridge-Domain name not updated to default')
|
123
|
+
|
124
|
+
bd.bd_name = bd.default_bd_name
|
125
|
+
assert_equal(bd.default_bd_name, bd.bd_name,
|
126
|
+
'Error: Bridge-Domain name not restored to default')
|
127
|
+
bd.destroy
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_bd_fabric_control
|
131
|
+
bd = BridgeDomain.new('100')
|
132
|
+
assert_equal(bd.default_fabric_control, bd.fabric_control,
|
133
|
+
'Error: Bridge-Domain fabric-control is not matching')
|
134
|
+
bd.fabric_control = true
|
135
|
+
assert(bd.fabric_control)
|
136
|
+
bd.destroy
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_another_bd_as_fabric_control
|
140
|
+
bd = BridgeDomain.new(100)
|
141
|
+
assert_equal(bd.default_fabric_control, bd.fabric_control,
|
142
|
+
'Error: Bridge-Domain fabric-control is not matching')
|
143
|
+
bd.fabric_control = true
|
144
|
+
assert(bd.fabric_control)
|
145
|
+
another_bd = BridgeDomain.new(101)
|
146
|
+
|
147
|
+
assert_raises(CliError,
|
148
|
+
'BD misconfig did not raise CliError') do
|
149
|
+
another_bd.fabric_control = true
|
150
|
+
end
|
151
|
+
bd.destroy
|
152
|
+
another_bd.destroy
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_invalid_bd_create
|
156
|
+
assert_raises(CliError,
|
157
|
+
'BD misconfig did not raise CliError') do
|
158
|
+
BridgeDomain.new('90, 5000-5004,100')
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_multiple_bd_combinations
|
163
|
+
bds = BridgeDomain.new('100-110')
|
164
|
+
bd_hash = {}
|
165
|
+
bd_hash['100'] = [true, false, 'bd100']
|
166
|
+
bd_hash['105'] = [true, true, 'bd105']
|
167
|
+
bd_hash['107'] = [true, false, 'bd107']
|
168
|
+
bd_hash['110'] = [true, false, '']
|
169
|
+
BridgeDomain.bds.each do |bd, obj|
|
170
|
+
if bd_hash.key?(bd)
|
171
|
+
obj.shutdown = bd_hash[bd][0]
|
172
|
+
assert_equal(bd_hash[bd][0], obj.shutdown,
|
173
|
+
'Error: Bridge-Domain state is not matching')
|
174
|
+
|
175
|
+
obj.fabric_control = bd_hash[bd][1]
|
176
|
+
assert_equal(bd_hash[bd][1], obj.fabric_control,
|
177
|
+
'Error: Bridge-Domain type is not matching')
|
178
|
+
|
179
|
+
if bd_hash[bd][2] != ''
|
180
|
+
obj.bd_name = bd_hash[bd][2]
|
181
|
+
assert_equal(bd_hash[bd][2], obj.bd_name,
|
182
|
+
'Error: Bridge-Domain name is not matching')
|
183
|
+
else
|
184
|
+
assert_equal(obj.default_bd_name, obj.bd_name,
|
185
|
+
'Error: Bridge-Domain name is not matching')
|
186
|
+
end
|
187
|
+
else
|
188
|
+
assert_equal(obj.default_shutdown, obj.shutdown,
|
189
|
+
'Error: Bridge-Domain state is not matching')
|
190
|
+
assert_equal(obj.default_fabric_control, obj.fabric_control,
|
191
|
+
'Error: Bridge-Domain type is not matching')
|
192
|
+
assert_equal(obj.default_bd_name, obj.bd_name,
|
193
|
+
'Error: Bridge-Domain name is not matching')
|
194
|
+
end
|
195
|
+
end
|
196
|
+
bds.destroy
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,109 @@
|
|
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/bridge_domain_vni'
|
17
|
+
|
18
|
+
include Cisco
|
19
|
+
|
20
|
+
# TestBridgeDomainVNI - Minitest for bridge domain class.
|
21
|
+
class TestBridgeDomainVNI < CiscoTestCase
|
22
|
+
@skip_unless_supported = 'bridge_domain_vni'
|
23
|
+
@@cleaned = false # rubocop:disable Style/ClassVars
|
24
|
+
|
25
|
+
def cleanup
|
26
|
+
remove_all_vlans
|
27
|
+
config_no_warn('no feature vni')
|
28
|
+
BridgeDomainVNI.range_bds.each do |_bd, obj|
|
29
|
+
obj.destroy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def setup
|
34
|
+
super
|
35
|
+
vdc_limit_f3_no_intf_needed(:set)
|
36
|
+
cleanup unless @@cleaned
|
37
|
+
@@cleaned = true # rubocop:disable Style/ClassVars
|
38
|
+
end
|
39
|
+
|
40
|
+
def teardown
|
41
|
+
cleanup
|
42
|
+
vdc_limit_f3_no_intf_needed(:clear) if first_or_last_teardown
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_single_bd_member_vni
|
47
|
+
bd = BridgeDomainVNI.new('100')
|
48
|
+
assert_equal(bd.default_member_vni, bd.member_vni,
|
49
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
50
|
+
|
51
|
+
vni = '6000'
|
52
|
+
bd.member_vni = vni
|
53
|
+
assert_equal(vni, bd.member_vni,
|
54
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
55
|
+
|
56
|
+
bd.member_vni = ''
|
57
|
+
assert_equal(bd.default_member_vni, bd.member_vni,
|
58
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
59
|
+
|
60
|
+
bd.destroy
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_multiple_bd_member_vni
|
64
|
+
bd = BridgeDomainVNI.new('100-110, 150, 170-171 ')
|
65
|
+
assert_equal(bd.default_member_vni, bd.member_vni,
|
66
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
67
|
+
|
68
|
+
vni = '6000-6010,6050,5070-5071'
|
69
|
+
bd.member_vni = vni
|
70
|
+
assert_equal(vni, bd.member_vni,
|
71
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
72
|
+
|
73
|
+
bd.member_vni = ''
|
74
|
+
assert_equal(bd.default_member_vni, bd.member_vni,
|
75
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
76
|
+
|
77
|
+
bd.destroy
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_member_vni_empty_assign
|
81
|
+
bd = BridgeDomainVNI.new(100)
|
82
|
+
bd.member_vni = ''
|
83
|
+
assert_equal(bd.default_member_vni, bd.member_vni,
|
84
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
85
|
+
bd.destroy
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_overwrite_bd_member_vni
|
89
|
+
bd = BridgeDomainVNI.new('100-110')
|
90
|
+
assert_equal(bd.default_member_vni, bd.member_vni,
|
91
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
92
|
+
|
93
|
+
vni = '5000-5010'
|
94
|
+
bd.member_vni = vni
|
95
|
+
assert_equal(vni, bd.member_vni,
|
96
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
97
|
+
|
98
|
+
vni = '5000-5005,6006-6010'
|
99
|
+
bd.member_vni = vni
|
100
|
+
assert_equal(vni, bd.member_vni,
|
101
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
102
|
+
|
103
|
+
bd.member_vni = ''
|
104
|
+
assert_equal(bd.default_member_vni, bd.member_vni,
|
105
|
+
'Error: Bridge-Domain is mapped to different vnis')
|
106
|
+
|
107
|
+
bd.destroy
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,111 @@
|
|
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 'basetest'
|
16
|
+
|
17
|
+
require_relative '../lib/cisco_node_utils/client/utils.rb'
|
18
|
+
|
19
|
+
# TestClientUtils - Minitest for Client utility functions
|
20
|
+
class TestClientUtils < Minitest::Test
|
21
|
+
def show_run_ospf
|
22
|
+
"\
|
23
|
+
router ospf foo
|
24
|
+
vrf red
|
25
|
+
log-adjacency-changes
|
26
|
+
router ospf bar
|
27
|
+
log-adjacency-changes
|
28
|
+
vrf red
|
29
|
+
log-adjacency-changes detail
|
30
|
+
vrf blue
|
31
|
+
!
|
32
|
+
router ospf baz
|
33
|
+
log-adjacency-changes detail"
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_find_subconfig
|
37
|
+
result = Cisco::Client.find_subconfig(show_run_ospf, /router ospf bar/)
|
38
|
+
assert_equal("\
|
39
|
+
log-adjacency-changes
|
40
|
+
vrf red
|
41
|
+
log-adjacency-changes detail
|
42
|
+
vrf blue",
|
43
|
+
result)
|
44
|
+
|
45
|
+
assert_nil(Cisco::Client.find_subconfig(result, /vrf blue/))
|
46
|
+
|
47
|
+
assert_equal('log-adjacency-changes detail',
|
48
|
+
Cisco::Client.find_subconfig(result, /vrf red/))
|
49
|
+
|
50
|
+
assert_nil(Cisco::Client.find_subconfig(result, /vrf green/))
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_filter_cli
|
54
|
+
# Unfiltered (no context / values)
|
55
|
+
assert_equal(show_run_ospf,
|
56
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf))
|
57
|
+
# Filtered by context but not by value
|
58
|
+
assert_equal("\
|
59
|
+
log-adjacency-changes
|
60
|
+
vrf red
|
61
|
+
log-adjacency-changes detail
|
62
|
+
vrf blue",
|
63
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
64
|
+
context: [/router ospf bar/]))
|
65
|
+
# Filtered by value but not by context
|
66
|
+
assert_equal(['router ospf foo', 'router ospf bar', 'router ospf baz'],
|
67
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
68
|
+
value: /router ospf .*/))
|
69
|
+
# rubocop:disable Style/WordArray
|
70
|
+
|
71
|
+
# Values with a single match group
|
72
|
+
assert_equal(['foo', 'bar', 'baz'],
|
73
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
74
|
+
value: /router ospf (.*)/))
|
75
|
+
# Values with multiple match groups
|
76
|
+
assert_equal([['ospf', 'foo'], ['ospf', 'bar'], ['ospf', 'baz']],
|
77
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
78
|
+
value: /router (\S+) (.*)/))
|
79
|
+
# rubocop:enable Style/WordArray
|
80
|
+
|
81
|
+
# Values with a single match group
|
82
|
+
# Find an entry in the parent submode, ignoring nested submodes
|
83
|
+
assert_equal(
|
84
|
+
['log-adjacency-changes'],
|
85
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
86
|
+
value: /^log-adjacency-changes.*$/,
|
87
|
+
context: [/router ospf bar/]))
|
88
|
+
# Find an entry in a nested submode
|
89
|
+
assert_equal(
|
90
|
+
['log-adjacency-changes detail'],
|
91
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
92
|
+
value: /^log-adjacency-changes.*$/,
|
93
|
+
context: [/router ospf bar/, /vrf red/]))
|
94
|
+
# Submode exists but does not have a match
|
95
|
+
assert_nil(
|
96
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
97
|
+
value: /^log-adjacency-changes.*$/,
|
98
|
+
context: [/router ospf bar/, /vrf blue/]))
|
99
|
+
# Submode does not exist
|
100
|
+
assert_nil(
|
101
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
102
|
+
value: /^log-adjacency-changes.*$/,
|
103
|
+
context: [/router ospf bar/, /vrf green/]))
|
104
|
+
|
105
|
+
# Entry exists in submode only
|
106
|
+
assert_nil(
|
107
|
+
Cisco::Client.filter_cli(cli_output: show_run_ospf,
|
108
|
+
value: /^log-adjacency-changes.*$/,
|
109
|
+
context: [/router ospf foo/]))
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# cisco_cmn_utils Unit Tests
|
3
|
+
#
|
4
|
+
# Chris Van Heuveln, May, 2016
|
5
|
+
#
|
6
|
+
# Copyright (c) 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/cisco_cmn_utils'
|
22
|
+
|
23
|
+
# Test utility methods in cisco_cmn_utils
|
24
|
+
class TestCmnUtils < CiscoTestCase
|
25
|
+
#
|
26
|
+
# TBD: Add tests for *all* methods in cisco_cmn_utils
|
27
|
+
#
|
28
|
+
def test_dash_range_to_ruby_range
|
29
|
+
expected = [2..5, 9..9, 4..6]
|
30
|
+
|
31
|
+
str_input = '2-5, 9, 4-6'
|
32
|
+
assert_equal(expected, Utils.dash_range_to_ruby_range(str_input))
|
33
|
+
|
34
|
+
arr_input = ['2-5', '9', '4-6']
|
35
|
+
assert_equal(expected, Utils.dash_range_to_ruby_range(arr_input))
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_ruby_range_to_dash_range
|
39
|
+
str_expected = '2-5, 9, 4-6'
|
40
|
+
arr_expected = ['2-5', '9', '4-6']
|
41
|
+
|
42
|
+
input1 = [2..5, 9..9, 4..6]
|
43
|
+
input2 = input1.clone
|
44
|
+
assert_equal(str_expected, Utils.ruby_range_to_dash_range(input1, :string))
|
45
|
+
assert_equal(arr_expected, Utils.ruby_range_to_dash_range(input2, :array))
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_dash_range_to_elements
|
49
|
+
expected = %w(2 3 4 5 6 9)
|
50
|
+
|
51
|
+
str_input = '2-5, 9, 4-6'
|
52
|
+
str_arr_input = ['2-5, 9, 4-6']
|
53
|
+
arr_input = str_input.split(', ')
|
54
|
+
|
55
|
+
assert_equal(expected, Utils.dash_range_to_elements(str_input))
|
56
|
+
assert_equal(expected, Utils.dash_range_to_elements(str_arr_input))
|
57
|
+
assert_equal(expected, Utils.dash_range_to_elements(arr_input))
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_merge_range
|
61
|
+
expected = [2..6, 9..9]
|
62
|
+
input = [2..5, 9..9, 4..6]
|
63
|
+
assert_equal(expected, Utils.merge_range(input))
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_normalize_range_array
|
67
|
+
expected = ['2-6', '9']
|
68
|
+
|
69
|
+
str_input = '2-5, 9, 4-6'
|
70
|
+
str_arr_input = ['2-5, 9, 4-6']
|
71
|
+
arr_input = str_input.split(', ')
|
72
|
+
assert_equal(expected, Utils.normalize_range_array(str_input))
|
73
|
+
assert_equal(expected, Utils.normalize_range_array(str_arr_input))
|
74
|
+
assert_equal(expected, Utils.normalize_range_array(arr_input))
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Michael Wiebe, December 2014
|
4
|
+
#
|
5
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'ciscotest'
|
20
|
+
require_relative '../lib/cisco_node_utils/configparser_lib'
|
21
|
+
require 'timeout'
|
22
|
+
require 'yaml'
|
23
|
+
|
24
|
+
def load_yaml(test_type=:positive)
|
25
|
+
if test_type == :positive
|
26
|
+
path = File.expand_path('../cmd_config.yaml', __FILE__)
|
27
|
+
elsif test_type == :negative
|
28
|
+
path = File.expand_path('../cmd_config_invalid.yaml', __FILE__)
|
29
|
+
else
|
30
|
+
fail TypeError
|
31
|
+
end
|
32
|
+
YAML.load(File.read(path))
|
33
|
+
end
|
34
|
+
|
35
|
+
# TestCommandConfig - Minitest for ConfigParser module
|
36
|
+
class TestCommandConfig < CiscoTestCase
|
37
|
+
include ConfigParser
|
38
|
+
|
39
|
+
# ---------------------------------------------------------------------------
|
40
|
+
# Helper Methods
|
41
|
+
# ---------------------------------------------------------------------------
|
42
|
+
|
43
|
+
def remove_whitespace(commands)
|
44
|
+
commands.gsub(/^\s*$\n/, '')
|
45
|
+
end # remove_whitespace
|
46
|
+
|
47
|
+
def compare_with_results(desired_config_str, _current_key, nvgen)
|
48
|
+
retrieve_command = 'show running all'
|
49
|
+
running_config_str = node.get(command: retrieve_command)
|
50
|
+
|
51
|
+
begin
|
52
|
+
should_config = ConfigParser::Configuration.new(desired_config_str)
|
53
|
+
running_config = ConfigParser::Configuration.new(running_config_str)
|
54
|
+
existing = should_config.compare_with(running_config)
|
55
|
+
rescue StopIteration => e
|
56
|
+
puts e.what
|
57
|
+
rescue ArgumentError => e
|
58
|
+
puts e.what
|
59
|
+
end
|
60
|
+
# puts "Existing command block:\n#{existing}"
|
61
|
+
if nvgen == false
|
62
|
+
msg = "The following configuration should be removed: #{desired_config_str}"
|
63
|
+
assert_equal(existing.empty?, true, msg)
|
64
|
+
else
|
65
|
+
msg = "The following configuration should exist but doesn't: #{desired_config_str}"
|
66
|
+
assert_equal(existing.empty?, false, msg)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def send_device_config(config_cmd_hash)
|
71
|
+
config_cmd_hash.each do |k, v|
|
72
|
+
v.each do |k1, v1|
|
73
|
+
next if k1 == 'nvgen'
|
74
|
+
config(v1) if k1 == 'setup'
|
75
|
+
# Send commands
|
76
|
+
cfg_cmd_str = "#{v1.gsub(/^/, ' ')}"
|
77
|
+
cfg_string = remove_whitespace(cfg_cmd_str)
|
78
|
+
# puts "cfg_string: \n||\n#{cfg_string}||\n"
|
79
|
+
begin
|
80
|
+
node.set(values: cfg_string)
|
81
|
+
# make sure config is present in success case
|
82
|
+
compare_with_results(v1, k, config_cmd_hash[k]['nvgen'])
|
83
|
+
rescue CliError => e
|
84
|
+
known_failure = e.message[/ERROR:.*port channel not present/]
|
85
|
+
refute(known_failure, 'ERROR: port channel not present')
|
86
|
+
raise
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def loopback
|
93
|
+
(platform == :ios_xr) ? 'Loopback' : 'loopback'
|
94
|
+
end
|
95
|
+
|
96
|
+
def build_int_scale_config(add=true)
|
97
|
+
add ? s = '' : s = 'no '
|
98
|
+
current_interface = 0
|
99
|
+
num_interfaces = 1024
|
100
|
+
command_list = ''
|
101
|
+
while current_interface < num_interfaces
|
102
|
+
command_list += "#{s}interface #{loopback}#{current_interface}\n"
|
103
|
+
current_interface += 1
|
104
|
+
end
|
105
|
+
command_list
|
106
|
+
end
|
107
|
+
|
108
|
+
# ---------------------------------------------------------------------------
|
109
|
+
# Test Case Methods
|
110
|
+
# ---------------------------------------------------------------------------
|
111
|
+
|
112
|
+
def test_valid_config
|
113
|
+
cfg_hash = load_yaml[platform.to_s]
|
114
|
+
begin
|
115
|
+
send_device_config(cfg_hash)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_valid_scale
|
120
|
+
show_int_count = "show int brief | i '^\S+\s+--' | count"
|
121
|
+
pre = @device.cmd(show_int_count)[/^(\d+)$/]
|
122
|
+
# Add 1024 loopback interfaces
|
123
|
+
cfg_hash_add = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
124
|
+
cfg_hash_add ['loopback-int-add']['command'] = "#{build_int_scale_config}"
|
125
|
+
cfg_hash_add ['loopback-int-add']['nvgen'] = true
|
126
|
+
begin
|
127
|
+
send_device_config(cfg_hash_add)
|
128
|
+
rescue Timeout::Error
|
129
|
+
puts "\n -- Long-running command, extending timeout +30 sec"
|
130
|
+
sleep 30 # long-running command
|
131
|
+
curr = @device.cmd('show int brief | count')[/^(\d+)$/]
|
132
|
+
flunk('Timeout while creating 1024 loopback interfaces' \
|
133
|
+
"(pre:#{pre} curr:#{curr}") unless pre == curr - 1024
|
134
|
+
end
|
135
|
+
|
136
|
+
# Remove 1024 loopback interfaces
|
137
|
+
cfg_hash_remove = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
|
138
|
+
cfg_hash_remove['loopback-int-add']['command'] = \
|
139
|
+
"#{build_int_scale_config(false)}"
|
140
|
+
cfg_hash_remove ['loopback-int-add']['nvgen'] = false
|
141
|
+
begin
|
142
|
+
send_device_config(cfg_hash_remove)
|
143
|
+
rescue Timeout::Error
|
144
|
+
puts "\n -- Long-running command, extending timeout +30 sec"
|
145
|
+
sleep 30 # long-running: n95 can take 70+ sec to remove all of these
|
146
|
+
curr = @device.cmd(show_int_count)[/^(\d+)$/]
|
147
|
+
flunk('Timeout while deleting 1024 loopback interfaces ' \
|
148
|
+
"(pre:#{pre} curr:#{curr}") unless pre == curr
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_invalid_config
|
153
|
+
cfg_hash = load_yaml(:negative)
|
154
|
+
cfg_hash.each_value do |v|
|
155
|
+
v.each_value do |v1|
|
156
|
+
cfg_cmd_str = "#{v1.gsub(/^/, ' ')}\n"
|
157
|
+
cfg_string = remove_whitespace(cfg_cmd_str)
|
158
|
+
assert_raises(Cisco::CliError) { node.set(values: cfg_string) }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_indent_with_tab
|
164
|
+
assert_raises(RuntimeError,
|
165
|
+
'Should have caught TAB char in indent area') do
|
166
|
+
Configuration.new(" \t interface loopback10")
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_build_min_config_hash
|
171
|
+
# 1. Get superset of running-config and agent-config
|
172
|
+
# 2. From superset derive minimum needed for parity with running
|
173
|
+
runn_str = "
|
174
|
+
\ninterface loopback10
|
175
|
+
\n description foo
|
176
|
+
\ninterface loopback11
|
177
|
+
\ninterface loopback12
|
178
|
+
\ninterface loopback13"
|
179
|
+
runn_hash = Configuration.new(runn_str)
|
180
|
+
|
181
|
+
agent_str = "
|
182
|
+
\ninterface loopback10
|
183
|
+
\n description 10
|
184
|
+
\ninterface loopback11
|
185
|
+
\nno interface loopback12
|
186
|
+
\ninterface loopback13"
|
187
|
+
agent_hash = Configuration.new(agent_str)
|
188
|
+
|
189
|
+
min_expected = ['interface loopback10',
|
190
|
+
'description 10',
|
191
|
+
'no interface loopback12',
|
192
|
+
].join("\n")
|
193
|
+
|
194
|
+
superset_str = agent_hash.compare_with(runn_hash)
|
195
|
+
superset_hash = Configuration.new(superset_str)
|
196
|
+
|
197
|
+
min_config_hash =
|
198
|
+
Configuration.build_min_config_hash(superset_hash.configuration,
|
199
|
+
agent_hash.configuration)
|
200
|
+
min_config_str = Configuration.config_hash_to_str(min_config_hash)
|
201
|
+
|
202
|
+
assert_equal(min_config_str.include?(min_expected), true,
|
203
|
+
"Error:\nExpected:\n#{min_expected}\n" \
|
204
|
+
"\nFound:\n#{min_config_str}")
|
205
|
+
end
|
206
|
+
end
|