cisco_node_utils_mgx 2.1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +96 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +676 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +10 -0
- data/LICENSE +201 -0
- data/README.md +246 -0
- data/Rakefile +44 -0
- data/SUPPORT.md +3 -0
- data/bin/.rubocop.yml +18 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +89 -0
- data/bin/git/hooks/hook_lib +115 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +25 -0
- data/bin/git/hooks/pre-commit/validate-diffs +45 -0
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +123 -0
- data/bin/show_running_yang.rb +233 -0
- data/cisco_node_utils.gemspec +41 -0
- data/docs/README-develop-best-practices.md +521 -0
- data/docs/README-develop-node-utils-APIs.md +570 -0
- data/docs/README-maintainers.md +77 -0
- data/docs/README-test-execution.md +57 -0
- data/docs/README-utilities.md +14 -0
- data/docs/agent_files.png +0 -0
- data/docs/cisco_node_utils.yaml.example +36 -0
- data/docs/template-router.rb +123 -0
- data/docs/template-test_router.rb +104 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +95 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +138 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +156 -0
- data/lib/cisco_node_utils/ace.rb +467 -0
- data/lib/cisco_node_utils/acl.rb +101 -0
- data/lib/cisco_node_utils/banner.rb +63 -0
- data/lib/cisco_node_utils/bfd_global.rb +305 -0
- data/lib/cisco_node_utils/bgp.rb +988 -0
- data/lib/cisco_node_utils/bgp_af.rb +545 -0
- data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +527 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +780 -0
- data/lib/cisco_node_utils/bridge_domain.rb +178 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +444 -0
- data/lib/cisco_node_utils/client/client.rb +238 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +395 -0
- data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
- data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
- data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
- data/lib/cisco_node_utils/client/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +368 -0
- data/lib/cisco_node_utils/client/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/utils.rb +180 -0
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +590 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/banner.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +383 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +223 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +174 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +236 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +128 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multicast.yaml +12 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multisite.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_stormcontrol.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +183 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +126 -0
- data/lib/cisco_node_utils/cmd_ref/hostname.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/hsrp_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +781 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/interface_evpn_multisite.yaml +17 -0
- data/lib/cisco_node_utils/cmd_ref/interface_hsrp_group.yaml +120 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +112 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +87 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/ip_multicast.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
- data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +24 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +27 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/object_group.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +100 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +19 -0
- data/lib/cisco_node_utils/cmd_ref/route_map.yaml +601 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +84 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +81 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +57 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +235 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_facility.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +63 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/upgrade.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +52 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +106 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +233 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +139 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +114 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +68 -0
- data/lib/cisco_node_utils/command_reference.rb +724 -0
- data/lib/cisco_node_utils/configparser_lib.rb +195 -0
- data/lib/cisco_node_utils/constants.rb +40 -0
- data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
- data/lib/cisco_node_utils/dns_domain.rb +93 -0
- data/lib/cisco_node_utils/domain_name.rb +82 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +110 -0
- data/lib/cisco_node_utils/evpn_multicast.rb +66 -0
- data/lib/cisco_node_utils/evpn_multisite.rb +96 -0
- data/lib/cisco_node_utils/evpn_stormcontrol.rb +84 -0
- data/lib/cisco_node_utils/evpn_vni.rb +159 -0
- data/lib/cisco_node_utils/exceptions.rb +140 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +405 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +137 -0
- data/lib/cisco_node_utils/feature.rb +377 -0
- data/lib/cisco_node_utils/hostname.rb +62 -0
- data/lib/cisco_node_utils/hsrp_global.rb +97 -0
- data/lib/cisco_node_utils/interface.rb +2128 -0
- data/lib/cisco_node_utils/interface_channel_group.rb +142 -0
- data/lib/cisco_node_utils/interface_evpn_multisite.rb +72 -0
- data/lib/cisco_node_utils/interface_hsrp_group.rb +557 -0
- data/lib/cisco_node_utils/interface_ospf.rb +378 -0
- data/lib/cisco_node_utils/interface_portchannel.rb +180 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/ip_multicast.rb +90 -0
- data/lib/cisco_node_utils/itd_device_group.rb +228 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +511 -0
- data/lib/cisco_node_utils/logger.rb +78 -0
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +443 -0
- data/lib/cisco_node_utils/node_util.rb +111 -0
- data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
- data/lib/cisco_node_utils/ntp_config.rb +83 -0
- data/lib/cisco_node_utils/ntp_server.rb +86 -0
- data/lib/cisco_node_utils/object_group.rb +75 -0
- data/lib/cisco_node_utils/object_group_entry.rb +143 -0
- data/lib/cisco_node_utils/overlay_global.rb +142 -0
- data/lib/cisco_node_utils/pim.rb +131 -0
- data/lib/cisco_node_utils/pim_group_list.rb +109 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +103 -0
- data/lib/cisco_node_utils/platform.rb +217 -0
- data/lib/cisco_node_utils/portchannel_global.rb +347 -0
- data/lib/cisco_node_utils/radius_global.rb +165 -0
- data/lib/cisco_node_utils/radius_server.rb +421 -0
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/route_map.rb +2540 -0
- data/lib/cisco_node_utils/router_ospf.rb +77 -0
- data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
- data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
- data/lib/cisco_node_utils/router_ospf_vrf.rb +342 -0
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +176 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +109 -0
- data/lib/cisco_node_utils/snmpgroup.rb +54 -0
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +132 -0
- data/lib/cisco_node_utils/snmpuser.rb +403 -0
- data/lib/cisco_node_utils/span_session.rb +149 -0
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_facility.rb +64 -0
- data/lib/cisco_node_utils/syslog_server.rb +146 -0
- data/lib/cisco_node_utils/syslog_settings.rb +174 -0
- data/lib/cisco_node_utils/tacacs_global.rb +137 -0
- data/lib/cisco_node_utils/tacacs_server.rb +173 -0
- data/lib/cisco_node_utils/tacacs_server_group.rb +149 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +216 -0
- data/lib/cisco_node_utils/upgrade.rb +122 -0
- data/lib/cisco_node_utils/vdc.rb +118 -0
- data/lib/cisco_node_utils/version.rb +21 -0
- data/lib/cisco_node_utils/vlan.rb +301 -0
- data/lib/cisco_node_utils/vpc.rb +466 -0
- data/lib/cisco_node_utils/vrf.rb +192 -0
- data/lib/cisco_node_utils/vrf_af.rb +327 -0
- data/lib/cisco_node_utils/vtp.rb +125 -0
- data/lib/cisco_node_utils/vxlan_vtep.rb +286 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +331 -0
- data/lib/cisco_node_utils/yang.rb +160 -0
- data/lib/cisco_node_utils/yum.rb +213 -0
- data/lib/cisco_node_utils.rb +21 -0
- data/lib/minitest/environment_plugin.rb +31 -0
- data/lib/minitest/log_level_plugin.rb +41 -0
- data/spec/client_spec.rb +7 -0
- data/spec/environment_spec.rb +384 -0
- data/spec/grpc_client_spec.rb +23 -0
- data/spec/isolate/all_clients_spec.rb +9 -0
- data/spec/isolate/grpc_only_spec.rb +16 -0
- data/spec/isolate/no_clients_spec.rb +26 -0
- data/spec/isolate/nxapi_only_spec.rb +16 -0
- data/spec/nxapi_client_spec.rb +42 -0
- data/spec/schema.yaml +82 -0
- data/spec/shared_examples_for_clients.rb +14 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/whitespace_spec.rb +10 -0
- data/spec/yaml_spec.rb +42 -0
- data/tests/.rubocop.yml +18 -0
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +243 -0
- data/tests/ciscotest.rb +577 -0
- data/tests/cmd_config.yaml +75 -0
- data/tests/cmd_config_invalid.yaml +16 -0
- data/tests/n9000_sample-1.0.0-7.0.3.x86_64.rpm +0 -0
- data/tests/noop.rb +7 -0
- data/tests/platform_info.rb +63 -0
- data/tests/tacacs_server.yaml.example +6 -0
- data/tests/test_aaa_authentication_login.rb +243 -0
- data/tests/test_aaa_authentication_login_service.rb +761 -0
- data/tests/test_aaa_authorization_service.rb +874 -0
- data/tests/test_ace.rb +304 -0
- data/tests/test_acl.rb +185 -0
- data/tests/test_banner.rb +85 -0
- data/tests/test_bfd_global.rb +272 -0
- data/tests/test_bgp_af.rb +875 -0
- data/tests/test_bgp_af_aa.rb +108 -0
- data/tests/test_bgp_neighbor.rb +596 -0
- data/tests/test_bgp_neighbor_af.rb +781 -0
- data/tests/test_bridge_domain.rb +198 -0
- data/tests/test_bridge_domain_vni.rb +109 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_cmn_utils.rb +76 -0
- data/tests/test_command_config.rb +206 -0
- data/tests/test_command_reference.rb +669 -0
- data/tests/test_dhcp_relay_global.rb +286 -0
- data/tests/test_dns_domain.rb +123 -0
- data/tests/test_domain_name.rb +96 -0
- data/tests/test_encapsulation.rb +75 -0
- data/tests/test_evpn_multicast.rb +65 -0
- data/tests/test_evpn_multisite.rb +70 -0
- data/tests/test_evpn_stormcontrol.rb +56 -0
- data/tests/test_evpn_vni.rb +131 -0
- data/tests/test_fabricpath_global.rb +246 -0
- data/tests/test_fabricpath_topology.rb +77 -0
- data/tests/test_feature.rb +272 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_hostname.rb +64 -0
- data/tests/test_hsrp_global.rb +79 -0
- data/tests/test_interface.rb +1958 -0
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +131 -0
- data/tests/test_interface_evpn_multisite.rb +94 -0
- data/tests/test_interface_hsrp.rb +134 -0
- data/tests/test_interface_hsrp_group.rb +570 -0
- data/tests/test_interface_ospf.rb +820 -0
- data/tests/test_interface_portchannel.rb +135 -0
- data/tests/test_interface_private_vlan.rb +365 -0
- data/tests/test_interface_service_vni.rb +203 -0
- data/tests/test_interface_svi.rb +210 -0
- data/tests/test_interface_switchport.rb +468 -0
- data/tests/test_ip_multicast.rb +80 -0
- data/tests/test_itd_device_group.rb +145 -0
- data/tests/test_itd_device_group_node.rb +199 -0
- data/tests/test_itd_service.rb +314 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +94 -0
- data/tests/test_node.rb +50 -0
- data/tests/test_node_ext.rb +406 -0
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_auth_key.rb +77 -0
- data/tests/test_ntp_config.rb +100 -0
- data/tests/test_ntp_server.rb +146 -0
- data/tests/test_nxapi.rb +236 -0
- data/tests/test_object_group.rb +122 -0
- data/tests/test_overlay_global.rb +108 -0
- data/tests/test_pim.rb +203 -0
- data/tests/test_pim_group_list.rb +147 -0
- data/tests/test_pim_rp_address.rb +155 -0
- data/tests/test_platform.rb +254 -0
- data/tests/test_portchannel_global.rb +322 -0
- data/tests/test_radius_global.rb +108 -0
- data/tests/test_radius_server.rb +377 -0
- data/tests/test_radius_server_group.rb +151 -0
- data/tests/test_route_map.rb +1479 -0
- data/tests/test_router_bgp.rb +1325 -0
- data/tests/test_router_ospf.rb +56 -0
- data/tests/test_router_ospf_area.rb +433 -0
- data/tests/test_router_ospf_area_vlink.rb +298 -0
- data/tests/test_router_ospf_vrf.rb +690 -0
- data/tests/test_snmp_notification_receiver.rb +169 -0
- data/tests/test_snmpcommunity.rb +422 -0
- data/tests/test_snmpgroup.rb +71 -0
- data/tests/test_snmpnotification.rb +91 -0
- data/tests/test_snmpserver.rb +251 -0
- data/tests/test_snmpuser.rb +666 -0
- data/tests/test_span_session.rb +155 -0
- data/tests/test_stp_global.rb +575 -0
- data/tests/test_syslog_facility.rb +80 -0
- data/tests/test_syslog_server.rb +119 -0
- data/tests/test_syslog_settings.rb +123 -0
- data/tests/test_tacacs_global.rb +109 -0
- data/tests/test_tacacs_server.rb +436 -0
- data/tests/test_tacacs_server_group.rb +434 -0
- data/tests/test_tacacs_server_host.rb +427 -0
- data/tests/test_upgrade.rb +105 -0
- data/tests/test_vdc.rb +64 -0
- data/tests/test_vlan.rb +386 -0
- data/tests/test_vlan_private.rb +656 -0
- data/tests/test_vpc.rb +548 -0
- data/tests/test_vrf.rb +248 -0
- data/tests/test_vrf_af.rb +288 -0
- data/tests/test_vtp.rb +278 -0
- data/tests/test_vxlan_vtep.rb +327 -0
- data/tests/test_vxlan_vtep_vni.rb +326 -0
- data/tests/test_yang.rb +369 -0
- data/tests/test_yum.rb +109 -0
- data/tests/upgrade_info.yaml.example +3 -0
- data/tests/yum_package.yaml +94 -0
- metadata +534 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Minitest for SnmpNotificationReceiver class
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
require_relative 'ciscotest'
|
|
19
|
+
require_relative '../lib/cisco_node_utils/snmp_notification_receiver'
|
|
20
|
+
|
|
21
|
+
# TestSnmpNotificationReceiver - Minitest for SnmpNotificationReceiver
|
|
22
|
+
# node utility.
|
|
23
|
+
class TestSnmpNotifRcvr < CiscoTestCase
|
|
24
|
+
@skip_unless_supported = 'snmp_notification_receiver'
|
|
25
|
+
|
|
26
|
+
def setup
|
|
27
|
+
# setup runs at the beginning of each test
|
|
28
|
+
super
|
|
29
|
+
no_snmpnotificationreceiver
|
|
30
|
+
config('vrf context red') if platform == :nexus
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def teardown
|
|
34
|
+
# teardown runs at the end of each test
|
|
35
|
+
no_snmpnotificationreceiver
|
|
36
|
+
config('no vrf context red') if platform == :nexus
|
|
37
|
+
super
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def no_snmpnotificationreceiver
|
|
41
|
+
# Turn the feature off for a clean test.
|
|
42
|
+
config('no snmp-server host 4.5.6.7 informs version 3 priv ab udp-port 45',
|
|
43
|
+
'no snmp-server host 2004::7 traps version 3 auth cd udp-port 46')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# TESTS
|
|
47
|
+
|
|
48
|
+
def test_create_destroy_single
|
|
49
|
+
id = '4.5.6.7'
|
|
50
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
51
|
+
|
|
52
|
+
receiver = \
|
|
53
|
+
Cisco::SnmpNotificationReceiver.new(id,
|
|
54
|
+
instantiate: true,
|
|
55
|
+
type: 'informs',
|
|
56
|
+
version: '3',
|
|
57
|
+
security: 'priv',
|
|
58
|
+
username: 'ab',
|
|
59
|
+
port: '45',
|
|
60
|
+
vrf: 'red',
|
|
61
|
+
source_interface: interfaces[0].downcase)
|
|
62
|
+
|
|
63
|
+
assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
64
|
+
assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
|
|
65
|
+
|
|
66
|
+
assert_equal(interfaces[0].downcase,
|
|
67
|
+
Cisco::SnmpNotificationReceiver.receivers[id].source_interface)
|
|
68
|
+
assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
|
|
69
|
+
assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
|
|
70
|
+
assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
|
|
71
|
+
assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id].version)
|
|
72
|
+
assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id].vrf)
|
|
73
|
+
assert_equal('priv', Cisco::SnmpNotificationReceiver.receivers[id].security)
|
|
74
|
+
|
|
75
|
+
receiver.destroy
|
|
76
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_create_destroy_single_ipv6
|
|
80
|
+
id = '2004::7'
|
|
81
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
82
|
+
|
|
83
|
+
receiver = \
|
|
84
|
+
Cisco::SnmpNotificationReceiver.new(id,
|
|
85
|
+
instantiate: true,
|
|
86
|
+
type: 'informs',
|
|
87
|
+
version: '3',
|
|
88
|
+
security: 'priv',
|
|
89
|
+
username: 'ab',
|
|
90
|
+
port: '45',
|
|
91
|
+
vrf: 'red',
|
|
92
|
+
source_interface: interfaces[0].downcase)
|
|
93
|
+
|
|
94
|
+
assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
95
|
+
assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
|
|
96
|
+
|
|
97
|
+
assert_equal(interfaces[0].downcase,
|
|
98
|
+
Cisco::SnmpNotificationReceiver.receivers[id].source_interface)
|
|
99
|
+
assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
|
|
100
|
+
assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
|
|
101
|
+
assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
|
|
102
|
+
assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id].version)
|
|
103
|
+
assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id].vrf)
|
|
104
|
+
assert_equal('priv', Cisco::SnmpNotificationReceiver.receivers[id].security)
|
|
105
|
+
|
|
106
|
+
receiver.destroy
|
|
107
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def test_create_destroy_multiple
|
|
111
|
+
id = '4.5.6.7'
|
|
112
|
+
id2 = '2004::7'
|
|
113
|
+
|
|
114
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
115
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id2)
|
|
116
|
+
|
|
117
|
+
receiver = \
|
|
118
|
+
Cisco::SnmpNotificationReceiver.new(id,
|
|
119
|
+
instantiate: true,
|
|
120
|
+
type: 'informs',
|
|
121
|
+
version: '3',
|
|
122
|
+
security: 'priv',
|
|
123
|
+
username: 'ab',
|
|
124
|
+
port: '45',
|
|
125
|
+
vrf: 'red',
|
|
126
|
+
source_interface: interfaces[0].downcase)
|
|
127
|
+
|
|
128
|
+
receiver2 = \
|
|
129
|
+
Cisco::SnmpNotificationReceiver.new(id2,
|
|
130
|
+
instantiate: true,
|
|
131
|
+
type: 'traps',
|
|
132
|
+
version: '3',
|
|
133
|
+
security: 'auth',
|
|
134
|
+
username: 'cd',
|
|
135
|
+
port: '46',
|
|
136
|
+
vrf: 'red',
|
|
137
|
+
source_interface: interfaces[1].downcase)
|
|
138
|
+
|
|
139
|
+
assert_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
140
|
+
assert_equal(receiver, Cisco::SnmpNotificationReceiver.receivers[id])
|
|
141
|
+
|
|
142
|
+
assert_equal(interfaces[0].downcase,
|
|
143
|
+
Cisco::SnmpNotificationReceiver.receivers[id].source_interface) if platform == :nexus
|
|
144
|
+
assert_equal('45', Cisco::SnmpNotificationReceiver.receivers[id].port)
|
|
145
|
+
assert_equal('informs', Cisco::SnmpNotificationReceiver.receivers[id].type)
|
|
146
|
+
assert_equal('ab', Cisco::SnmpNotificationReceiver.receivers[id].username)
|
|
147
|
+
assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id].version)
|
|
148
|
+
assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id].vrf)
|
|
149
|
+
assert_equal('priv', Cisco::SnmpNotificationReceiver.receivers[id].security)
|
|
150
|
+
|
|
151
|
+
assert_includes(Cisco::SnmpNotificationReceiver.receivers, id2)
|
|
152
|
+
assert_equal(receiver2, Cisco::SnmpNotificationReceiver.receivers[id2])
|
|
153
|
+
|
|
154
|
+
assert_equal(interfaces[1].downcase,
|
|
155
|
+
Cisco::SnmpNotificationReceiver.receivers[id2].source_interface)
|
|
156
|
+
assert_equal('46', Cisco::SnmpNotificationReceiver.receivers[id2].port)
|
|
157
|
+
assert_equal('traps', Cisco::SnmpNotificationReceiver.receivers[id2].type)
|
|
158
|
+
assert_equal('cd', Cisco::SnmpNotificationReceiver.receivers[id2].username)
|
|
159
|
+
assert_equal('3', Cisco::SnmpNotificationReceiver.receivers[id2].version)
|
|
160
|
+
assert_equal('red', Cisco::SnmpNotificationReceiver.receivers[id2].vrf)
|
|
161
|
+
assert_equal('auth',
|
|
162
|
+
Cisco::SnmpNotificationReceiver.receivers[id2].security)
|
|
163
|
+
|
|
164
|
+
receiver.destroy
|
|
165
|
+
receiver2.destroy
|
|
166
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id)
|
|
167
|
+
refute_includes(Cisco::SnmpNotificationReceiver.receivers, id2)
|
|
168
|
+
end
|
|
169
|
+
end
|
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
# Copyright (c) 2013-2016 Cisco and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/snmpcommunity'
|
|
17
|
+
|
|
18
|
+
def cleanup_snmp_communities(snmpcommunities)
|
|
19
|
+
snmpcommunities.each_value(&:destroy)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def cleanup_snmpcommunity(community)
|
|
23
|
+
community.destroy
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# TestSnmpCommunity - Minitest for SnmpCommunity node utility
|
|
27
|
+
class TestSnmpCommunity < CiscoTestCase
|
|
28
|
+
@skip_unless_supported = 'snmp_community'
|
|
29
|
+
|
|
30
|
+
SNMP_COMMUNITY_NAME_STR = 128
|
|
31
|
+
SNMP_GROUP_NAME_STR = 128
|
|
32
|
+
DEFAULT_SNMP_COMMUNITY_GROUP = 'network-operator'
|
|
33
|
+
DEFAULT_SNMP_COMMUNITY_ACL = ''
|
|
34
|
+
|
|
35
|
+
def setup
|
|
36
|
+
super
|
|
37
|
+
if platform != :ios_xr
|
|
38
|
+
@default_show_command = 'show run snmp all | no-more'
|
|
39
|
+
else
|
|
40
|
+
@default_show_command = 'show running-config snmp'
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_collection_empty
|
|
45
|
+
# This test requires all the snmp communities removed from device
|
|
46
|
+
original_list = SnmpCommunity.communities
|
|
47
|
+
cleanup_snmp_communities(original_list)
|
|
48
|
+
|
|
49
|
+
snmpcommunities = SnmpCommunity.communities
|
|
50
|
+
assert_equal(true, snmpcommunities.empty?,
|
|
51
|
+
'SnmpCommunity collection is not empty')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_collection_not_empty
|
|
55
|
+
snmpcommunities = SnmpCommunity.communities
|
|
56
|
+
cleanup_snmp_communities(snmpcommunities)
|
|
57
|
+
|
|
58
|
+
# This test require some snmp community exist in device
|
|
59
|
+
if platform != :ios_xr
|
|
60
|
+
config('snmp-server community com1 group network-admin',
|
|
61
|
+
'snmp-server community com2')
|
|
62
|
+
else
|
|
63
|
+
config('snmp-server community com1',
|
|
64
|
+
'snmp-server community com2')
|
|
65
|
+
end
|
|
66
|
+
snmpcommunities = SnmpCommunity.communities
|
|
67
|
+
|
|
68
|
+
assert_equal(false, snmpcommunities.empty?,
|
|
69
|
+
'SnmpCommunity collection is empty')
|
|
70
|
+
cleanup_snmp_communities(snmpcommunities)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_collection_valid
|
|
74
|
+
# This test require some snmp community exist in device
|
|
75
|
+
if platform != :ios_xr
|
|
76
|
+
config('snmp-server community com12 group network-operator',
|
|
77
|
+
'snmp-server community com22 group network-admin')
|
|
78
|
+
else
|
|
79
|
+
config('snmp-server community com12',
|
|
80
|
+
'snmp-server community com22')
|
|
81
|
+
end
|
|
82
|
+
# get collection
|
|
83
|
+
|
|
84
|
+
snmpcommunities = SnmpCommunity.communities
|
|
85
|
+
if platform != :ios_xr
|
|
86
|
+
s = @device.cmd('show run snmp all | no-more')
|
|
87
|
+
else
|
|
88
|
+
s = @device.cmd('show running-config snmp')
|
|
89
|
+
end
|
|
90
|
+
cmd = 'snmp-server community'
|
|
91
|
+
snmpcommunities.each do |name, _snmpcommunity|
|
|
92
|
+
line = /#{cmd}\s#{name}\s.*/.match(s)
|
|
93
|
+
# puts "line: #{line}"
|
|
94
|
+
assert_equal(false, line.nil?)
|
|
95
|
+
end
|
|
96
|
+
cleanup_snmp_communities(snmpcommunities)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def test_create_name_nil
|
|
100
|
+
assert_raises(TypeError) do
|
|
101
|
+
SnmpCommunity.new(nil, 'network-operator')
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_create_group_nil
|
|
106
|
+
assert_raises(TypeError) do
|
|
107
|
+
SnmpCommunity.new('test', nil)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def test_create_name_zero_length
|
|
112
|
+
assert_raises(Cisco::CliError) do
|
|
113
|
+
SnmpCommunity.new('', 'network-operator')
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def test_create_group_zero_length
|
|
118
|
+
assert_raises(Cisco::CliError) do
|
|
119
|
+
SnmpCommunity.new('test', '')
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def test_create_name_too_long
|
|
124
|
+
name = 'co' + 'c' * SNMP_COMMUNITY_NAME_STR
|
|
125
|
+
assert_raises(Cisco::CliError) do
|
|
126
|
+
if platform != :ios_xr
|
|
127
|
+
SnmpCommunity.new(name, 'network-operator')
|
|
128
|
+
else
|
|
129
|
+
SnmpCommunity.new(name, '')
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def test_create_group_too_long
|
|
135
|
+
group = 'gr' + 'g' * SNMP_GROUP_NAME_STR
|
|
136
|
+
assert_raises(Cisco::CliError) do
|
|
137
|
+
SnmpCommunity.new('test', group)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def test_create_group_invalid
|
|
142
|
+
name = 'ciscotest'
|
|
143
|
+
group = 'network-operator-invalid'
|
|
144
|
+
skip if platform == :ios_xr
|
|
145
|
+
assert_raises(Cisco::CliError) do
|
|
146
|
+
SnmpCommunity.new(name, group)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def test_create_valid
|
|
151
|
+
name = 'cisco'
|
|
152
|
+
group = 'network-operator'
|
|
153
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
154
|
+
if platform != :ios_xr
|
|
155
|
+
assert_show_match(
|
|
156
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
157
|
+
else
|
|
158
|
+
assert_show_match(
|
|
159
|
+
pattern: /snmp-server community\s#{name}/)
|
|
160
|
+
assert_show_match(
|
|
161
|
+
pattern: /snmp-server group\s#{group}/)
|
|
162
|
+
assert_show_match(
|
|
163
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
164
|
+
end
|
|
165
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def test_name_alpha
|
|
169
|
+
name = 'cisco128lab'
|
|
170
|
+
group = 'network-operator'
|
|
171
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
172
|
+
if platform != :ios_xr
|
|
173
|
+
assert_show_match(
|
|
174
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
175
|
+
else
|
|
176
|
+
assert_show_match(
|
|
177
|
+
pattern: /snmp-server community\s#{name}/)
|
|
178
|
+
assert_show_match(
|
|
179
|
+
pattern: /snmp-server group\s#{group}/)
|
|
180
|
+
assert_show_match(
|
|
181
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
182
|
+
end
|
|
183
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def test_get_group
|
|
187
|
+
name = 'ciscogetgrp'
|
|
188
|
+
group = 'network-operator'
|
|
189
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
190
|
+
assert_equal(snmpcommunity.group, group)
|
|
191
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def test_get_group_complex_name
|
|
195
|
+
skip("Test not supported on #{product_tag} due to CSCva63814") if product_tag[/n5|6|7k/]
|
|
196
|
+
names = ['C0mplex()Community!', 'C#', 'C$', 'C%', 'C^', 'C&', 'C*',
|
|
197
|
+
'C-', 'C=', 'C<', 'C,', 'C.', 'C/', 'C|', 'C{}[]']
|
|
198
|
+
group = 'network-admin'
|
|
199
|
+
names.each do |name|
|
|
200
|
+
sc = SnmpCommunity.new(name, group)
|
|
201
|
+
assert_equal(group, sc.group)
|
|
202
|
+
cleanup_snmpcommunity(sc)
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def test_group_set_zero_length
|
|
207
|
+
name = 'ciscogroupsetcom'
|
|
208
|
+
group = 'network-operator'
|
|
209
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
210
|
+
assert_raises(Cisco::CliError) do
|
|
211
|
+
snmpcommunity.group = ''
|
|
212
|
+
end
|
|
213
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def test_group_set_too_long
|
|
217
|
+
skip if platform == :ios_xr
|
|
218
|
+
name = 'ciscogroupsetcom'
|
|
219
|
+
group = 'network-operator'
|
|
220
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
221
|
+
assert_raises(Cisco::CliError) do
|
|
222
|
+
snmpcommunity.group = 'group123456789c123456789c123456789c12345'
|
|
223
|
+
end
|
|
224
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def test_group_set_invalid
|
|
228
|
+
skip if platform == :ios_xr
|
|
229
|
+
name = 'ciscogroupsetcom'
|
|
230
|
+
group = 'network-operator'
|
|
231
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
232
|
+
assert_raises(Cisco::CliError) do
|
|
233
|
+
snmpcommunity.group = 'testgroup'
|
|
234
|
+
end
|
|
235
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
def test_group_set_valid
|
|
239
|
+
name = 'ciscogroupsetcom'
|
|
240
|
+
group = 'network-operator'
|
|
241
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
242
|
+
# new group
|
|
243
|
+
group = 'network-admin'
|
|
244
|
+
snmpcommunity.group = group
|
|
245
|
+
if platform != :ios_xr
|
|
246
|
+
assert_show_match(
|
|
247
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
248
|
+
else
|
|
249
|
+
assert_show_match(
|
|
250
|
+
pattern: /snmp-server community\s#{name}/)
|
|
251
|
+
assert_show_match(
|
|
252
|
+
pattern: /snmp-server group\s#{group}/)
|
|
253
|
+
assert_show_match(
|
|
254
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def test_group_set_default
|
|
261
|
+
name = 'ciscogroupsetcom'
|
|
262
|
+
group = 'network-operator'
|
|
263
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
264
|
+
# new group identity
|
|
265
|
+
group = 'vdc-admin'
|
|
266
|
+
snmpcommunity.group = group
|
|
267
|
+
if platform != :ios_xr
|
|
268
|
+
assert_show_match(
|
|
269
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
270
|
+
else
|
|
271
|
+
assert_show_match(
|
|
272
|
+
pattern: /snmp-server community\s#{name}/)
|
|
273
|
+
assert_show_match(
|
|
274
|
+
pattern: /snmp-server group\s#{group}/)
|
|
275
|
+
assert_show_match(
|
|
276
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Restore group default
|
|
280
|
+
group = SnmpCommunity.default_group
|
|
281
|
+
snmpcommunity.group = group
|
|
282
|
+
if platform != :ios_xr
|
|
283
|
+
assert_show_match(
|
|
284
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
285
|
+
else
|
|
286
|
+
assert_show_match(
|
|
287
|
+
pattern: /snmp-server community\s#{name}/)
|
|
288
|
+
assert_show_match(
|
|
289
|
+
pattern: /snmp-server group\s#{group}/)
|
|
290
|
+
assert_show_match(
|
|
291
|
+
pattern: /snmp-server community-map\s#{name}\starget-list\s#{group}/)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def test_destroy_valid
|
|
298
|
+
name = 'ciscotest'
|
|
299
|
+
group = 'network-operator'
|
|
300
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
301
|
+
snmpcommunity.destroy
|
|
302
|
+
if platform != :ios_xr
|
|
303
|
+
refute_show_match(
|
|
304
|
+
pattern: /snmp-server community\s#{name}\sgroup\s#{group}/)
|
|
305
|
+
else
|
|
306
|
+
refute_show_match(
|
|
307
|
+
pattern: /snmp-server community\s#{name}/)
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def test_acl_get_no_acl
|
|
312
|
+
name = 'cisconoaclget'
|
|
313
|
+
group = 'network-operator'
|
|
314
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
315
|
+
assert_equal(snmpcommunity.acl, '')
|
|
316
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def test_acl_get
|
|
320
|
+
name = 'ciscoaclget'
|
|
321
|
+
group = 'network-operator'
|
|
322
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
323
|
+
snmpcommunity.acl = 'ciscoacl'
|
|
324
|
+
if platform != :ios_xr
|
|
325
|
+
line = assert_show_match(
|
|
326
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s\S+/)
|
|
327
|
+
acl = line.to_s.gsub(/snmp-server community\s#{name}\suse-acl\s/, '').strip
|
|
328
|
+
assert_equal(snmpcommunity.acl, acl)
|
|
329
|
+
else
|
|
330
|
+
line = assert_show_match(
|
|
331
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s\S+/)
|
|
332
|
+
acl = line.to_s.gsub(/snmp-server community\s#{name}\sIPv4\s/, '').strip
|
|
333
|
+
assert_equal(snmpcommunity.acl, acl)
|
|
334
|
+
end
|
|
335
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
def test_acl_set_nil
|
|
339
|
+
name = 'cisco'
|
|
340
|
+
group = 'network-operator'
|
|
341
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
342
|
+
assert_raises(TypeError) do
|
|
343
|
+
snmpcommunity.acl = nil
|
|
344
|
+
end
|
|
345
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
def test_acl_set_valid
|
|
349
|
+
name = 'ciscoadmin'
|
|
350
|
+
group = 'network-admin'
|
|
351
|
+
acl = 'ciscoadminacl'
|
|
352
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
353
|
+
snmpcommunity.acl = acl
|
|
354
|
+
if platform != :ios_xr
|
|
355
|
+
assert_show_match(
|
|
356
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
357
|
+
else
|
|
358
|
+
assert_show_match(
|
|
359
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
360
|
+
end
|
|
361
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def test_acl_set_zero_length
|
|
365
|
+
name = 'ciscooper'
|
|
366
|
+
group = 'network-operator'
|
|
367
|
+
acl = 'ciscooperacl'
|
|
368
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
369
|
+
# puts "set acl #{acl}"
|
|
370
|
+
snmpcommunity.acl = acl
|
|
371
|
+
if platform != :ios_xr
|
|
372
|
+
assert_show_match(
|
|
373
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
374
|
+
else
|
|
375
|
+
assert_show_match(
|
|
376
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
377
|
+
end
|
|
378
|
+
# remove acl
|
|
379
|
+
snmpcommunity.acl = ''
|
|
380
|
+
if platform != :ios_xr
|
|
381
|
+
refute_show_match(
|
|
382
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
383
|
+
else
|
|
384
|
+
refute_show_match(
|
|
385
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
386
|
+
end
|
|
387
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def test_acl_set_default
|
|
391
|
+
name = 'cisco'
|
|
392
|
+
group = 'network-operator'
|
|
393
|
+
acl = 'cisco_test_acl'
|
|
394
|
+
snmpcommunity = SnmpCommunity.new(name, group)
|
|
395
|
+
snmpcommunity.acl = acl
|
|
396
|
+
if platform != :ios_xr
|
|
397
|
+
assert_show_match(
|
|
398
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
399
|
+
else
|
|
400
|
+
assert_show_match(
|
|
401
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# Check default_acl
|
|
405
|
+
assert_equal(DEFAULT_SNMP_COMMUNITY_ACL,
|
|
406
|
+
SnmpCommunity.default_acl,
|
|
407
|
+
'Error: Snmp Community, default ACL not correct value')
|
|
408
|
+
|
|
409
|
+
# Set acl to default
|
|
410
|
+
acl = SnmpCommunity.default_acl
|
|
411
|
+
snmpcommunity.acl = acl
|
|
412
|
+
if platform != :ios_xr
|
|
413
|
+
refute_show_match(
|
|
414
|
+
pattern: /snmp-server community\s#{name}\suse-acl\s#{acl}/)
|
|
415
|
+
else
|
|
416
|
+
refute_show_match(
|
|
417
|
+
pattern: /snmp-server community\s#{name}\sIPv4\s#{acl}/)
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
cleanup_snmpcommunity(snmpcommunity)
|
|
421
|
+
end
|
|
422
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Copyright (c) 2013-2016 Cisco and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
require_relative 'ciscotest'
|
|
16
|
+
require_relative '../lib/cisco_node_utils/snmpgroup'
|
|
17
|
+
|
|
18
|
+
# TestSnmpGroup - Minitest for SnmpGroup node utility.
|
|
19
|
+
class TestSnmpGroup < CiscoTestCase
|
|
20
|
+
@skip_unless_supported = 'snmp_group'
|
|
21
|
+
|
|
22
|
+
# NXOS snmp groups will not be empty
|
|
23
|
+
def test_collection_not_empty
|
|
24
|
+
snmpgroups = SnmpGroup.groups
|
|
25
|
+
refute_empty(snmpgroups)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def test_collection_valid
|
|
29
|
+
snmpgroups = SnmpGroup.groups
|
|
30
|
+
s = @device.cmd('show snmp group | include Role | no-more')
|
|
31
|
+
snmpgroups.each_value do |snmpgroup|
|
|
32
|
+
line = /Role:\s#{snmpgroup.name}/.match(s)
|
|
33
|
+
# puts "line: #{line}"
|
|
34
|
+
assert_equal(false, line.nil?)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_exists_with_name_empty
|
|
39
|
+
assert_raises(ArgumentError) do
|
|
40
|
+
SnmpGroup.exists?('')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_exists_with_name_invalid
|
|
45
|
+
name = 'group-dummy'
|
|
46
|
+
exist = SnmpGroup.exists?(name)
|
|
47
|
+
s = @device.cmd('show snmp group | in Role | no-more')
|
|
48
|
+
line = /Role:\s#{name}/.match(s)
|
|
49
|
+
assert_equal(exist, !line.nil?)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_exists_with_name_bad_type
|
|
53
|
+
assert_raises(TypeError) do
|
|
54
|
+
SnmpGroup.exists?(:not_a_string)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_exists_with_name_valid
|
|
59
|
+
name = 'network-admin'
|
|
60
|
+
exist = SnmpGroup.exists?(name)
|
|
61
|
+
s = @device.cmd('show snmp group | in Role | no-more')
|
|
62
|
+
line = /Role:\s#{name}/.match(s)
|
|
63
|
+
assert_equal(exist, !line.nil?)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_get_name
|
|
67
|
+
name = 'network-operator'
|
|
68
|
+
snmpgroup = SnmpGroup.new(name)
|
|
69
|
+
assert_equal(snmpgroup.name, name)
|
|
70
|
+
end
|
|
71
|
+
end
|