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,57 @@
|
|
1
|
+
# Executing the tests provided for this gem
|
2
|
+
|
3
|
+
## RSpec tests
|
4
|
+
|
5
|
+
The test files located in the `spec/` directory use [RSpec](http://rspec.info/) as their test framework. These tests are generally standalone and do not generally require any actual Cisco hardware or virtual machines to test against.
|
6
|
+
|
7
|
+
### Running a single RSpec test
|
8
|
+
|
9
|
+
You can execute a single spec file by name:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
rspec spec/environment_spec.rb
|
13
|
+
```
|
14
|
+
|
15
|
+
### Running all RSpec tests
|
16
|
+
|
17
|
+
|
18
|
+
```bash
|
19
|
+
rake spec
|
20
|
+
```
|
21
|
+
|
22
|
+
## Minitest tests
|
23
|
+
|
24
|
+
The test files located in the `tests/` directory use [minitest](https://github.com/seattlerb/minitest/) as their test framework. These tests generally require one or more Cisco routers, switches, or virtual machines to test against.
|
25
|
+
|
26
|
+
It is recommended that you create a `cisco_node_utils.yaml` file (as described in [README.md](../README.md#configuration) to specify the node(s) under test, but if you do not create such a file, the test will prompt you to enter the required information at runtime:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
$ rake test
|
30
|
+
Enter address or hostname of node under test: 192.168.100.1
|
31
|
+
Enter username for node under test: user
|
32
|
+
Enter password for node under test: password
|
33
|
+
```
|
34
|
+
|
35
|
+
### Running a single minitest test
|
36
|
+
|
37
|
+
You can execute a single test file by name. If you do not specify the `-e` / `--environment` option, the node labeled as `default` in `cisco_node_utils.yaml` will be used (or, if no such entry exists, you will be prompted to enter the required information as shown above):
|
38
|
+
|
39
|
+
```bash
|
40
|
+
# Run test against the 'default' node:
|
41
|
+
$ ruby tests/test_node.rb
|
42
|
+
# Run test against node 'n7k':
|
43
|
+
$ ruby tests/test_node.rb --environment n7k
|
44
|
+
# Run test against node 'n9k':
|
45
|
+
$ ruby tests/test_node.rb -e n9k
|
46
|
+
```
|
47
|
+
|
48
|
+
### Running all minitest tests
|
49
|
+
|
50
|
+
As above, if you do not specify the `--environment` option, the `default` node will be used or you will be prompted if necessary.
|
51
|
+
|
52
|
+
```bash
|
53
|
+
# Run all tests against the 'default' node:
|
54
|
+
$ rake test
|
55
|
+
# Run all tests against 'n7k':
|
56
|
+
$ rake test TEST_OPTS='--environment=n7k'
|
57
|
+
```
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Executable utilities included in this gem
|
2
|
+
|
3
|
+
## check_metric_limits.rb
|
4
|
+
|
5
|
+
This is a helper script for developers. If you're doing refactoring work to
|
6
|
+
reduce the code complexity metrics, you can run this script to report the
|
7
|
+
worst offenders for each metric and whether you've managed to improve any
|
8
|
+
metrics compared to the baseline. Run this script from the base
|
9
|
+
cisco-network-node-utils directory to report metrics of code in the
|
10
|
+
./lib and ./tests directories.
|
11
|
+
|
12
|
+
```bash
|
13
|
+
[cisco-network-node-utils]$ ruby bin/check_metric_limits.rb
|
14
|
+
```
|
Binary file
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# The entry labeled 'default' will be used by default.
|
2
|
+
# The user can select a different entry by name if desired.
|
3
|
+
#
|
4
|
+
# default:
|
5
|
+
# host: foo
|
6
|
+
|
7
|
+
# Example config for running NXAPI remotely:
|
8
|
+
nxapi_remote:
|
9
|
+
host: 192.168.1.100
|
10
|
+
username: devops
|
11
|
+
password: devops
|
12
|
+
|
13
|
+
# Example config for running NXAPI on a node:
|
14
|
+
nxapi_local:
|
15
|
+
# (none needed)
|
16
|
+
|
17
|
+
# Example config for running NXAPI on a node with default cookie override:
|
18
|
+
# User 'nxapi' must be configured with requisite privilages to configure the device.
|
19
|
+
# This will override the default 'admin:local' cookie and use 'nxapi:local' instead.
|
20
|
+
default:
|
21
|
+
cookie: 'nxapi:local'
|
22
|
+
|
23
|
+
# Example config for running gRPC remotely:
|
24
|
+
grpc_remote:
|
25
|
+
host: 192.168.1.100
|
26
|
+
# gRPC port defaults to 57400 if unset
|
27
|
+
# port: 57400
|
28
|
+
username: admin
|
29
|
+
password: admin
|
30
|
+
|
31
|
+
# Example config for running gRPC on a node:
|
32
|
+
grpc_local:
|
33
|
+
port: 57999
|
34
|
+
username: admin
|
35
|
+
password: admin
|
36
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# Copyright (c) 2014-2015 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 'node_util'
|
16
|
+
|
17
|
+
module Cisco
|
18
|
+
# X__CLASS_NAME__X - node utility class for X__CLASS_NAME__X config mgmt.
|
19
|
+
class X__CLASS_NAME__X < NodeUtil
|
20
|
+
attr_reader :name
|
21
|
+
|
22
|
+
# name: name of the router instance
|
23
|
+
# instantiate: true = create router instance
|
24
|
+
def initialize(name, instantiate=true)
|
25
|
+
fail ArgumentError unless name.length > 0
|
26
|
+
@name = name
|
27
|
+
create if instantiate
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"X__CLASS_NAME__X '#{name}'"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Create a hash of all current router instances.
|
35
|
+
def self.routers
|
36
|
+
instances = config_get('X__RESOURCE_NAME__X', 'router')
|
37
|
+
return {} if instances.nil?
|
38
|
+
hash = {}
|
39
|
+
instances.each do |name|
|
40
|
+
hash[name] = X__CLASS_NAME__X.new(name, false)
|
41
|
+
end
|
42
|
+
return hash
|
43
|
+
rescue Cisco::CliError => e
|
44
|
+
# CLI will syntax reject when feature is not enabled
|
45
|
+
raise unless e.clierror =~ /Syntax error/
|
46
|
+
return {}
|
47
|
+
end
|
48
|
+
|
49
|
+
def feature_enabled
|
50
|
+
config_get('X__RESOURCE_NAME__X', 'feature')
|
51
|
+
rescue Cisco::CliError => e
|
52
|
+
# This cmd will syntax reject if feature is not
|
53
|
+
# enabled. Just catch the reject and return false.
|
54
|
+
return false if e.clierror =~ /Syntax error/
|
55
|
+
raise
|
56
|
+
end
|
57
|
+
|
58
|
+
def feature_enable
|
59
|
+
config_set('X__RESOURCE_NAME__X', 'feature', state: '')
|
60
|
+
end
|
61
|
+
|
62
|
+
def feature_disable
|
63
|
+
config_set('X__RESOURCE_NAME__X', 'feature', state: 'no')
|
64
|
+
end
|
65
|
+
|
66
|
+
# Enable feature and create router instance
|
67
|
+
def create
|
68
|
+
feature_enable unless feature_enabled
|
69
|
+
X__RESOURCE_NAME__X_router
|
70
|
+
end
|
71
|
+
|
72
|
+
# Destroy a router instance; disable feature on last instance
|
73
|
+
def destroy
|
74
|
+
ids = config_get('X__RESOURCE_NAME__X', 'router')
|
75
|
+
return if ids.nil?
|
76
|
+
if ids.size == 1
|
77
|
+
feature_disable
|
78
|
+
else
|
79
|
+
X__RESOURCE_NAME__X_router('no')
|
80
|
+
end
|
81
|
+
rescue Cisco::CliError => e
|
82
|
+
# CLI will syntax reject when feature is not enabled
|
83
|
+
raise unless e.clierror =~ /Syntax error/
|
84
|
+
end
|
85
|
+
|
86
|
+
def X__RESOURCE_NAME__X_router(state='')
|
87
|
+
config_set('X__RESOURCE_NAME__X', 'router', name: @name, state: state)
|
88
|
+
end
|
89
|
+
|
90
|
+
# ----------
|
91
|
+
# PROPERTIES
|
92
|
+
# ----------
|
93
|
+
|
94
|
+
# Property methods for boolean property
|
95
|
+
def default_X__PROPERTY_BOOL__X
|
96
|
+
config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X')
|
97
|
+
end
|
98
|
+
|
99
|
+
def X__PROPERTY_BOOL__X
|
100
|
+
config_get('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X', name: @name)
|
101
|
+
end
|
102
|
+
|
103
|
+
def X__PROPERTY_BOOL__X=(state)
|
104
|
+
state = (state ? '' : 'no')
|
105
|
+
config_set('X__RESOURCE_NAME__X', 'X__PROPERTY_BOOL__X',
|
106
|
+
name: @name, state: state)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Property methods for integer property
|
110
|
+
def default_X__PROPERTY_INT__X
|
111
|
+
config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X')
|
112
|
+
end
|
113
|
+
|
114
|
+
def X__PROPERTY_INT__X
|
115
|
+
config_get('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X', name: @name)
|
116
|
+
end
|
117
|
+
|
118
|
+
def X__PROPERTY_INT__X=(val)
|
119
|
+
config_set('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X',
|
120
|
+
name: @name, val: val)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# Copyright (c) 2014-2015 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/router_X__RESOURCE_NAME__X'
|
17
|
+
|
18
|
+
# TestX__CLASS_NAME__X - Minitest for X__CLASS_NAME__X node utility class
|
19
|
+
class TestX__CLASS_NAME__X < CiscoTestCase
|
20
|
+
def setup
|
21
|
+
# setup runs at the beginning of each test
|
22
|
+
super
|
23
|
+
no_feature_X__RESOURCE_NAME__X
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
# teardown runs at the end of each test
|
28
|
+
no_feature_X__RESOURCE_NAME__X
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def no_feature_X__RESOURCE_NAME__X
|
33
|
+
# Turn the feature off for a clean test.
|
34
|
+
config('no feature X__RESOURCE_NAME__X')
|
35
|
+
end
|
36
|
+
|
37
|
+
# TESTS
|
38
|
+
|
39
|
+
def test_router_create_destroy_one
|
40
|
+
id = 'blue'
|
41
|
+
rtr = X__CLASS_NAME__X.new(id)
|
42
|
+
@default_show_command = "show runn | i 'router X__RESOURCE_NAME__X #{id}'"
|
43
|
+
assert_show_match(pattern: /^router X__RESOURCE_NAME__X #{id}$/,
|
44
|
+
msg: "failed to create router X__RESOURCE_NAME__X #{id}")
|
45
|
+
|
46
|
+
rtr.destroy
|
47
|
+
refute_show_match(pattern: /^router X__RESOURCE_NAME__X #{id}$/,
|
48
|
+
msg: "failed to destroy router X__RESOURCE_NAME__X #{id}")
|
49
|
+
|
50
|
+
refute_show_match(command: "show runn | i 'feature X__RESOURCE_NAME__X'",
|
51
|
+
pattern: /^feature X__RESOURCE_NAME__X$/,
|
52
|
+
msg: 'failed to disable feature X__RESOURCE_NAME__X')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_router_create_destroy_multiple
|
56
|
+
id1 = 'blue'
|
57
|
+
rtr1 = X__CLASS_NAME__X.new(id1)
|
58
|
+
id2 = 'red'
|
59
|
+
rtr2 = X__CLASS_NAME__X.new(id2)
|
60
|
+
|
61
|
+
@default_show_command = "show runn | i 'router X__RESOURCE_NAME__X'"
|
62
|
+
|
63
|
+
assert_show_match(pattern: /^router X__RESOURCE_NAME__X #{id1}$/,
|
64
|
+
msg: "failed to create router X__RESOURCE_NAME__X #{id1}")
|
65
|
+
|
66
|
+
assert_show_match(pattern: /^router X__RESOURCE_NAME__X #{id2}$/,
|
67
|
+
msg: "failed to create router X__RESOURCE_NAME__X #{id2}")
|
68
|
+
|
69
|
+
rtr1.destroy
|
70
|
+
refute_show_match(pattern: /^router X__RESOURCE_NAME__X #{id1}$/,
|
71
|
+
msg: "failed to destroy router X__RESOURCE_NAME__X #{id1}")
|
72
|
+
|
73
|
+
rtr2.destroy
|
74
|
+
refute_show_match(pattern: /^router X__RESOURCE_NAME__X #{id2}$/,
|
75
|
+
msg: "failed to destroy router X__RESOURCE_NAME__X #{id2}")
|
76
|
+
|
77
|
+
refute_show_match(command: "show runn | i 'feature X__RESOURCE_NAME__X'",
|
78
|
+
pattern: /^feature X__RESOURCE_NAME__X$/,
|
79
|
+
msg: 'failed to disable feature X__RESOURCE_NAME__X')
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_router_X__PROPERTY_INT__X
|
83
|
+
id = 'blue'
|
84
|
+
rtr = X__CLASS_NAME__X.new(id)
|
85
|
+
val = 5 # This value depends on property bounds
|
86
|
+
rtr.X__PROPERTY_INT__X = val
|
87
|
+
assert_equal(rtr.X__PROPERTY_INT__X, val, "X__PROPERTY_INT__X is not #{val}")
|
88
|
+
|
89
|
+
# Get default value from yaml
|
90
|
+
val = node.config_get_default('X__RESOURCE_NAME__X', 'X__PROPERTY_INT__X')
|
91
|
+
rtr.X__PROPERTY_INT__X = val
|
92
|
+
assert_equal(rtr.X__PROPERTY_INT__X, val, "X__PROPERTY_INT__X is not #{val}")
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_router_X__PROPERTY_BOOL__X
|
96
|
+
id = 'blue'
|
97
|
+
rtr = X__CLASS_NAME__X.new(id)
|
98
|
+
rtr.X__PROPERTY_BOOL__X = true
|
99
|
+
assert(rtr.X__PROPERTY_BOOL__X, 'X__PROPERTY_BOOL__X state is not true')
|
100
|
+
|
101
|
+
rtr.X__PROPERTY_BOOL__X = false
|
102
|
+
refute(rtr.X__PROPERTY_BOOL__X, 'X__PROPERTY_BOOL__X state is not false')
|
103
|
+
end
|
104
|
+
end
|
data/ext/mkrf_conf.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Inspired by:
|
2
|
+
# https://github.com/ruby-debug/ruby-debug-ide/blob/master/ext/mkrf_conf.rb
|
3
|
+
|
4
|
+
# This file needs to be named mkrf_conf.rb
|
5
|
+
# so that rubygems will recognize it as a ruby extension
|
6
|
+
# file and not think it is a C extension file
|
7
|
+
|
8
|
+
require 'rubygems/specification'
|
9
|
+
require 'rubygems/dependency'
|
10
|
+
require 'rubygems/dependency_installer'
|
11
|
+
|
12
|
+
# Load up the rubygems dependency installer to install the dependencies
|
13
|
+
# we need based on the platform we are running under.
|
14
|
+
installer = Gem::DependencyInstaller.new
|
15
|
+
deps = []
|
16
|
+
begin
|
17
|
+
# Try to detect Cisco NX-OS and IOS XR environments
|
18
|
+
os = nil
|
19
|
+
if File.exist?('/etc/os-release')
|
20
|
+
cisco_release_file = nil
|
21
|
+
File.foreach('/etc/os-release') do |line|
|
22
|
+
next unless line[/^CISCO_RELEASE_INFO=/]
|
23
|
+
cisco_release_file = line[/^CISCO_RELEASE_INFO=(.*)$/, 1]
|
24
|
+
break
|
25
|
+
end
|
26
|
+
unless cisco_release_file.nil?
|
27
|
+
File.foreach(cisco_release_file) do |line|
|
28
|
+
next unless line[/^ID=/]
|
29
|
+
os = line[/^ID=(.*)$/, 1]
|
30
|
+
break
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
puts "Detected client OS as '#{os}'" unless os.nil?
|
35
|
+
|
36
|
+
# IOS XR doesn't need net_http_unix
|
37
|
+
os == 'ios_xr' || deps << Gem::Dependency.new('net_http_unix',
|
38
|
+
'~> 0.2', '>= 0.2.1')
|
39
|
+
# NX-OS doesn't need gRPC
|
40
|
+
os == 'nexus' || deps << Gem::Dependency.new('grpc', '~> 1.30.0')
|
41
|
+
|
42
|
+
deps.each do |dep|
|
43
|
+
installed = dep.matching_specs
|
44
|
+
if installed.empty?
|
45
|
+
puts "Installing #{dep}"
|
46
|
+
installed = installer.install dep
|
47
|
+
fail installer.errors[0] unless installer.errors.empty?
|
48
|
+
fail "Did not install #{dep}" if installed.empty?
|
49
|
+
else
|
50
|
+
puts "Found installed gems matching #{dep}:"
|
51
|
+
installed.each { |i| puts " #{i.name} (#{i.version})" }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
rescue StandardError => e
|
55
|
+
puts e
|
56
|
+
puts e.backtrace.join("\n ")
|
57
|
+
exit(1)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Create a dummy Rakefile to report successful 'compilation'
|
61
|
+
f = File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w')
|
62
|
+
f.write("task :default\n")
|
63
|
+
f.close
|
data/lib/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
inherit_from: ../.rubocop.yml
|
2
|
+
|
3
|
+
# Baseline code complexity metrics for the lib/ subdirectory:
|
4
|
+
|
5
|
+
Metrics/AbcSize:
|
6
|
+
Max: 49
|
7
|
+
|
8
|
+
Metrics/CyclomaticComplexity:
|
9
|
+
Max: 23
|
10
|
+
|
11
|
+
Metrics/MethodLength:
|
12
|
+
Max: 50
|
13
|
+
|
14
|
+
Metrics/ParameterLists:
|
15
|
+
Max: 10
|
16
|
+
|
17
|
+
Metrics/PerceivedComplexity:
|
18
|
+
Max: 24
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#
|
2
|
+
# NXAPI implementation of AaaAuthenticationLogin class
|
3
|
+
#
|
4
|
+
# April 2015, Alex Hunsberger
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
|
21
|
+
require_relative 'node_util'
|
22
|
+
|
23
|
+
module Cisco
|
24
|
+
# NXAPI implementation of AAA Authentication Login class
|
25
|
+
class AaaAuthenticationLogin < NodeUtil
|
26
|
+
# There is no "feature aaa" or "aaa new-model" on nxos, and only one
|
27
|
+
# instance which is always available
|
28
|
+
def self.ascii_authentication
|
29
|
+
config_get('aaa_authentication_login', 'ascii_authentication')
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.ascii_authentication=(val)
|
33
|
+
no_cmd = val ? '' : 'no'
|
34
|
+
config_set('aaa_authentication_login',
|
35
|
+
'ascii_authentication', no_cmd)
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.default_ascii_authentication
|
39
|
+
config_get_default('aaa_authentication_login',
|
40
|
+
'ascii_authentication')
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.chap
|
44
|
+
config_get('aaa_authentication_login', 'chap')
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.chap=(val)
|
48
|
+
no_cmd = val ? '' : 'no'
|
49
|
+
config_set('aaa_authentication_login', 'chap', no_cmd)
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.default_chap
|
53
|
+
config_get_default('aaa_authentication_login', 'chap')
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.error_display
|
57
|
+
config_get('aaa_authentication_login', 'error_display')
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.error_display=(val)
|
61
|
+
no_cmd = val ? '' : 'no'
|
62
|
+
config_set('aaa_authentication_login', 'error_display', no_cmd)
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.default_error_display
|
66
|
+
config_get_default('aaa_authentication_login', 'error_display')
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.mschap
|
70
|
+
config_get('aaa_authentication_login', 'mschap')
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.mschap=(val)
|
74
|
+
no_cmd = val ? '' : 'no'
|
75
|
+
config_set('aaa_authentication_login', 'mschap', no_cmd)
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.default_mschap
|
79
|
+
config_get_default('aaa_authentication_login', 'mschap')
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.mschapv2
|
83
|
+
config_get('aaa_authentication_login', 'mschapv2')
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.mschapv2=(val)
|
87
|
+
no_cmd = val ? '' : 'no'
|
88
|
+
config_set('aaa_authentication_login', 'mschapv2', no_cmd)
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.default_mschapv2
|
92
|
+
config_get_default('aaa_authentication_login', 'mschapv2')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
#
|
2
|
+
# NXAPI implementation of AaaAuthenticationLoginService class
|
3
|
+
#
|
4
|
+
# May 2015, Alex Hunsberger
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
|
20
|
+
require_relative 'node_util'
|
21
|
+
|
22
|
+
module Cisco
|
23
|
+
# NXAPI implementation of AAA Authentication Login Service class
|
24
|
+
class AaaAuthenticationLoginService < NodeUtil
|
25
|
+
attr_reader :name
|
26
|
+
|
27
|
+
def initialize(name, create=true)
|
28
|
+
fail TypeError unless name.is_a? String
|
29
|
+
# only console and default are supported currently
|
30
|
+
fail ArgumentError unless %w(console default).include? name
|
31
|
+
@name = name
|
32
|
+
|
33
|
+
# console needs to be explicitly created before it appears in
|
34
|
+
# "show run aaa all" but oddly not before it shows up in
|
35
|
+
# "show aaa authentication"
|
36
|
+
return unless create
|
37
|
+
m = default_method.to_s
|
38
|
+
config_set('aaa_auth_login_service', 'method', '', name, m)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.services
|
42
|
+
servs = {}
|
43
|
+
servs_arr = config_get('aaa_auth_login_service', 'services')
|
44
|
+
unless servs_arr.nil?
|
45
|
+
servs_arr.each do |s|
|
46
|
+
servs[s] = AaaAuthenticationLoginService.new(s, false)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
servs
|
50
|
+
end
|
51
|
+
|
52
|
+
def destroy
|
53
|
+
# must specify exact current config string to unconfigure
|
54
|
+
m = method
|
55
|
+
m_str = m == :unselected ? '' : m.to_s
|
56
|
+
g_str = groups.join(' ')
|
57
|
+
|
58
|
+
if g_str.empty?
|
59
|
+
# cannot remove default local, so do nothing in this case
|
60
|
+
unless m == :local
|
61
|
+
unless node.product_id[/N(3|9)K-F/]
|
62
|
+
# TBD: These 'no' commands currently error on N(3|9)K-F
|
63
|
+
# no aaa authentication login console local
|
64
|
+
# no aaa authentication login console none
|
65
|
+
config_set('aaa_auth_login_service', 'method',
|
66
|
+
'no', @name, m_str)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
else
|
70
|
+
config_set('aaa_auth_login_service', 'groups',
|
71
|
+
'no', @name, g_str, m_str)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# groups aren't retrieved via the usual CLI regex memory method because
|
76
|
+
# there can be an arbitrary number of groups and specifying a repeating
|
77
|
+
# memory regex only captures the last match
|
78
|
+
# ex: aaa authentication login default group group1 group2 group3 none
|
79
|
+
def groups
|
80
|
+
# config_get returns the following format:
|
81
|
+
# [{service:"default",method:"group group1 none "},
|
82
|
+
# {service:"console",method:"local "}]
|
83
|
+
hsh_arr = config_get('aaa_auth_login_service', 'groups')
|
84
|
+
fail 'unable to retrieve aaa groups information' if hsh_arr.empty?
|
85
|
+
hsh = hsh_arr.find { |x| x['service'] == @name }
|
86
|
+
# this should never happen unless @name is invalid
|
87
|
+
fail "no aaa info found for service #{@name}" if hsh.nil?
|
88
|
+
fail "no method found for #{@name} - api or feature change?" unless
|
89
|
+
hsh.key? 'method'
|
90
|
+
# ex: ["group", "group1", "local"] or maybe ["none"]
|
91
|
+
grps = hsh['method'].strip.split
|
92
|
+
return [] if grps.size == 1
|
93
|
+
# remove local, none, group keywords
|
94
|
+
grps -= %w(none local group)
|
95
|
+
grps
|
96
|
+
end
|
97
|
+
|
98
|
+
# default is []
|
99
|
+
def default_groups
|
100
|
+
config_get_default('aaa_auth_login_service', 'groups')
|
101
|
+
end
|
102
|
+
|
103
|
+
def method
|
104
|
+
m = config_get('aaa_auth_login_service', 'method', @name)
|
105
|
+
m.nil? ? :unselected : m.to_sym
|
106
|
+
end
|
107
|
+
|
108
|
+
# default is :local
|
109
|
+
def default_method
|
110
|
+
config_get_default('aaa_auth_login_service', 'method')
|
111
|
+
end
|
112
|
+
|
113
|
+
# groups and method must be set in the same CLI string
|
114
|
+
# aaa authentication login { console | default } /
|
115
|
+
# none | local | group <group1 [group2, ...]> [none]
|
116
|
+
def groups_method_set(grps, m)
|
117
|
+
fail TypeError unless grps.is_a? Array
|
118
|
+
fail TypeError unless grps.all? { |x| x.is_a? String }
|
119
|
+
fail TypeError unless m.is_a? Symbol
|
120
|
+
# only the following 3 are supported (unselected = blank)
|
121
|
+
fail ArgumentError unless [:none, :local, :unselected].include? m
|
122
|
+
|
123
|
+
fail "method 'local' not allowed when groups are configured" if
|
124
|
+
m == :local && !grps.empty?
|
125
|
+
m_str = m == :unselected ? '' : m.to_s
|
126
|
+
g_str = grps.join(' ')
|
127
|
+
|
128
|
+
# config_set depends on whether we're setting groups or not
|
129
|
+
if g_str.empty?
|
130
|
+
config_set('aaa_auth_login_service', 'method',
|
131
|
+
'', @name, m_str)
|
132
|
+
else
|
133
|
+
config_set('aaa_auth_login_service', 'groups',
|
134
|
+
'', @name, g_str, m_str)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|