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,570 @@
|
|
1
|
+
# How To Create New node_utils APIs
|
2
|
+
|
3
|
+
#### Table of Contents
|
4
|
+
|
5
|
+
* [Overview](#overview)
|
6
|
+
* [Before You Begin](#prerequisites)
|
7
|
+
* [Start here: Fork and Clone the Repo](#clone)
|
8
|
+
* [Example: router eigrp](#complex)
|
9
|
+
* [Step 1. YAML Definitions: router eigrp](#comp_yaml)
|
10
|
+
* [Step 2. Create the node_utils API: router eigrp](#comp_api)
|
11
|
+
* [Step 3. Create the Minitest: router eigrp](#comp_minitest)
|
12
|
+
* [Step 4. rubocop / lint: router eigrp](#comp_lint)
|
13
|
+
* [Step 5. Build and Install the gem](#comp_gem)
|
14
|
+
|
15
|
+
## <a name="overview">Overview</a>
|
16
|
+
|
17
|
+
This document is a HowTo guide for writing new cisco_node_utils APIs. The APIs act as an interface between the NX-OS CLI and an agent's resource/provider. If written properly the new API will work as a common framework for multiple providers (Puppet, Chef, etc). In addition to this guide, please reference the [cisco_node_utils development 'best practices' guide.](./README-develop-best-practices.md)
|
18
|
+
|
19
|
+
There are multiple components involved when creating new resources. This document focuses on the cisco_node_utils API, command reference YAML files, and minitests.
|
20
|
+
|
21
|
+
![1](agent_files.png)
|
22
|
+
|
23
|
+
## <a name="prerequisites">Before You Begin</a>
|
24
|
+
|
25
|
+
### <a name="prereq_git">Git Configuration</a>
|
26
|
+
|
27
|
+
Any code commits must be associated with your github account and email address. If you intend to commit code to this repository then you must configure `git` with your identity. If you have not already done so, use the following commands to configure the default identity that `git` will use for all projects on your system:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
git config --global user.name "John Doe"
|
31
|
+
git config --global user.email johndoe@example.com
|
32
|
+
```
|
33
|
+
If you do not wish to change the global configuration on your system, you can set your identity for a single local repository by using the above commands without the ``--global`` flag.
|
34
|
+
|
35
|
+
### <a name="prereq_ruby">Ruby Prerequisites</a>
|
36
|
+
|
37
|
+
This project requires Ruby 2.0 or later.
|
38
|
+
|
39
|
+
This development guide uses tools that are packaged as gems that need to be installed in your development environment. You can install the gems manually but it's recommended to use [Bundler](https://rubygems.org/gems/bundler) to guarantee the dependencies are all present.
|
40
|
+
|
41
|
+
```bash
|
42
|
+
gem install bundler
|
43
|
+
```
|
44
|
+
At present the following gems are needed to work on this code base - if you wish to install them all manually instead of through Bundler, you can run:
|
45
|
+
|
46
|
+
```bash
|
47
|
+
gem install grpc kwalify minitest net_http_unix rake rspec simplecov
|
48
|
+
gem install rubocop --version 0.35.1
|
49
|
+
```
|
50
|
+
|
51
|
+
**NOTE:** If you are working from a server where you don't have admin/root privileges, use the following commands to install the gems:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
gem install --user-install bundler
|
55
|
+
gem install --user-install grpc kwalify minitest net_http_unix rake rspec simplecov
|
56
|
+
gem install --user-install rubocop --version 0.35.1
|
57
|
+
```
|
58
|
+
or add `--user-install` to your `.gemrc` to make this the default behavior:
|
59
|
+
|
60
|
+
```bash
|
61
|
+
echo 'gem: --user-install' >> ~/.gemrc
|
62
|
+
```
|
63
|
+
and then update the `PATH` to include `~/.gem/ruby/x.x.x/bin`. For example, you could add this to your `.bashrc` or `.profile`:
|
64
|
+
|
65
|
+
```bash
|
66
|
+
if which ruby >/dev/null && which gem >/dev/null; then
|
67
|
+
PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
|
68
|
+
fi
|
69
|
+
```
|
70
|
+
|
71
|
+
### <a name="prereq_vm">Nexus VM (optional)</a>
|
72
|
+
|
73
|
+
A virtual Nexus N9000 may be helpful for development and testing. Users with a valid [cisco.com](http://cisco.com) user ID can [download the software on CCO.](https://software.cisco.com/download/release.html?mdfid=286312239&softwareid=282088129&release=7.0(3)I5(2)&relind=AVAILABLE&rellifecycle=&reltype=latest) If you do not have a [cisco.com](http://cisco.com) user ID please register for one at [https://tools.cisco.com/IDREG/guestRegistration](https://tools.cisco.com/IDREG/guestRegistration)
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
## <a name="clone">Start here: Fork and Clone the Repo</a>
|
78
|
+
|
79
|
+
First [fork](https://help.github.com/articles/fork-a-repo) the [cisco-network-node-utils](https://github.com/cisco/cisco-network-node-utils) repository on GitHub.
|
80
|
+
|
81
|
+
Next create your local repository. Clone the cisco-network-node-utils repo from your fork into a workspace:
|
82
|
+
|
83
|
+
```bash
|
84
|
+
git clone https://github.com/YOUR-USERNAME/cisco-network-node-utils.git
|
85
|
+
cd cisco-network-node-utils/
|
86
|
+
```
|
87
|
+
|
88
|
+
If you're using Bundler, invoke it to ensure all of the development dependencies are installed on your system:
|
89
|
+
|
90
|
+
```bash
|
91
|
+
bundle install
|
92
|
+
```
|
93
|
+
|
94
|
+
or (if you don't have admin/root privileges and have used `--user-install` to install Bundler):
|
95
|
+
|
96
|
+
```bash
|
97
|
+
~/.gem/ruby/$RUBY_VERSION/bin/bundle install --path ~/.gem
|
98
|
+
```
|
99
|
+
|
100
|
+
Optionally create the file `~/cisco_node_utils.yaml` to specify how the test scripts will connect to your Nexus VM or other node under test. Refer to the project [README](../README.md#configuration) for details.
|
101
|
+
|
102
|
+
If you intend to contribute your code back to the project then you should install the git hooks that are checked in with the project source code. These hooks check your commits for conformance with various style guidelines. To install them in your local repository (or to update them to match the files currently in the repository, in case they are out of sync), simply run the `update-hooks` script:
|
103
|
+
|
104
|
+
```bash
|
105
|
+
bin/git/update-hooks
|
106
|
+
```
|
107
|
+
|
108
|
+
|
109
|
+
## <a name="complex">Example: router eigrp</a>
|
110
|
+
|
111
|
+
As a best practice, create a topic branch (also sometimes called a feature branch) for your feature work using the `git branch feature/<feature_name>` command.
|
112
|
+
|
113
|
+
```bash
|
114
|
+
git branch feature/eigrp
|
115
|
+
git branch
|
116
|
+
* develop
|
117
|
+
feature/eigrp
|
118
|
+
```
|
119
|
+
|
120
|
+
Before you start working on the eigrp feature, checkout its topic branch, `feature/eigrp`.
|
121
|
+
|
122
|
+
```bash
|
123
|
+
git checkout feature/eigrp
|
124
|
+
git branch
|
125
|
+
develop
|
126
|
+
* feature/eigrp
|
127
|
+
```
|
128
|
+
|
129
|
+
`router eigrp` requires feature enablement and supports multiple eigrp instances. It also has multiple configuration levels for vrf and address-family.
|
130
|
+
|
131
|
+
For the purposes of this example we will only implement the following properties:
|
132
|
+
|
133
|
+
```bash
|
134
|
+
[no] feature eigrp (boolean)
|
135
|
+
[no] router eigrp [name] (string)
|
136
|
+
maximum-paths [n] (integer)
|
137
|
+
[no] shutdown (boolean)
|
138
|
+
|
139
|
+
Example:
|
140
|
+
feature eigrp
|
141
|
+
router eigrp Blue
|
142
|
+
maximum-paths 5
|
143
|
+
shutdown
|
144
|
+
```
|
145
|
+
|
146
|
+
### <a name="comp_yaml">Step 1. YAML Definitions: router eigrp</a>
|
147
|
+
|
148
|
+
The new API for `router eigrp` will need some basic YAML definitions. By convention we create a new YAML file to handle a new feature set, so we will create
|
149
|
+
the following file:
|
150
|
+
|
151
|
+
`lib/cisco_node_utils/cmd_ref/eigrp.yaml`
|
152
|
+
|
153
|
+
YAML files in the `/cmd_ref/` subdirectory are automatically discovered at runtime, so we don't need to do anything special once we have created this file
|
154
|
+
|
155
|
+
The following basic command_reference parameters will be defined for each resource property:
|
156
|
+
|
157
|
+
1. `get_command:` This defines the CLI command (usually a 'show...' command) or similar request string used to retrieve the property's current configuration state. Note that some commands may not be present on NX-OS until a pre-requisite feature is enabled.
|
158
|
+
2. `get_value:` A regexp pattern for extracting state values from the get_command output.
|
159
|
+
3. `set_value:` The configuration command(s) used to set the property configuration. May contain wildcards for variable parameters.
|
160
|
+
4. `default_value:` This is typically the "factory" default state of the property, expressed as an actual value (true, 12, "off", etc)
|
161
|
+
5. `kind:` The data type of this property. If omitted, the property will be a string by default. Commonly used values for this property are `int` and `boolean`.
|
162
|
+
6. `multiple:` By default a property is assumed to be found once or not at all by the `get_command`/`get_value` lookup, and an error will be raised if multiple matches are found. If multiple matches are valid and expected, you must set `multiple: true` for this property.
|
163
|
+
7. `os_version:` This command_reference parameter is used to specify the product family and minimum os version within that product family required to support the property. Any version that is greater then or equal to the specified os version within the product family will be supported. If nothing is specified, the property is assumed to be supported on all version of software. This is a test_only feature and is ignored outside the context of the minitests and must be used in conjunction with the skip_incompat_version? API defined in the ciscotest.rb file.
|
164
|
+
|
165
|
+
There are additional YAML command parameters available which are not covered by this document. Please see the [README_YAML.md](../lib/cisco_node_utils/cmd_ref/README_YAML.md) document for more information on the structure and semantics of these files.
|
166
|
+
The properties in this example require additional context for their `get_value` and `set_value` because they need to differentiate between different eigrp instances. This is done with the `context` parameter. (For more complex properties, you can define `get_context` and `set_context` separately if needed.) Most properties will also have a default value.
|
167
|
+
|
168
|
+
*Note: Eigrp also has vrf and address-family contexts. These contexts require additional coding and are beyond the scope of this document.*
|
169
|
+
|
170
|
+
#### Example: YAML Property Definitions for router eigrp
|
171
|
+
|
172
|
+
*Note: The basic token definitions for multi-level commands can become long and complicated. A better solution for these commands is to use a command_reference _template: definition to simplify the configuration. The example below will use the basic syntax; see the ospf definitions in the YAML file for an example of _template: usage.*
|
173
|
+
|
174
|
+
*Note: Property definitions in the YAML must be given in alphabetical order. Parameters under a property can be given in any order.*
|
175
|
+
|
176
|
+
```yaml
|
177
|
+
# eigrp.yaml
|
178
|
+
---
|
179
|
+
feature:
|
180
|
+
# feature eigrp must be enabled before configuring router eigrp
|
181
|
+
kind: boolean
|
182
|
+
os_version: 'N3k, N9k:7.0.3.I2.1; N7k:8.1.1'
|
183
|
+
get_command: 'show running eigrp all'
|
184
|
+
get_value: 'feature eigrp'
|
185
|
+
set_value: '<state> feature eigrp'
|
186
|
+
|
187
|
+
maximum_paths:
|
188
|
+
# This is an integer property
|
189
|
+
kind: int
|
190
|
+
context:
|
191
|
+
- 'router eigrp <name>'
|
192
|
+
get_command: 'show running eigrp all'
|
193
|
+
get_value: 'maximum-paths (\d+)'
|
194
|
+
set_value: 'maximum-paths <val>'
|
195
|
+
default_value: 8
|
196
|
+
|
197
|
+
router:
|
198
|
+
# There can be multiple eigrp instances
|
199
|
+
multiple: true
|
200
|
+
get_command: 'show running eigrp all' # all eigrp-related configs
|
201
|
+
get_value: 'router eigrp (\S+)' # Match instance name
|
202
|
+
set_value: '<state> router eigrp <name>' # config to add or remove
|
203
|
+
|
204
|
+
shutdown:
|
205
|
+
# This is a boolean property
|
206
|
+
kind: boolean
|
207
|
+
context:
|
208
|
+
- 'router eigrp <name>'
|
209
|
+
get_command: 'show running eigrp all'
|
210
|
+
get_value: 'shutdown'
|
211
|
+
set_value: '<state> shutdown'
|
212
|
+
default_value: false
|
213
|
+
```
|
214
|
+
|
215
|
+
### <a name="comp_api">Step 2. cisco_node_utils API: router eigrp</a>
|
216
|
+
|
217
|
+
* The `template-router.rb` file provides a basic router API that we will use as the basis for `router_eigrp.rb`:
|
218
|
+
|
219
|
+
```bash
|
220
|
+
cp docs/template-router.rb lib/cisco_node_utils/router_eigrp.rb
|
221
|
+
```
|
222
|
+
|
223
|
+
* Our new `router_eigrp.rb` requires changes from the original template. Edit `router_eigrp.rb` and change the placeholder names as shown.
|
224
|
+
|
225
|
+
```
|
226
|
+
/X__CLASS_NAME__X/RouterEigrp/
|
227
|
+
|
228
|
+
/X__RESOURCE_NAME__X/eigrp/
|
229
|
+
|
230
|
+
/X__PROPERTY_BOOL__X/shutdown/
|
231
|
+
|
232
|
+
/X__PROPERTY_INT__X/maximum_paths/
|
233
|
+
```
|
234
|
+
|
235
|
+
*Note that this template only provides example property methods for a few properties. Copy the example methods for additional properties as needed.*
|
236
|
+
|
237
|
+
#### Example: router_eigrp.rb
|
238
|
+
This is the completed `router_eigrp` API based on `template-router.rb`:
|
239
|
+
|
240
|
+
```ruby
|
241
|
+
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
242
|
+
#
|
243
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
244
|
+
# you may not use this file except in compliance with the License.
|
245
|
+
# You may obtain a copy of the License at
|
246
|
+
#
|
247
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
248
|
+
#
|
249
|
+
# Unless required by applicable law or agreed to in writing, software
|
250
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
251
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
252
|
+
# See the License for the specific language governing permissions and
|
253
|
+
# limitations under the License.
|
254
|
+
|
255
|
+
require_relative 'node_util'
|
256
|
+
|
257
|
+
module Cisco
|
258
|
+
# RouterEigrp - node utility class for EIGRP config management.
|
259
|
+
class RouterEigrp < NodeUtil
|
260
|
+
attr_reader :name
|
261
|
+
|
262
|
+
# name: name of the router instance
|
263
|
+
# instantiate: true = create router instance
|
264
|
+
def initialize(name, instantiate=true)
|
265
|
+
fail ArgumentError unless name.length > 0
|
266
|
+
@name = name
|
267
|
+
create if instantiate
|
268
|
+
end
|
269
|
+
|
270
|
+
def to_s
|
271
|
+
"RouterEigrp '#{name}'"
|
272
|
+
end
|
273
|
+
|
274
|
+
# Create a hash of all current router instances.
|
275
|
+
def self.routers
|
276
|
+
instances = config_get('eigrp', 'router')
|
277
|
+
return {} if instances.nil?
|
278
|
+
hash = {}
|
279
|
+
instances.each do |name|
|
280
|
+
hash[name] = RouterEigrp.new(name, false)
|
281
|
+
end
|
282
|
+
return hash
|
283
|
+
rescue Cisco::CliError => e
|
284
|
+
# CLI will syntax reject when feature is not enabled
|
285
|
+
raise unless e.clierror =~ /Syntax error/
|
286
|
+
return {}
|
287
|
+
end
|
288
|
+
|
289
|
+
def feature_enabled
|
290
|
+
config_get('eigrp', 'feature')
|
291
|
+
rescue Cisco::CliError => e
|
292
|
+
# This cmd will syntax reject if feature is not
|
293
|
+
# enabled. Just catch the reject and return false.
|
294
|
+
return false if e.clierror =~ /Syntax error/
|
295
|
+
raise
|
296
|
+
end
|
297
|
+
|
298
|
+
def feature_enable
|
299
|
+
config_set('eigrp', 'feature', state: '')
|
300
|
+
end
|
301
|
+
|
302
|
+
def feature_disable
|
303
|
+
config_set('eigrp', 'feature', state: 'no')
|
304
|
+
end
|
305
|
+
|
306
|
+
# Enable feature and create router instance
|
307
|
+
def create
|
308
|
+
feature_enable unless feature_enabled
|
309
|
+
eigrp_router
|
310
|
+
end
|
311
|
+
|
312
|
+
# Destroy a router instance; disable feature on last instance
|
313
|
+
def destroy
|
314
|
+
ids = config_get('eigrp', 'router')
|
315
|
+
return if ids.nil?
|
316
|
+
if ids.size == 1
|
317
|
+
feature_disable
|
318
|
+
else
|
319
|
+
eigrp_router('no')
|
320
|
+
end
|
321
|
+
rescue Cisco::CliError => e
|
322
|
+
# CLI will syntax reject when feature is not enabled
|
323
|
+
raise unless e.clierror =~ /Syntax error/
|
324
|
+
end
|
325
|
+
|
326
|
+
def eigrp_router(state='')
|
327
|
+
config_set('eigrp', 'router', name: @name, state: state)
|
328
|
+
end
|
329
|
+
|
330
|
+
# ----------
|
331
|
+
# PROPERTIES
|
332
|
+
# ----------
|
333
|
+
|
334
|
+
# Property methods for boolean property
|
335
|
+
def default_shutdown
|
336
|
+
config_get_default('eigrp', 'shutdown')
|
337
|
+
end
|
338
|
+
|
339
|
+
def shutdown
|
340
|
+
config_get('eigrp', 'shutdown', name: @name)
|
341
|
+
end
|
342
|
+
|
343
|
+
def shutdown=(state)
|
344
|
+
state = (state ? '' : 'no')
|
345
|
+
config_set('eigrp', 'shutdown', name: @name, state: state)
|
346
|
+
end
|
347
|
+
|
348
|
+
# Property methods for integer property
|
349
|
+
def default_maximum_paths
|
350
|
+
config_get_default('eigrp', 'maximum_paths')
|
351
|
+
end
|
352
|
+
|
353
|
+
def maximum_paths
|
354
|
+
config_get('eigrp', 'maximum_paths', name: @name)
|
355
|
+
end
|
356
|
+
|
357
|
+
def maximum_paths=(val)
|
358
|
+
config_set('eigrp', 'maximum_paths', name: @name, val: val)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
end
|
362
|
+
```
|
363
|
+
|
364
|
+
### <a name="comp_minitest">Step 3. Minitest: router eigrp</a>
|
365
|
+
|
366
|
+
* Use `template-test_router.rb` to build the minitest for `router_eigrp.rb`:
|
367
|
+
|
368
|
+
```
|
369
|
+
cp docs/template-test_router.rb tests/test_router_eigrp.rb
|
370
|
+
```
|
371
|
+
* As with the API code, edit `test_router_eigrp.rb` and change the placeholder names as shown:
|
372
|
+
|
373
|
+
```
|
374
|
+
/X__CLASS_NAME__X/RouterEigrp/
|
375
|
+
|
376
|
+
/X__RESOURCE_NAME__X/eigrp/
|
377
|
+
|
378
|
+
/X__PROPERTY_BOOL__X/shutdown/
|
379
|
+
|
380
|
+
/X__PROPERTY_INT__X/maximum_paths/
|
381
|
+
```
|
382
|
+
|
383
|
+
* At a minimum, the tests should include coverage for:
|
384
|
+
* creating & destroying a single `router eigrp` instance
|
385
|
+
* creating & destroying multiple `router eigrp` instances
|
386
|
+
* feature disablement when removing last `router eigrp`
|
387
|
+
* testing each property state
|
388
|
+
|
389
|
+
#### Example: test_router_eigrp.rb
|
390
|
+
This is the completed `test_router_eigrp` minitest based on `template-test_router.rb`:
|
391
|
+
|
392
|
+
```ruby
|
393
|
+
# Copyright (c) 2014-2015 Cisco and/or its affiliates.
|
394
|
+
#
|
395
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
396
|
+
# you may not use this file except in compliance with the License.
|
397
|
+
# You may obtain a copy of the License at
|
398
|
+
#
|
399
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
400
|
+
#
|
401
|
+
# Unless required by applicable law or agreed to in writing, software
|
402
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
403
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
404
|
+
# See the License for the specific language governing permissions and
|
405
|
+
# limitations under the License.
|
406
|
+
|
407
|
+
require_relative 'ciscotest'
|
408
|
+
require_relative '../lib/cisco_node_utils/router_eigrp'
|
409
|
+
|
410
|
+
# TestRouterEigrp - Minitest for RouterEigrp node utility class
|
411
|
+
class TestRouterEigrp < CiscoTestCase
|
412
|
+
def setup
|
413
|
+
# setup runs at the beginning of each test
|
414
|
+
super
|
415
|
+
no_feature_eigrp
|
416
|
+
end
|
417
|
+
|
418
|
+
def teardown
|
419
|
+
# teardown runs at the end of each test
|
420
|
+
no_feature_eigrp
|
421
|
+
super
|
422
|
+
end
|
423
|
+
|
424
|
+
def no_feature_eigrp
|
425
|
+
# Turn the feature off for a clean test.
|
426
|
+
config('no feature eigrp')
|
427
|
+
end
|
428
|
+
|
429
|
+
# TESTS
|
430
|
+
|
431
|
+
def test_router_create_destroy_one
|
432
|
+
id = 'blue'
|
433
|
+
rtr = RouterEigrp.new(id)
|
434
|
+
@default_show_command = "show runn | i 'router eigrp #{id}'")
|
435
|
+
assert_show_match(pattern: /^router eigrp #{id}$/,
|
436
|
+
msg: "failed to create router eigrp #{id}")
|
437
|
+
|
438
|
+
rtr.destroy
|
439
|
+
refute_show_match(pattern: /^router eigrp #{id}$/,
|
440
|
+
msg: "failed to destroy router eigrp #{id}")
|
441
|
+
|
442
|
+
refute_show_match(command: "show runn | i 'feature eigrp'",
|
443
|
+
pattern: /^feature eigrp$/,
|
444
|
+
msg: "failed to disable feature eigrp")
|
445
|
+
end
|
446
|
+
|
447
|
+
def test_router_create_destroy_multiple
|
448
|
+
id1 = 'blue'
|
449
|
+
rtr1 = RouterEigrp.new(id1)
|
450
|
+
id2 = 'red'
|
451
|
+
rtr2 = RouterEigrp.new(id2)
|
452
|
+
|
453
|
+
@default_show_command = "show runn | i 'router eigrp'"
|
454
|
+
|
455
|
+
assert_show_match(pattern: /^router eigrp #{id1}$/,
|
456
|
+
msg: "failed to create router eigrp #{id1}")
|
457
|
+
|
458
|
+
assert_show_match(pattern: /^router eigrp #{id2}$/,
|
459
|
+
msg: "failed to create router eigrp #{id2}")
|
460
|
+
|
461
|
+
rtr1.destroy
|
462
|
+
refute_show_match(pattern: /^router eigrp #{id1}$/,
|
463
|
+
msg: "failed to destroy router eigrp #{id1}")
|
464
|
+
|
465
|
+
rtr2.destroy
|
466
|
+
refute_show_match(pattern: /^router eigrp #{id2}$/,
|
467
|
+
msg: "failed to destroy router eigrp #{id2}")
|
468
|
+
|
469
|
+
refute_show_match(command: "show runn | i 'feature eigrp'",
|
470
|
+
pattern: /^feature eigrp$/,
|
471
|
+
msg: "failed to disable feature eigrp")
|
472
|
+
end
|
473
|
+
|
474
|
+
def test_router_maximum_paths
|
475
|
+
id = 'blue'
|
476
|
+
rtr = RouterEigrp.new(id)
|
477
|
+
val = 5 # This value depends on property bounds
|
478
|
+
rtr.maximum_paths = val
|
479
|
+
assert_equal(rtr.maximum_paths, val, "maximum_paths is not #{val}")
|
480
|
+
|
481
|
+
# Get default value from yaml
|
482
|
+
val = node.config_get_default('eigrp', 'maximum_paths')
|
483
|
+
rtr.maximum_paths = val
|
484
|
+
assert_equal(rtr.maximum_paths, val, "maximum_paths is not #{val}")
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_router_shutdown
|
488
|
+
id = 'blue'
|
489
|
+
rtr = RouterEigrp.new(id)
|
490
|
+
rtr.shutdown = true
|
491
|
+
assert(rtr.shutdown, 'shutdown state is not true')
|
492
|
+
|
493
|
+
rtr.shutdown = false
|
494
|
+
refute(rtr.shutdown, 'shutdown state is not false')
|
495
|
+
end
|
496
|
+
end
|
497
|
+
```
|
498
|
+
|
499
|
+
Now run the test (see [README-test-execution](README-test-execution.md) for detailed instructions):
|
500
|
+
|
501
|
+
```bash
|
502
|
+
% ruby test_router_eigrp.rb -v --environment my_nexus_vm
|
503
|
+
Run options: -v -- --seed 56593
|
504
|
+
|
505
|
+
# Running:
|
506
|
+
|
507
|
+
Node under test:
|
508
|
+
- name - my_n3k
|
509
|
+
- type - N3K-C3132Q-40GX
|
510
|
+
- image -
|
511
|
+
|
512
|
+
2.90 s = .
|
513
|
+
TestRouterEigrp#test_router_create_destroy_multiple = 10.77 s = .
|
514
|
+
TestRouterEigrp#test_router_create_destroy_one = 6.14 s = .
|
515
|
+
TestRouterEigrp#test_router_maximum_paths = 9.41 s = .
|
516
|
+
TestRouterEigrp#test_router_shutdown = 6.40 s = .
|
517
|
+
|
518
|
+
|
519
|
+
Finished tests in 37.512356s, 0.1866 tests/s, 0.3199 assertions/s.
|
520
|
+
|
521
|
+
5 tests, 12 assertions, 0 failures, 0 errors, 0 skips
|
522
|
+
```
|
523
|
+
|
524
|
+
### <a name="comp_lint">Step 4. rubocop: router eigrp</a>
|
525
|
+
|
526
|
+
rubocop is a Ruby static analysis tool. Run rubocop to validate the new code:
|
527
|
+
|
528
|
+
```bash
|
529
|
+
% rubocop lib/cisco_node_utils/router_eigrp.rb tests/test_router_eigrp.rb
|
530
|
+
Inspecting 2 file
|
531
|
+
..
|
532
|
+
|
533
|
+
2 file inspected, no offenses detected
|
534
|
+
```
|
535
|
+
|
536
|
+
### <a name="comp_gem">Step 5. Build and Install the gem</a>
|
537
|
+
|
538
|
+
The final step is to build and install the gem that contains the new APIs.
|
539
|
+
|
540
|
+
Please note: `gem build` will only include files that are part of the repository. This means that new files `router_eigrp.rb` and `eigrp.yaml` will be ignored by the build until they are added to the repo with `git add`:
|
541
|
+
|
542
|
+
```bash
|
543
|
+
git add lib/cisco_node_utils/router_eigrp.rb \
|
544
|
+
lib/cisco_node_utils/cmd_ref/eigrp.yaml
|
545
|
+
```
|
546
|
+
|
547
|
+
From the root of the cisco-network-node-utils repository issue the following command.
|
548
|
+
|
549
|
+
```bash
|
550
|
+
% gem build cisco_node_utils.gemspec
|
551
|
+
Successfully built RubyGem
|
552
|
+
Name: cisco_node_utils
|
553
|
+
Version: 1.0.1
|
554
|
+
File: cisco_node_utils-1.0.1.gem
|
555
|
+
```
|
556
|
+
|
557
|
+
Copy the new gem to your NX-OS device and then install it.
|
558
|
+
|
559
|
+
```bash
|
560
|
+
n9k#gem install --local /bootflash/cisco_node_utils-1.0.1.gem
|
561
|
+
Successfully installed cisco_node_utils-1.0.1
|
562
|
+
Parsing documentation for cisco_node_utils-1.0.1
|
563
|
+
Installing ri documentation for cisco_node_utils-1.0.1
|
564
|
+
Done installing documentation for cisco_node_utils after 2 seconds
|
565
|
+
1 gem installed
|
566
|
+
```
|
567
|
+
|
568
|
+
## Conclusion
|
569
|
+
|
570
|
+
This was hopefully a good introduction to writing a Cisco node_utils API. At this point you could continue adding properties or try your hand at writing Puppet or Chef provider code to utilize your new API.
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Maintainers Guide
|
2
|
+
|
3
|
+
Guidelines for the core maintainers of the cisco-network-node-utils project - above and beyond the [general developer guidelines](../CONTRIBUTING.md).
|
4
|
+
|
5
|
+
## Accepting Pull Requests
|
6
|
+
|
7
|
+
* Is the pull request correctly submitted against `develop`?
|
8
|
+
* Does `rubocop` pass? (TODO - this will be part of our CI integration to run automatically)
|
9
|
+
* Is `CHANGELOG.md` updated appropriately?
|
10
|
+
* Are new minitests added? Do they provide sufficient coverage and consistent results?
|
11
|
+
* Do minitests pass on all supported platforms
|
12
|
+
|
13
|
+
## Release Process Checklist
|
14
|
+
|
15
|
+
When we are considering publishing a new release, all of the following steps must be carried out.
|
16
|
+
* NOTE: Use the latest code base in `develop`
|
17
|
+
|
18
|
+
### Pre-Merge to `master` branch:
|
19
|
+
|
20
|
+
1. Pull release branch based on the `develop` branch.
|
21
|
+
* 0.0.x - a bugfix release
|
22
|
+
* 0.x.0 - new feature(s)
|
23
|
+
* x.0.0 - backward-incompatible change (if unvoidable!)
|
24
|
+
|
25
|
+
1. Run full minitest regression on [supported platforms.](https://github.com/cisco/cisco-network-node-utils#overview)
|
26
|
+
* Fix All Bugs.
|
27
|
+
* Make sure proper test case skips are in place for unsupported platforms.
|
28
|
+
* Make sure [yum_package.yaml](../tests/yum_package.yaml) is updated with all versions that need to be tested.
|
29
|
+
|
30
|
+
1. Build gem and test it in combination with the latest released Puppet module (using Beaker and demo manifests) to make sure no backward compatibility issues have been introduced.
|
31
|
+
|
32
|
+
1. Update [changelog.](https://github.com/cisco/cisco-network-node-utils/blob/develop/CHANGELOG.md)
|
33
|
+
* Make sure CHANGELOG.md accurately reflects all changes since the last release.
|
34
|
+
* Add any significant changes that weren't documented in the changelog
|
35
|
+
* Clean up any entries that are overly verbose, unclear, or otherwise could be improved.
|
36
|
+
* Create markdown release tag.
|
37
|
+
* [Example](https://github.com/cisco/cisco-network-node-utils/blob/develop/CHANGELOG.md#v120)
|
38
|
+
* Add compare versions
|
39
|
+
```diff
|
40
|
+
...
|
41
|
+
+[v1.0.1]: https://github.com/cisco/cisco-network-node-utils/compare/v1.0.0...v1.0.1
|
42
|
+
[v1.0.0]: https://github.com/cisco/cisco-network-node-utils/compare/v0.9.0...v1.0.0
|
43
|
+
```
|
44
|
+
* Indicate new platform support (if any) for exisiting providers.
|
45
|
+
|
46
|
+
1. Update [cisco_node_utils.gemspec](https://github.com/cisco/cisco-network-node-utils/blob/develop/cisco_node_utils.gemspec) if needed.
|
47
|
+
* Is the data still relevant?
|
48
|
+
* Do the version dependencies need to be updated? (e.g. rubocop)
|
49
|
+
|
50
|
+
1. Update [version.rb](https://github.com/cisco/cisco-network-node-utils/blob/develop/lib/cisco_node_utils/version.rb) file.
|
51
|
+
```diff
|
52
|
+
- VERSION = '1.0.0'
|
53
|
+
+ VERSION = '1.0.1'
|
54
|
+
```
|
55
|
+
|
56
|
+
1. Scrub README Docs.
|
57
|
+
* Update references to indicate new platorm support where applicable.
|
58
|
+
* Update nxos release information where applicable.
|
59
|
+
|
60
|
+
1. Open pull request from release branch against the `master` branch.
|
61
|
+
* Merge after approval.
|
62
|
+
|
63
|
+
### Post-Merge to `master` branch:
|
64
|
+
|
65
|
+
1. Create annotated git tag for the release.
|
66
|
+
* [HowTo](https://git-scm.com/book/en/v2/Git-Basics-Tagging#Annotated-Tags)
|
67
|
+
|
68
|
+
2. Draft a [new release](https://github.com/cisco/cisco-network-node-utils/releases) on github.
|
69
|
+
|
70
|
+
3. Publish the gem to rubygems.org. (Replace `x.x.x` with actual gem version)
|
71
|
+
```
|
72
|
+
gem build cisco_node_utils.gemspec
|
73
|
+
gem push cisco_node_utils-x.x.x.gem
|
74
|
+
```
|
75
|
+
4. Merge `master` branch back into `develop` branch.
|
76
|
+
* Resolve any merge conflicts
|
77
|
+
* Optional: Delete release branch (May want to keep for reference)
|