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
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
5
|
+
# files.
|
6
|
+
#
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
13
|
+
# it.
|
14
|
+
#
|
15
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
16
|
+
# users commonly want.
|
17
|
+
#
|
18
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
19
|
+
RSpec.configure do |config|
|
20
|
+
# rspec-expectations config goes here. You can use an alternate
|
21
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
22
|
+
# assertions if you prefer.
|
23
|
+
config.expect_with :rspec do |expectations|
|
24
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
25
|
+
# and `failure_message` of custom matchers include text for helper methods
|
26
|
+
# defined using `chain`, e.g.:
|
27
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
28
|
+
# # => "be bigger than 2 and smaller than 4"
|
29
|
+
# ...rather than:
|
30
|
+
# # => "be bigger than 2"
|
31
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
32
|
+
end
|
33
|
+
|
34
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
35
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
36
|
+
config.mock_with :rspec do |mocks|
|
37
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
38
|
+
# a real object. This is generally recommended, and will default to
|
39
|
+
# `true` in RSpec 4.
|
40
|
+
mocks.verify_partial_doubles = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# The settings below are suggested to provide a good initial experience
|
44
|
+
# with RSpec, but feel free to customize to your heart's content.
|
45
|
+
# rubocop:disable Style/BlockComments
|
46
|
+
=begin
|
47
|
+
# These two settings work together to allow you to limit a spec run
|
48
|
+
# to individual examples or groups you care about by tagging them with
|
49
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
50
|
+
# get run.
|
51
|
+
config.filter_run :focus
|
52
|
+
config.run_all_when_everything_filtered = true
|
53
|
+
# Allows RSpec to persist some state between runs in order to support
|
54
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
55
|
+
# you configure your source control system to ignore this file.
|
56
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
57
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
58
|
+
# recommended. For more details, see:
|
59
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
60
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
61
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
62
|
+
config.disable_monkey_patching!
|
63
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
64
|
+
# be too noisy due to issues in dependencies.
|
65
|
+
config.warnings = true
|
66
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
67
|
+
# file, and it's useful to allow more verbose output when running an
|
68
|
+
# individual spec file.
|
69
|
+
if config.files_to_run.one?
|
70
|
+
# Use the documentation formatter for detailed output,
|
71
|
+
# unless a formatter has already been configured
|
72
|
+
# (e.g. via a command-line flag).
|
73
|
+
config.default_formatter = 'doc'
|
74
|
+
end
|
75
|
+
# Print the 10 slowest examples and example groups at the
|
76
|
+
# end of the spec run, to help surface which specs are running
|
77
|
+
# particularly slow.
|
78
|
+
config.profile_examples = 10
|
79
|
+
# Run specs in random order to surface order dependencies. If you find an
|
80
|
+
# order dependency and want to debug it, you can fix the order by providing
|
81
|
+
# the seed, which is printed after each run.
|
82
|
+
# --seed 1234
|
83
|
+
config.order = :random
|
84
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
85
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
86
|
+
# test failures related to randomization by passing the same `--seed` value
|
87
|
+
# as the one that triggered the failure.
|
88
|
+
Kernel.srand config.seed
|
89
|
+
=end
|
90
|
+
# rubocop:enable Style:BlockComments
|
91
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require_relative 'spec_helper.rb'
|
2
|
+
|
3
|
+
context 'non-ruby files' do
|
4
|
+
# Whitespace in ruby files is managed by Rubocop.
|
5
|
+
# Ignore ems.proto as it's a generated file.
|
6
|
+
failures = `git grep -n -I '\s$' | grep -v .rb | grep -v ems.proto`
|
7
|
+
it 'should have no trailing whitespace' do
|
8
|
+
expect(failures).to be_empty, -> { failures }
|
9
|
+
end
|
10
|
+
end
|
data/spec/yaml_spec.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'spec_helper.rb'
|
2
|
+
require 'kwalify'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
files = Dir.glob(__dir__ + '/../lib/cisco_node_utils/cmd_ref/*.yaml')
|
6
|
+
|
7
|
+
def print_errors(errors)
|
8
|
+
str = "Schema validation errors:\n"
|
9
|
+
error_str_list = errors.map do |e|
|
10
|
+
"line #{e.linenum}, column #{e.column}: [#{e.path}] #{e.message}"
|
11
|
+
end
|
12
|
+
str + error_str_list.join("\n")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Use the MetaValidator to make sure the schema itself is sane
|
16
|
+
metavalidator = Kwalify::MetaValidator.instance
|
17
|
+
|
18
|
+
schema_file = File.join(__dir__, 'schema.yaml')
|
19
|
+
|
20
|
+
metaparser = Kwalify::Yaml::Parser.new(metavalidator)
|
21
|
+
context 'schema.yaml' do
|
22
|
+
it 'should have no schema metavalidation errors' do
|
23
|
+
metaparser.parse_file(schema_file)
|
24
|
+
errors = metaparser.errors()
|
25
|
+
expect(errors).to be_empty, -> { print_errors(errors) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Then use the Validator to make sure our files comply with the schema
|
30
|
+
schema = Kwalify::Yaml.load_file(schema_file)
|
31
|
+
validator = Kwalify::Validator.new(schema)
|
32
|
+
parser = Kwalify::Yaml::Parser.new(validator)
|
33
|
+
|
34
|
+
files.each do |file|
|
35
|
+
context file.split('/')[-1] do
|
36
|
+
it 'should have no schema validation errors' do
|
37
|
+
parser.parse_file(file)
|
38
|
+
errors = parser.errors()
|
39
|
+
expect(errors).to be_empty, -> { print_errors(errors) }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/tests/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
inherit_from: ../.rubocop.yml
|
2
|
+
|
3
|
+
# Code complexity metrics for the tests/ subdirectory
|
4
|
+
|
5
|
+
Metrics/AbcSize:
|
6
|
+
Max: 158 # ouch!
|
7
|
+
|
8
|
+
Metrics/CyclomaticComplexity:
|
9
|
+
Max: 15
|
10
|
+
|
11
|
+
Metrics/MethodLength:
|
12
|
+
Max: 100
|
13
|
+
|
14
|
+
Metrics/PerceivedComplexity:
|
15
|
+
Max: 17
|
16
|
+
|
17
|
+
Metrics/LineLength:
|
18
|
+
Max: 120
|
Binary file
|
data/tests/basetest.rb
ADDED
@@ -0,0 +1,243 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Basic unit test case class.
|
4
|
+
# December 2014, Glenn F. Matthews
|
5
|
+
#
|
6
|
+
# Copyright (c) 2014-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
|
+
# Minitest needs to have this path in order to discover our logging plugin
|
21
|
+
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
|
22
|
+
|
23
|
+
require 'simplecov'
|
24
|
+
SimpleCov.start do
|
25
|
+
# Don't calculate coverage of our test code itself!
|
26
|
+
add_filter '/tests/'
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'rubygems'
|
30
|
+
gem 'minitest', '~> 5.0'
|
31
|
+
require 'minitest/autorun'
|
32
|
+
require 'net/telnet'
|
33
|
+
require_relative '../lib/cisco_node_utils/client'
|
34
|
+
require_relative '../lib/cisco_node_utils/environment'
|
35
|
+
require_relative '../lib/cisco_node_utils/command_reference'
|
36
|
+
require_relative '../lib/cisco_node_utils/logger'
|
37
|
+
|
38
|
+
# rubocop:disable Style/ClassVars
|
39
|
+
# We *want* the address/username/password class variables to be shared
|
40
|
+
# with all child classes, so that we only need to initialize them once.
|
41
|
+
|
42
|
+
# TestCase - common base class for all minitest cases in this module.
|
43
|
+
# Most node utility tests should inherit from CiscoTestCase instead.
|
44
|
+
class TestCase < Minitest::Test
|
45
|
+
@@address = nil
|
46
|
+
@@username = nil
|
47
|
+
@@password = nil
|
48
|
+
|
49
|
+
def self.address
|
50
|
+
@@address ||= Cisco::Environment.environment[:host]
|
51
|
+
unless @@address
|
52
|
+
print 'Enter address or hostname of node under test: '
|
53
|
+
@@address = gets.chomp
|
54
|
+
end
|
55
|
+
@@address
|
56
|
+
end
|
57
|
+
|
58
|
+
def address
|
59
|
+
self.class.address
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.username
|
63
|
+
@@username ||= Cisco::Environment.environment[:username]
|
64
|
+
unless @@username
|
65
|
+
print 'Enter username for node under test: '
|
66
|
+
@@username = gets.chomp
|
67
|
+
end
|
68
|
+
@@username
|
69
|
+
end
|
70
|
+
|
71
|
+
def username
|
72
|
+
self.class.username
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.password
|
76
|
+
@@password ||= Cisco::Environment.environment[:password]
|
77
|
+
unless @@password
|
78
|
+
print 'Enter password for node under test: '
|
79
|
+
@@password = gets.chomp
|
80
|
+
end
|
81
|
+
@@password
|
82
|
+
end
|
83
|
+
|
84
|
+
def password
|
85
|
+
self.class.password
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.telnet_port
|
89
|
+
Cisco::Environment.environment[:telnet_port] || 23
|
90
|
+
end
|
91
|
+
|
92
|
+
def telnet_port
|
93
|
+
self.class.telnet_port
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.port
|
97
|
+
Cisco::Environment.environment[:port] || address.split(':')[1]
|
98
|
+
end
|
99
|
+
|
100
|
+
def port
|
101
|
+
self.class.port
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.transport
|
105
|
+
Cisco::Environment.environment[:transport] || 'http'
|
106
|
+
end
|
107
|
+
|
108
|
+
def transport
|
109
|
+
self.class.transport
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.verify_mode
|
113
|
+
Cisco::Environment.environment[:verify_mode] || 'none'
|
114
|
+
end
|
115
|
+
|
116
|
+
def verify_mode
|
117
|
+
self.class.verify_mode
|
118
|
+
end
|
119
|
+
|
120
|
+
def setup
|
121
|
+
# Hack - populate environment from user-entered values from basetest.rb
|
122
|
+
if Cisco::Environment.environments.empty?
|
123
|
+
class << Cisco::Environment
|
124
|
+
attr_writer :environments
|
125
|
+
end
|
126
|
+
Cisco::Environment.environments['default'] = {
|
127
|
+
host: address.split(':')[0],
|
128
|
+
port: port,
|
129
|
+
telnet_port: telnet_port,
|
130
|
+
transport: transport,
|
131
|
+
verify_mode: verify_mode,
|
132
|
+
username: username,
|
133
|
+
password: password,
|
134
|
+
}
|
135
|
+
end
|
136
|
+
@device = Net::Telnet.new('Host' => address.split(':')[0],
|
137
|
+
'Port' => telnet_port,
|
138
|
+
'Timeout' => 240,
|
139
|
+
# NX-OS has a space after '#', IOS XR does not
|
140
|
+
'Prompt' => /[$%#>] *\z/n,
|
141
|
+
)
|
142
|
+
begin
|
143
|
+
@device.login('Name' => username,
|
144
|
+
'Password' => password,
|
145
|
+
# NX-OS uses 'login:' while IOS XR uses 'Username:'
|
146
|
+
'LoginPrompt' => /(?:[Ll]ogin|[Uu]sername)[: ]*\z/n,
|
147
|
+
)
|
148
|
+
rescue Errno::ECONNRESET
|
149
|
+
@device.close
|
150
|
+
# TODO
|
151
|
+
puts 'Connection reset by peer? Try again'
|
152
|
+
sleep 1
|
153
|
+
@device = Net::Telnet.new('Host' => address.split(':')[0],
|
154
|
+
'Timeout' => 240,
|
155
|
+
# NX-OS has a space after '#', IOS XR does not
|
156
|
+
'Prompt' => /[$%#>] *\z/n,
|
157
|
+
)
|
158
|
+
@device.login('Name' => username,
|
159
|
+
'Password' => password,
|
160
|
+
# NX-OS uses 'login:' while IOS XR uses 'Username:'
|
161
|
+
'LoginPrompt' => /(?:[Ll]ogin|[Uu]sername)[: ]*\z/n,
|
162
|
+
)
|
163
|
+
end
|
164
|
+
@device.cmd('term len 0')
|
165
|
+
rescue Errno::ECONNREFUSED
|
166
|
+
puts 'Telnet login refused - please check that the IP address is correct'
|
167
|
+
puts " and that you have configured 'feature telnet' (NX-OS) or "
|
168
|
+
puts " 'telnet ipv4 server...' (IOS XR) on the UUT"
|
169
|
+
exit
|
170
|
+
end
|
171
|
+
|
172
|
+
def teardown
|
173
|
+
@device.close unless @device.nil?
|
174
|
+
@device = nil
|
175
|
+
end
|
176
|
+
|
177
|
+
# Execute the specified config commands and warn if the
|
178
|
+
# output matches the default "warning" regex.
|
179
|
+
def config(*args)
|
180
|
+
config_and_warn_on_match(/^invalid|^%/i, *args)
|
181
|
+
end
|
182
|
+
|
183
|
+
# Execute the specified config commands. Use this version
|
184
|
+
# of the config method if you expect possible config errors
|
185
|
+
# and do not wish to log them as a warning.
|
186
|
+
def config_no_warn(*args)
|
187
|
+
config_and_warn_on_match(nil, *args)
|
188
|
+
end
|
189
|
+
|
190
|
+
# Execute the specified config commands and warn if the
|
191
|
+
# ouput matches the specified regex. Specifying nil for
|
192
|
+
# warn_match means "do not warn".
|
193
|
+
def config_and_warn_on_match(warn_match, *args)
|
194
|
+
# Send the entire config as one string but be sure not to return until
|
195
|
+
# we are safely back out of config mode, i.e. prompt is
|
196
|
+
# 'switch#' not 'switch(config)#' or 'switch(config-if)#' etc.
|
197
|
+
result = @device.cmd(
|
198
|
+
'String' => "configure terminal\n" + args.join("\n") + "\nend",
|
199
|
+
# NX-OS has a space after '#', IOS XR does not
|
200
|
+
'Match' => /^[^()]+[$%#>] *\z/n)
|
201
|
+
|
202
|
+
if warn_match && warn_match.match(result)
|
203
|
+
Cisco::Logger.warn("Config result:\n#{result}")
|
204
|
+
else
|
205
|
+
Cisco::Logger.debug("Config result:\n#{result}")
|
206
|
+
end
|
207
|
+
result
|
208
|
+
rescue Net::ReadTimeout => e
|
209
|
+
raise "Timeout when configuring:\n#{args.join("\n")}\n\n#{e}"
|
210
|
+
end
|
211
|
+
|
212
|
+
def assert_show_match(pattern: nil, command: nil, msg: nil)
|
213
|
+
pattern ||= @default_output_pattern
|
214
|
+
refute_nil(pattern)
|
215
|
+
pattern = Cisco::Client.to_regexp(pattern)
|
216
|
+
command ||= @default_show_command
|
217
|
+
refute_nil(command)
|
218
|
+
|
219
|
+
output = @device.cmd(command)
|
220
|
+
msg = message(msg) do
|
221
|
+
"Expected #{mu_pp pattern} to match " \
|
222
|
+
"output of '#{mu_pp command}':\n#{output}"
|
223
|
+
end
|
224
|
+
assert pattern =~ output, msg
|
225
|
+
pattern.match(output)
|
226
|
+
end
|
227
|
+
|
228
|
+
def refute_show_match(pattern: nil, command: nil, msg: nil)
|
229
|
+
pattern ||= @default_output_pattern
|
230
|
+
refute_nil(pattern)
|
231
|
+
pattern = Cisco::Client.to_regexp(pattern)
|
232
|
+
command ||= @default_show_command
|
233
|
+
refute_nil(command)
|
234
|
+
|
235
|
+
output = @device.cmd(command)
|
236
|
+
msg = message(msg) do
|
237
|
+
"Expected #{mu_pp pattern} to NOT match " \
|
238
|
+
"output of '#{mu_pp command}':\n#{output}"
|
239
|
+
end
|
240
|
+
refute pattern =~ output, msg
|
241
|
+
end
|
242
|
+
end
|
243
|
+
# rubocop:enable Style/ClassVars
|