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,160 @@
|
|
1
|
+
# June 2016, Charles Burkett
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'json'
|
18
|
+
|
19
|
+
module Cisco
|
20
|
+
# class Cisco::Yang
|
21
|
+
# Utility class mainly containing methods to compare YANG configurations
|
22
|
+
# in order to determine if the running config is in-sync with the
|
23
|
+
# desired config.
|
24
|
+
class Yang
|
25
|
+
# Is the specified yang string empty?
|
26
|
+
def self.empty?(yang)
|
27
|
+
!yang || yang.empty?
|
28
|
+
end
|
29
|
+
|
30
|
+
# Given target and current YANG configurations, returns true if
|
31
|
+
# the configurations are in-sync, relative to a "merge_config" action
|
32
|
+
# @param should [String] the should configuration in YANG JASON format
|
33
|
+
# @param is [String] the is configuration in YANG JASON format
|
34
|
+
def self.insync_for_merge?(should, is)
|
35
|
+
should_hash = self.empty?(should) ? {} : JSON.parse(should)
|
36
|
+
is_hash = self.empty?(is) ? {} : JSON.parse(is)
|
37
|
+
|
38
|
+
!needs_something?(:merge, should_hash, is_hash)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Given a is and should YANG configuration, returns true if
|
42
|
+
# the configuration are in-sync, relative to a "replace_config" action
|
43
|
+
# @param should [String] the should configuration in YANG JASON format
|
44
|
+
# @param is [String] the is configuration in YANG JASON format
|
45
|
+
def self.insync_for_replace?(should, is)
|
46
|
+
should_hash = self.empty?(should) ? {} : JSON.parse(should)
|
47
|
+
is_hash = self.empty?(is) ? {} : JSON.parse(is)
|
48
|
+
|
49
|
+
!needs_something?(:replace, should_hash, is_hash)
|
50
|
+
end
|
51
|
+
|
52
|
+
# usage:
|
53
|
+
# needs_something?(op, should, run)
|
54
|
+
#
|
55
|
+
# op - symbol - If value is not :replace, it's assumed to be :merge.
|
56
|
+
# Indicates to the function whether to check for a
|
57
|
+
# possible merge vs. replace
|
58
|
+
#
|
59
|
+
# should - JSON - JSON tree representing target configuration
|
60
|
+
#
|
61
|
+
# is - JSON - JSON tree representing current configuration
|
62
|
+
#
|
63
|
+
#
|
64
|
+
# Needs merge will determine if should and is differ
|
65
|
+
# sufficiently to necessitate running the merge command.
|
66
|
+
#
|
67
|
+
# The logic here amounts to determining if should is a subtree
|
68
|
+
# of is, with a tiny bit of domain trickiness surrounding
|
69
|
+
# elements that are arrays that contain a single nil element
|
70
|
+
# that is required for "creating" certain configuration elements.
|
71
|
+
#
|
72
|
+
# There are ultimately 3 different types of elements in a json
|
73
|
+
# tree. Hashes, Arrays, and leaves. While hashes and array values
|
74
|
+
# are organized with an order, the logic here ignores the order.
|
75
|
+
# In fact, it specifically attempts to match assuming order
|
76
|
+
# doesn't matter. This is largely to allow users some freedom
|
77
|
+
# in specifying the target configuration. The gRPC interface
|
78
|
+
# doesn't seem to care about order. If that changes, then so
|
79
|
+
# should this code.
|
80
|
+
#
|
81
|
+
# Arrays and Hashes are compared by iterating over every element
|
82
|
+
# in should, and ensuring it is within is.
|
83
|
+
#
|
84
|
+
# Leaves are directly compared for equality, excepting the
|
85
|
+
# condition that the should leaf is in fact an array with one
|
86
|
+
# element that is nil.
|
87
|
+
#
|
88
|
+
# Needs replace will determine if should and is differ
|
89
|
+
# sufficiently to necessitate running the replace command.
|
90
|
+
#
|
91
|
+
# The logic is the same as merge, except when comparing
|
92
|
+
# hashes, if the is hash table has elements that are not
|
93
|
+
# in should, we ultimately indicate that replace is needed
|
94
|
+
def self.needs_something?(op, should, is)
|
95
|
+
!hash_equiv?(op, should, is)
|
96
|
+
end
|
97
|
+
|
98
|
+
def self.nil_array(elt)
|
99
|
+
elt.nil? || (elt.is_a?(Array) && elt.length == 1 && elt[0].nil?)
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.sub_elt(op, should, is)
|
103
|
+
if should.is_a?(Hash) && is.is_a?(Hash)
|
104
|
+
return self.hash_equiv?(op, should, is)
|
105
|
+
elsif should.is_a?(Array) && is.is_a?(Array)
|
106
|
+
return self.array_equiv?(op, should, is)
|
107
|
+
else
|
108
|
+
return !(should != is && !nil_array(should))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.array_equiv?(op, should, is)
|
113
|
+
n = should.length
|
114
|
+
loop = lambda do|i|
|
115
|
+
if i == n
|
116
|
+
if op == :replace
|
117
|
+
is.length == should.length
|
118
|
+
else
|
119
|
+
true
|
120
|
+
end
|
121
|
+
else
|
122
|
+
should_elt = should[i]
|
123
|
+
is_elt = is.find do |elt|
|
124
|
+
sub_elt(op, should_elt, elt)
|
125
|
+
end
|
126
|
+
if is_elt.nil? && !nil_array(should_elt)
|
127
|
+
should_elt.nil?
|
128
|
+
else
|
129
|
+
loop.call(i + 1)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
loop.call(0)
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.hash_equiv?(op, should, is)
|
137
|
+
keys = should.keys
|
138
|
+
n = keys.length
|
139
|
+
loop = lambda do|i|
|
140
|
+
if i == n
|
141
|
+
if op == :replace
|
142
|
+
is.keys.length == should.keys.length
|
143
|
+
else
|
144
|
+
true
|
145
|
+
end
|
146
|
+
else
|
147
|
+
k = keys[i]
|
148
|
+
is_v = is[k]
|
149
|
+
should_v = should[k]
|
150
|
+
if is_v.nil? && !nil_array(should_v)
|
151
|
+
false
|
152
|
+
else
|
153
|
+
sub_elt(op, should_v, is_v) && loop.call(i + 1)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
loop.call(0)
|
158
|
+
end
|
159
|
+
end # Yang
|
160
|
+
end # Cisco
|
@@ -0,0 +1,213 @@
|
|
1
|
+
#
|
2
|
+
# NXAPI implementation of Yum class
|
3
|
+
#
|
4
|
+
# April 2015, Alex Hunsberger
|
5
|
+
#
|
6
|
+
# March 2017, Re-written by Mike Wiebe
|
7
|
+
#
|
8
|
+
# Copyright (c) 2015-2017 Cisco and/or its affiliates.
|
9
|
+
#
|
10
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
11
|
+
# you may not use this file except in compliance with the License.
|
12
|
+
# You may obtain a copy of the License at
|
13
|
+
#
|
14
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
15
|
+
#
|
16
|
+
# Unless required by applicable law or agreed to in writing, software
|
17
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
18
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
19
|
+
# See the License for the specific language governing permissions and
|
20
|
+
# limitations under the License.
|
21
|
+
|
22
|
+
require_relative 'node_util'
|
23
|
+
require_relative 'logger'
|
24
|
+
|
25
|
+
module Cisco
|
26
|
+
# This Yum class provides cisco package management functions through nxapi.
|
27
|
+
class Yum < NodeUtil
|
28
|
+
def self.validate_installed(pkg)
|
29
|
+
# Sample data returned from config_get('yum', 'query_all')
|
30
|
+
# ["nxos.sample-n8k_EOR.lib32_nxos", "1.0.0-7.0.3.F1.1", "@patching"],
|
31
|
+
patch_data = config_get('yum', 'query_all')
|
32
|
+
patch_data.each do |name_arch, version, _state|
|
33
|
+
# Separate name and architecture
|
34
|
+
next if name_arch.rindex('.').nil?
|
35
|
+
arch = name_arch.slice!(name_arch.rindex('.')..-1).delete('.')
|
36
|
+
# Version/Architecture info not available when only pkg name specified.
|
37
|
+
version = arch = '' if name_arch == pkg
|
38
|
+
# Check for match
|
39
|
+
if pkg.match(name_arch) && pkg.match(version) && pkg.match(arch)
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
fail 'Failed to install the requested rpm'
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.detect_vrf
|
47
|
+
# Detect current namespace from agent environment
|
48
|
+
inode = File::Stat.new('/proc/self/ns/net').ino
|
49
|
+
# -L reqd for guestshell's find command
|
50
|
+
vrfname = File.basename(`find -L /var/run/netns/ -inum #{inode}`.chop)
|
51
|
+
|
52
|
+
vrf = 'vrf ' + vrfname unless vrfname.empty?
|
53
|
+
vrf
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.install(pkg, vrf=nil)
|
57
|
+
vrf = vrf.nil? ? detect_vrf : "vrf #{vrf}"
|
58
|
+
begin
|
59
|
+
# get package name first
|
60
|
+
name = pkg_name(pkg)
|
61
|
+
# call remove if pkg exists
|
62
|
+
remove(name) unless name.empty?
|
63
|
+
add(pkg, vrf)
|
64
|
+
activate(pkg)
|
65
|
+
commit(pkg_name(pkg))
|
66
|
+
validate_installed(pkg)
|
67
|
+
rescue Cisco::CliError, RuntimeError => e
|
68
|
+
raise Cisco::CliError, "#{e.class}, #{e.message}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# returns version of package, or false if package doesn't exist
|
73
|
+
def self.query(pkg)
|
74
|
+
fail TypeError unless pkg.is_a? String
|
75
|
+
fail ArgumentError if pkg.empty?
|
76
|
+
b = config_get('yum', 'query', pkg)
|
77
|
+
fail "Multiple matching packages found for #{pkg}" if b && b.size > 1
|
78
|
+
b.nil? ? nil : b.first
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.remove(pkg)
|
82
|
+
# get committed state
|
83
|
+
cstate = query_committed(pkg)
|
84
|
+
# get activated state
|
85
|
+
astate = query_activated(pkg)
|
86
|
+
|
87
|
+
if astate && cstate
|
88
|
+
# pkg is active and committed
|
89
|
+
# so deactivate, commit and remove
|
90
|
+
deactivate(pkg)
|
91
|
+
commit_deactivate(pkg)
|
92
|
+
delete(pkg)
|
93
|
+
elsif cstate
|
94
|
+
# pkg is inactive and committed
|
95
|
+
# so commit and remove
|
96
|
+
commit_deactivate(pkg)
|
97
|
+
delete(pkg)
|
98
|
+
elsif astate
|
99
|
+
# pkg is active and not committed
|
100
|
+
# so deactivate and remove
|
101
|
+
deactivate(pkg)
|
102
|
+
delete(pkg)
|
103
|
+
else
|
104
|
+
# pkg is inactive and not committed
|
105
|
+
# so just remove
|
106
|
+
delete(pkg)
|
107
|
+
end
|
108
|
+
rescue Cisco::CliError, RuntimeError => e
|
109
|
+
raise Cisco::CliError, "#{e.class}, #{e.message}"
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.add(pkg, vrf=nil)
|
113
|
+
try_operation('add', pkg, vrf)
|
114
|
+
while (try ||= 1) < 20
|
115
|
+
return if query_added(pkg)
|
116
|
+
sleep 1
|
117
|
+
try += 1
|
118
|
+
end
|
119
|
+
fail "Failed to add pkg: #{pkg}, using vrf #{vrf}"
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.activate(pkg)
|
123
|
+
try_operation('activate', pkg)
|
124
|
+
while (try ||= 1) < 20
|
125
|
+
return if query_activated(pkg)
|
126
|
+
sleep 1
|
127
|
+
try += 1
|
128
|
+
end
|
129
|
+
fail "Failed to activate pkg: #{pkg}"
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.commit(pkg)
|
133
|
+
try_operation('commit', pkg)
|
134
|
+
while (try ||= 1) < 20
|
135
|
+
return if query_committed(pkg)
|
136
|
+
sleep 1
|
137
|
+
try += 1
|
138
|
+
end
|
139
|
+
fail "Failed to commit pkg: #{pkg}"
|
140
|
+
end
|
141
|
+
|
142
|
+
def self.commit_deactivate(pkg)
|
143
|
+
try_operation('commit', pkg)
|
144
|
+
while (try ||= 1) < 20
|
145
|
+
return unless query_committed(pkg)
|
146
|
+
sleep 1
|
147
|
+
try += 1
|
148
|
+
end
|
149
|
+
fail "Failed to commit after deactivate pkg: #{pkg}"
|
150
|
+
end
|
151
|
+
|
152
|
+
def self.deactivate(pkg)
|
153
|
+
try_operation('deactivate', pkg)
|
154
|
+
while (try ||= 1) < 20
|
155
|
+
return if query_inactive(pkg)
|
156
|
+
sleep 1
|
157
|
+
try += 1
|
158
|
+
end
|
159
|
+
fail "Failed to deactivate pkg: #{pkg}"
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.delete(pkg)
|
163
|
+
try_operation('remove', pkg)
|
164
|
+
while (try ||= 1) < 20
|
165
|
+
return if query_removed(pkg)
|
166
|
+
sleep 1
|
167
|
+
try += 1
|
168
|
+
end
|
169
|
+
fail "Failed to delete pkg: #{pkg}"
|
170
|
+
end
|
171
|
+
|
172
|
+
def self.try_operation(operation, pkg, vrf=nil)
|
173
|
+
args = vrf.nil? ? { pkg: pkg } : { pkg: pkg, vrf: vrf }
|
174
|
+
while (try ||= 1) < 20
|
175
|
+
o = config_set('yum', operation, args)
|
176
|
+
break unless o[/Another install operation is in progress/]
|
177
|
+
sleep 1
|
178
|
+
try += 1
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.pkg_name(pkg)
|
183
|
+
config_get('yum', 'pkg_name', pkg: pkg)
|
184
|
+
end
|
185
|
+
|
186
|
+
def self.query_activated(pkg)
|
187
|
+
config_get('yum', 'query_activated', pkg: pkg)
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.query_added(pkg)
|
191
|
+
config_get('yum', 'query_added', pkg: pkg)
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.query_committed(pkg)
|
195
|
+
o = config_get('yum', 'query_committed', pkg: pkg)
|
196
|
+
return false if o.nil?
|
197
|
+
o.include? pkg
|
198
|
+
end
|
199
|
+
|
200
|
+
def self.query_inactive(pkg)
|
201
|
+
config_get('yum', 'query_inactive', pkg: pkg)
|
202
|
+
end
|
203
|
+
|
204
|
+
def self.query_removed(pkg)
|
205
|
+
val = config_get('yum', 'query_removed', pkg: pkg)
|
206
|
+
val ? false : true
|
207
|
+
end
|
208
|
+
|
209
|
+
def self.query_state(pkg)
|
210
|
+
config_get('yum', 'query_state', pkg: pkg).downcase
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,21 @@
|
|
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
|
+
# Declare module here as files referenced in glob-order below may assume
|
16
|
+
# module already exists.
|
17
|
+
module Cisco
|
18
|
+
end
|
19
|
+
|
20
|
+
# Automatically load all Ruby files in the cisco_node_utils subdirectory
|
21
|
+
Dir.glob(__dir__ + '/cisco_node_utils/*.rb') { |file| require file }
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# March 2016, Glenn F. Matthews
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cisco and/or its affiliates.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require_relative '../cisco_node_utils/environment'
|
18
|
+
|
19
|
+
# Add environment option to minitest
|
20
|
+
module Minitest
|
21
|
+
def self.plugin_environment_options(opts, options)
|
22
|
+
opts.on('-e', '--environment NAME', 'Select environment by name') do |name|
|
23
|
+
options[:environment] = name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.plugin_environment_init(options)
|
28
|
+
name = options[:environment]
|
29
|
+
Cisco::Environment.default_environment_name = name unless name.nil?
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# March 2016, Glenn F. Matthews
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cisco and/or its affiliates.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'logger'
|
18
|
+
require_relative '../cisco_node_utils/logger'
|
19
|
+
|
20
|
+
# Add logging level option to minitest
|
21
|
+
module Minitest
|
22
|
+
LEVEL_ALIASES = {
|
23
|
+
'debug' => Logger::DEBUG,
|
24
|
+
'info' => Logger::INFO,
|
25
|
+
'warning' => Logger::WARN,
|
26
|
+
'error' => Logger::ERROR,
|
27
|
+
}
|
28
|
+
def self.plugin_log_level_options(opts, options)
|
29
|
+
opts.on(
|
30
|
+
'-l', '--log-level LEVEL', LEVEL_ALIASES,
|
31
|
+
'Configure logging level for tests',
|
32
|
+
"(#{LEVEL_ALIASES.keys.join(', ')})"
|
33
|
+
) do |level|
|
34
|
+
options[:log_level] = level
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.plugin_log_level_init(options)
|
39
|
+
Cisco::Logger.level = options[:log_level] if options[:log_level]
|
40
|
+
end
|
41
|
+
end
|