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,64 @@
|
|
1
|
+
# Syslog facility provider class
|
2
|
+
#
|
3
|
+
# Rick Sherman et al., August 2018
|
4
|
+
#
|
5
|
+
# Copyright (c) 2014-2018 Cisco and/or its affiliates.
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'node_util'
|
20
|
+
|
21
|
+
module Cisco
|
22
|
+
# SyslogFacility - node utility class for Syslog facility severity management
|
23
|
+
class SyslogFacility < NodeUtil
|
24
|
+
attr_reader :facility, :level
|
25
|
+
|
26
|
+
def initialize(opts, instantiate=true)
|
27
|
+
@facility = opts['facility']
|
28
|
+
@level = opts['level']
|
29
|
+
|
30
|
+
create if instantiate
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.facilities
|
34
|
+
keys = %w(facility level)
|
35
|
+
hash = {}
|
36
|
+
facility_key_list = config_get('syslog_facility', 'facility')
|
37
|
+
return hash if facility_key_list.nil?
|
38
|
+
|
39
|
+
facility_key_list.each do |id|
|
40
|
+
hash[id[0]] = SyslogFacility.new(Hash[keys.zip(id)], false)
|
41
|
+
end
|
42
|
+
|
43
|
+
hash
|
44
|
+
end
|
45
|
+
|
46
|
+
def ==(other)
|
47
|
+
facility == other.facility && level == other.level
|
48
|
+
end
|
49
|
+
|
50
|
+
def create
|
51
|
+
config_set('syslog_facility', 'facility', state: '', facility: @facility,
|
52
|
+
level: @level)
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy
|
56
|
+
config_set('syslog_facility', 'facility', state: 'no',
|
57
|
+
facility: @facility, level: @level)
|
58
|
+
end
|
59
|
+
|
60
|
+
def level
|
61
|
+
@level.to_i
|
62
|
+
end
|
63
|
+
end # class
|
64
|
+
end # module
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# Syslog Server provider class
|
2
|
+
#
|
3
|
+
# June 2018
|
4
|
+
# Jonathan Tripathy et al., September 2015
|
5
|
+
#
|
6
|
+
# Copyright (c) 2014-2018 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
|
+
require 'resolv'
|
22
|
+
|
23
|
+
module Cisco
|
24
|
+
# SyslogServer - node utility class for syslog server configuration management
|
25
|
+
class SyslogServer < NodeUtil
|
26
|
+
attr_reader :name, :level, :port, :vrf, :severity_level, :facility
|
27
|
+
|
28
|
+
LEVEL_TO_NUM = { 'emergencies' => 0,
|
29
|
+
'alerts' => 1,
|
30
|
+
'critical' => 2,
|
31
|
+
'error' => 3,
|
32
|
+
'warning' => 4,
|
33
|
+
'notifications' => 5,
|
34
|
+
'info' => 6,
|
35
|
+
'debugging' => 7 }.freeze
|
36
|
+
NUM_TO_LEVEL = LEVEL_TO_NUM.invert.freeze
|
37
|
+
|
38
|
+
def initialize(opts, instantiate=true)
|
39
|
+
@name = opts['name']
|
40
|
+
@level = opts['level'] || opts['severity_level']
|
41
|
+
@port = opts['port']
|
42
|
+
@vrf = opts['vrf']
|
43
|
+
@severity_level = opts['severity_level'] || opts['level']
|
44
|
+
@facility = opts['facility']
|
45
|
+
|
46
|
+
hostname_regex = /^(?=.{1,255}$)[0-9A-Za-z]
|
47
|
+
(?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?
|
48
|
+
(?:\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\.?$/x
|
49
|
+
|
50
|
+
unless @name =~ Resolv::AddressRegex ||
|
51
|
+
@name =~ hostname_regex
|
52
|
+
fail ArgumentError,
|
53
|
+
"Invalid value '#{@name}' \
|
54
|
+
(Must be valid IPv4/IPv6 address or hostname)"
|
55
|
+
end
|
56
|
+
|
57
|
+
create if instantiate
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.syslogservers
|
61
|
+
keys = %w(name level port vrf facility severity_level)
|
62
|
+
hash = {}
|
63
|
+
syslogservers_list = config_get('syslog_server', 'server')
|
64
|
+
return hash if syslogservers_list.nil?
|
65
|
+
|
66
|
+
syslogservers_list.each do |id|
|
67
|
+
value_hash = Hash[keys.zip(id)]
|
68
|
+
value_hash['severity_level'] = value_hash['level']
|
69
|
+
value_hash['vrf'] = 'default' if value_hash['vrf'].nil?
|
70
|
+
value_hash['facility'] = 'local7' if value_hash['facility'].nil?
|
71
|
+
hash[id[0]] = SyslogServer.new(value_hash, false)
|
72
|
+
end
|
73
|
+
|
74
|
+
hash
|
75
|
+
end
|
76
|
+
|
77
|
+
def ==(other)
|
78
|
+
(name == other.name) && (vrf == other.vrf)
|
79
|
+
end
|
80
|
+
|
81
|
+
def create
|
82
|
+
if platform == :ios_xr
|
83
|
+
|
84
|
+
# This provider only support a 1-1 mapping between host and VRF.
|
85
|
+
# Thus, we must remove the other entries on different VRFs.
|
86
|
+
all_vrfs = config_get('syslog_server', 'vrf', name)
|
87
|
+
destroy(all_vrfs) if all_vrfs.is_a?(Array) && all_vrfs.count > 1
|
88
|
+
|
89
|
+
config_set('syslog_server',
|
90
|
+
'server',
|
91
|
+
state: '',
|
92
|
+
ip: @name,
|
93
|
+
level: @level ? "severity #{NUM_TO_LEVEL[@level]}" : '',
|
94
|
+
vrf: @vrf ? "vrf #{@vrf}" : '',
|
95
|
+
)
|
96
|
+
else
|
97
|
+
config_set('syslog_server',
|
98
|
+
'server',
|
99
|
+
state: '',
|
100
|
+
ip: @name,
|
101
|
+
level: @level ? "#{@level}" : '',
|
102
|
+
port: @port ? "port #{@port}" : '',
|
103
|
+
vrf: @vrf ? "use-vrf #{@vrf}" : '',
|
104
|
+
facility: @facility ? "facility #{@facility}" : '',
|
105
|
+
)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def destroy(duplicate_vrfs=[])
|
110
|
+
if platform == :ios_xr
|
111
|
+
if duplicate_vrfs.empty?
|
112
|
+
config_set('syslog_server',
|
113
|
+
'server',
|
114
|
+
state: 'no',
|
115
|
+
ip: @name,
|
116
|
+
level: '',
|
117
|
+
vrf: @vrf ? "vrf #{@vrf}" : '',
|
118
|
+
)
|
119
|
+
else
|
120
|
+
warn("#{name} is configured multiple times on the device" \
|
121
|
+
' (possibly in different VRFs). This is unsupported by this' \
|
122
|
+
' API and the duplicate entries are being deleted.')
|
123
|
+
duplicate_vrfs.each do |dup|
|
124
|
+
config_set('syslog_server',
|
125
|
+
'server',
|
126
|
+
state: 'no',
|
127
|
+
ip: @name,
|
128
|
+
level: '',
|
129
|
+
vrf: "vrf #{dup}",
|
130
|
+
)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
else
|
134
|
+
config_set('syslog_server',
|
135
|
+
'server',
|
136
|
+
state: 'no',
|
137
|
+
ip: @name,
|
138
|
+
level: '',
|
139
|
+
port: '',
|
140
|
+
vrf: '',
|
141
|
+
facility: '',
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end # class
|
146
|
+
end # module
|
@@ -0,0 +1,174 @@
|
|
1
|
+
# Syslog Settings provider class
|
2
|
+
#
|
3
|
+
# August 2018
|
4
|
+
# Jonathan Tripathy et al., September 2015
|
5
|
+
#
|
6
|
+
# Copyright (c) 2014-2018 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
|
+
# SyslogSettings - node utility class for
|
24
|
+
# Syslog Settings configuration management
|
25
|
+
class SyslogSettings < NodeUtil
|
26
|
+
attr_reader :name
|
27
|
+
|
28
|
+
def initialize(name)
|
29
|
+
fail TypeError unless name.is_a?(String)
|
30
|
+
fail ArgumentError,
|
31
|
+
"This provider only accepts an id of 'default'" \
|
32
|
+
unless name.eql?('default')
|
33
|
+
@name = name
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.syslogsettings
|
37
|
+
hash = {}
|
38
|
+
hash['default'] = SyslogSettings.new('default')
|
39
|
+
hash
|
40
|
+
end
|
41
|
+
|
42
|
+
def ==(other)
|
43
|
+
name == other.name
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_console
|
47
|
+
config_get_default('syslog_settings', 'console')
|
48
|
+
end
|
49
|
+
|
50
|
+
def console
|
51
|
+
console = config_get('syslog_settings', 'console')
|
52
|
+
if console.is_a?(Array)
|
53
|
+
console = console[0] == 'no' ? 'unset' : console[1]
|
54
|
+
end
|
55
|
+
console
|
56
|
+
end
|
57
|
+
|
58
|
+
def console=(severity)
|
59
|
+
if severity
|
60
|
+
config_set(
|
61
|
+
'syslog_settings', 'console',
|
62
|
+
state: '', severity: severity)
|
63
|
+
else
|
64
|
+
config_set(
|
65
|
+
'syslog_settings', 'console',
|
66
|
+
state: 'no', severity: '')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def default_monitor
|
71
|
+
config_get_default('syslog_settings', 'monitor')
|
72
|
+
end
|
73
|
+
|
74
|
+
def monitor
|
75
|
+
monitor = config_get('syslog_settings', 'monitor')
|
76
|
+
if monitor.is_a?(Array)
|
77
|
+
monitor = monitor[0] == 'no' ? 'unset' : monitor[1]
|
78
|
+
end
|
79
|
+
monitor
|
80
|
+
end
|
81
|
+
|
82
|
+
def monitor=(severity)
|
83
|
+
if severity
|
84
|
+
config_set(
|
85
|
+
'syslog_settings', 'monitor',
|
86
|
+
state: '', severity: severity)
|
87
|
+
else
|
88
|
+
config_set(
|
89
|
+
'syslog_settings', 'monitor',
|
90
|
+
state: 'no', severity: '')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def default_source_interface
|
95
|
+
config_get_default('syslog_settings', 'source_interface')
|
96
|
+
end
|
97
|
+
|
98
|
+
def source_interface
|
99
|
+
i = config_get('syslog_settings', 'source_interface')
|
100
|
+
i.nil? ? default_source_interface : i.downcase
|
101
|
+
end
|
102
|
+
|
103
|
+
def source_interface=(name)
|
104
|
+
if name
|
105
|
+
config_set(
|
106
|
+
'syslog_settings', 'source_interface',
|
107
|
+
state: '', source_interface: name)
|
108
|
+
else
|
109
|
+
config_set(
|
110
|
+
'syslog_settings', 'source_interface',
|
111
|
+
state: 'no', source_interface: '')
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def timestamp
|
116
|
+
config_get('syslog_settings', 'timestamp')
|
117
|
+
end
|
118
|
+
|
119
|
+
def timestamp=(val)
|
120
|
+
fail TypeError \
|
121
|
+
unless %w(seconds milliseconds).include?(val.to_s)
|
122
|
+
|
123
|
+
# There is no unset version as timestamp has a default value
|
124
|
+
config_set('syslog_settings',
|
125
|
+
'timestamp',
|
126
|
+
state: '',
|
127
|
+
units: val)
|
128
|
+
end
|
129
|
+
|
130
|
+
def logfile_severity_level
|
131
|
+
logfile_severity_level =
|
132
|
+
config_get('syslog_settings', 'logfile_severity_level')
|
133
|
+
if logfile_severity_level.is_a?(Array)
|
134
|
+
if logfile_severity_level[0] == 'no'
|
135
|
+
logfile_severity_level = nil
|
136
|
+
else
|
137
|
+
logfile_severity_level = logfile_severity_level[1]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
logfile_severity_level
|
141
|
+
end
|
142
|
+
|
143
|
+
def logfile_name=(logname, severity, size)
|
144
|
+
if logname
|
145
|
+
config_set(
|
146
|
+
'syslog_settings', 'logfile_name',
|
147
|
+
state: '', logname: logname, severity: severity, size: size)
|
148
|
+
else
|
149
|
+
config_set(
|
150
|
+
'syslog_settings', 'logfile_name',
|
151
|
+
state: 'no', logname: logname, severity: severity, size: size)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def logfile_name
|
156
|
+
logfile_name = config_get('syslog_settings', 'logfile_name')
|
157
|
+
if logfile_name.is_a?(Array)
|
158
|
+
logfile_name = (logfile_name[0] == 'no') ? 'unset' : logfile_name[1]
|
159
|
+
end
|
160
|
+
logfile_name
|
161
|
+
end
|
162
|
+
|
163
|
+
def logfile_size
|
164
|
+
logfile_size = config_get('syslog_settings', 'logfile_size')
|
165
|
+
if logfile_size.is_a?(Array)
|
166
|
+
logfile_size = (logfile_size[0] == 'no') ? nil : logfile_size[1]
|
167
|
+
end
|
168
|
+
logfile_size
|
169
|
+
end
|
170
|
+
|
171
|
+
alias_method :time_stamp_units, :timestamp
|
172
|
+
alias_method :time_stamp_units=, :timestamp=
|
173
|
+
end # class
|
174
|
+
end # module
|
@@ -0,0 +1,137 @@
|
|
1
|
+
# Tacacs Global provider class
|
2
|
+
|
3
|
+
# TP HONEY et al., June 2014-2017
|
4
|
+
|
5
|
+
# Copyright (c) 2014-2017 Cisco and/or its affiliates.
|
6
|
+
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require_relative 'node_util'
|
20
|
+
|
21
|
+
# Tacacs Global configuration management
|
22
|
+
module Cisco
|
23
|
+
# TacacsGlobal - node utility class for
|
24
|
+
class TacacsGlobal < NodeUtil
|
25
|
+
attr_reader :name
|
26
|
+
|
27
|
+
def initialize(name)
|
28
|
+
fail TypeError unless name.is_a?(String)
|
29
|
+
fail ArgumentError,
|
30
|
+
"This provider only accepts an id of 'default'" \
|
31
|
+
unless name.eql?('default')
|
32
|
+
@name = name
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.tacacs_global
|
36
|
+
hash = {}
|
37
|
+
hash['default'] = TacacsGlobal.new('default')
|
38
|
+
hash
|
39
|
+
end
|
40
|
+
|
41
|
+
def ==(other)
|
42
|
+
name == other.name
|
43
|
+
end
|
44
|
+
|
45
|
+
def timeout
|
46
|
+
return nil unless Feature.tacacs_enabled?
|
47
|
+
config_get('tacacs_global', 'timeout')
|
48
|
+
end
|
49
|
+
|
50
|
+
def default_timeout
|
51
|
+
config_get_default('tacacs_global', 'timeout')
|
52
|
+
end
|
53
|
+
|
54
|
+
def timeout=(val)
|
55
|
+
unless val.nil?
|
56
|
+
fail ArgumentError, 'timeout must be an Integer' \
|
57
|
+
unless val.is_a?(Integer)
|
58
|
+
end
|
59
|
+
|
60
|
+
if val.nil?
|
61
|
+
fail ArgumentError, 'timeout cannot be unset if TACACS enabled - ' \
|
62
|
+
"use default value #{default_timeout}" \
|
63
|
+
if Feature.tacacs_enabled?
|
64
|
+
else
|
65
|
+
Feature.tacacs_enable
|
66
|
+
config_set('tacacs_global',
|
67
|
+
'timeout',
|
68
|
+
state: '',
|
69
|
+
timeout: val)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def key_format
|
74
|
+
match = config_get('tacacs_global', 'key_format')
|
75
|
+
match.nil? ? TACACS_GLOBAL_ENC_UNKNOWN : match[0].to_i
|
76
|
+
end
|
77
|
+
|
78
|
+
def key
|
79
|
+
return nil unless Feature.tacacs_enabled?
|
80
|
+
str = config_get('tacacs_global', 'key')
|
81
|
+
return TacacsGlobal.default_key if str.empty?
|
82
|
+
str[1].strip.gsub(/\"/, '')
|
83
|
+
end
|
84
|
+
|
85
|
+
# Get default encryption password
|
86
|
+
def self.default_key
|
87
|
+
config_get_default('tacacs_global', 'key')
|
88
|
+
end
|
89
|
+
|
90
|
+
def encryption_key_set(key_format, key)
|
91
|
+
# If we get an empty key - remove default if configured
|
92
|
+
if key.nil? || key.to_s.empty?
|
93
|
+
key = self.key
|
94
|
+
return if key.empty?
|
95
|
+
key_format = self.key_format
|
96
|
+
config_set('tacacs_server', 'encryption', state: 'no',
|
97
|
+
option: key_format, key: key)
|
98
|
+
else
|
99
|
+
Feature.tacacs_enable
|
100
|
+
key = Utils.add_quotes(key)
|
101
|
+
if key_format.nil? || key_format.to_s.empty?
|
102
|
+
config_set('tacacs_server', 'encryption', state: '', option: '',
|
103
|
+
key: key)
|
104
|
+
else
|
105
|
+
config_set('tacacs_server', 'encryption', state: '',
|
106
|
+
option: key_format, key: key)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Get default source interface
|
112
|
+
def default_source_interface
|
113
|
+
config_get_default('tacacs_global', 'source_interface')
|
114
|
+
end
|
115
|
+
|
116
|
+
# Set source interface
|
117
|
+
def source_interface=(name)
|
118
|
+
if name
|
119
|
+
Feature.tacacs_enable
|
120
|
+
config_set(
|
121
|
+
'tacacs_global', 'source_interface',
|
122
|
+
state: '', source_interface: name)
|
123
|
+
else
|
124
|
+
config_set(
|
125
|
+
'tacacs_global', 'source_interface',
|
126
|
+
state: 'no', source_interface: '')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# Get source interface
|
131
|
+
def source_interface
|
132
|
+
return nil unless Feature.tacacs_enabled?
|
133
|
+
i = config_get('tacacs_global', 'source_interface')
|
134
|
+
i.nil? ? default_source_interface : i.downcase
|
135
|
+
end
|
136
|
+
end # class
|
137
|
+
end # module
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# Mike Wiebe, January 2015
|
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_relative 'node_util'
|
18
|
+
|
19
|
+
# Add some TACACS+ server related constants to the Cisco namespace
|
20
|
+
module Cisco
|
21
|
+
TACACS_SERVER_ENC_NONE = 0
|
22
|
+
TACACS_SERVER_ENC_CISCO_TYPE_7 = 7
|
23
|
+
TACACS_SERVER_ENC_UNKNOWN = 8
|
24
|
+
|
25
|
+
# TacacsServer - node utility class for TACACS+ server config management
|
26
|
+
class TacacsServer < NodeUtil
|
27
|
+
def initialize(instantiate=true)
|
28
|
+
enable if instantiate && !TacacsServer.enabled
|
29
|
+
end
|
30
|
+
|
31
|
+
# Check feature enablement
|
32
|
+
def self.enabled
|
33
|
+
Feature.tacacs_enabled?
|
34
|
+
end
|
35
|
+
|
36
|
+
# Enable tacacs_server feature
|
37
|
+
def enable
|
38
|
+
config_set('tacacs_server', 'feature', '') unless platform == :ios_xr
|
39
|
+
end
|
40
|
+
|
41
|
+
# Disable tacacs_server feature
|
42
|
+
def destroy
|
43
|
+
config_set('tacacs_server', 'feature', 'no') unless platform == :ios_xr
|
44
|
+
end
|
45
|
+
|
46
|
+
# --------------------
|
47
|
+
# Getters and Setters
|
48
|
+
# --------------------
|
49
|
+
|
50
|
+
# Set timeout
|
51
|
+
def timeout=(timeout)
|
52
|
+
# 'no tacacs timeout' will fail.
|
53
|
+
# Just set it to the requested timeout value.
|
54
|
+
config_set('tacacs_server', 'timeout', state: '', timeout: timeout)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Get timeout
|
58
|
+
def timeout
|
59
|
+
config_get('tacacs_server', 'timeout')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Get default timeout
|
63
|
+
def self.default_timeout
|
64
|
+
config_get_default('tacacs_server', 'timeout')
|
65
|
+
end
|
66
|
+
|
67
|
+
# Set deadtime
|
68
|
+
def deadtime=(deadtime)
|
69
|
+
# 'no tacacs deadtime' will fail.
|
70
|
+
# Just set it to the requested timeout value.
|
71
|
+
config_set('tacacs_server', 'deadtime', '', deadtime)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Get deadtime
|
75
|
+
def deadtime
|
76
|
+
config_get('tacacs_server', 'deadtime')
|
77
|
+
end
|
78
|
+
|
79
|
+
# Get default deadtime
|
80
|
+
def self.default_deadtime
|
81
|
+
config_get_default('tacacs_server', 'deadtime')
|
82
|
+
end
|
83
|
+
|
84
|
+
# Set directed_request
|
85
|
+
def directed_request=(state)
|
86
|
+
fail TypeError unless state == true || state == false
|
87
|
+
if state == TacacsServer.default_directed_request
|
88
|
+
config_set('tacacs_server', 'directed_request', 'no')
|
89
|
+
else
|
90
|
+
config_set('tacacs_server', 'directed_request', '')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Check if directed request is enabled
|
95
|
+
def directed_request?
|
96
|
+
config_get('tacacs_server', 'directed_request')
|
97
|
+
end
|
98
|
+
|
99
|
+
# Get default directed_request
|
100
|
+
def self.default_directed_request
|
101
|
+
config_get_default('tacacs_server', 'directed_request')
|
102
|
+
end
|
103
|
+
|
104
|
+
# Set source interface
|
105
|
+
def source_interface=(name)
|
106
|
+
fail TypeError unless name.is_a? String
|
107
|
+
if name.empty?
|
108
|
+
config_set('tacacs_server', 'source_interface', 'no', '')
|
109
|
+
else
|
110
|
+
config_set('tacacs_server', 'source_interface', '', name)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# Get source interface
|
115
|
+
def source_interface
|
116
|
+
# Sample output
|
117
|
+
# ip tacacs source-interface Ethernet1/1
|
118
|
+
# no tacacs source-interface
|
119
|
+
match = config_get('tacacs_server', 'source_interface')
|
120
|
+
return TacacsServer.default_source_interface if match.empty?
|
121
|
+
# match_data will contain one of the following
|
122
|
+
# [nil, " Ethernet1/1"] or ["no", nil]
|
123
|
+
match[0] == 'no' ? TacacsServer.default_source_interface : match[1]
|
124
|
+
end
|
125
|
+
|
126
|
+
# Get default source interface
|
127
|
+
def self.default_source_interface
|
128
|
+
config_get_default('tacacs_server', 'source_interface')
|
129
|
+
end
|
130
|
+
|
131
|
+
# Get encryption type used for the key
|
132
|
+
def encryption_type
|
133
|
+
match = config_get('tacacs_server', 'encryption_type')
|
134
|
+
match.nil? ? TACACS_SERVER_ENC_UNKNOWN : match[0].to_i
|
135
|
+
end
|
136
|
+
|
137
|
+
# Get default encryption type
|
138
|
+
def self.default_encryption_type
|
139
|
+
config_get_default('tacacs_server', 'encryption_type')
|
140
|
+
end
|
141
|
+
|
142
|
+
# Get encryption password
|
143
|
+
def encryption_password
|
144
|
+
str = config_get('tacacs_server', 'encryption_password')
|
145
|
+
return TacacsServer.default_encryption_password if str.empty?
|
146
|
+
str[1].strip
|
147
|
+
end
|
148
|
+
|
149
|
+
# Get default encryption password
|
150
|
+
def self.default_encryption_password
|
151
|
+
config_get_default('tacacs_server', 'encryption_password')
|
152
|
+
end
|
153
|
+
|
154
|
+
# Set encryption type and password
|
155
|
+
def encryption_key_set(enctype, password)
|
156
|
+
password = Utils.add_quotes(password)
|
157
|
+
# if enctype is TACACS_SERVER_ENC_UNKNOWN, we will unset the key
|
158
|
+
if enctype == TACACS_SERVER_ENC_UNKNOWN
|
159
|
+
# if current encryption type is not TACACS_SERVER_ENC_UNKNOWN, we
|
160
|
+
# need to unset it. Otherwise the box is not configured with key, we
|
161
|
+
# don't need to do anything
|
162
|
+
if encryption_type != TACACS_SERVER_ENC_UNKNOWN
|
163
|
+
config_set('tacacs_server', 'encryption', state: 'no',
|
164
|
+
option: encryption_type,
|
165
|
+
key: encryption_password)
|
166
|
+
end
|
167
|
+
else
|
168
|
+
config_set('tacacs_server', 'encryption', state: '', option: enctype,
|
169
|
+
key: password)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|