cisco_node_utils_mgx 2.1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +96 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +676 -0
- data/CONTRIBUTING.md +43 -0
- data/Gemfile +10 -0
- data/LICENSE +201 -0
- data/README.md +246 -0
- data/Rakefile +44 -0
- data/SUPPORT.md +3 -0
- data/bin/.rubocop.yml +18 -0
- data/bin/check_metric_limits.rb +109 -0
- data/bin/git/hooks/commit-msg/enforce_style +89 -0
- data/bin/git/hooks/hook_lib +115 -0
- data/bin/git/hooks/hooks-wrapper +38 -0
- data/bin/git/hooks/post-flow-hotfix-start/update-version +24 -0
- data/bin/git/hooks/post-flow-release-finish/update-version +29 -0
- data/bin/git/hooks/post-flow-release-start/update-version +19 -0
- data/bin/git/hooks/post-merge/update-hooks +6 -0
- data/bin/git/hooks/post-rewrite/update-hooks +6 -0
- data/bin/git/hooks/pre-commit/check_unstaged_changes +18 -0
- data/bin/git/hooks/pre-commit/rubocop +25 -0
- data/bin/git/hooks/pre-commit/validate-diffs +45 -0
- data/bin/git/hooks/pre-commit/validate-yaml +18 -0
- data/bin/git/hooks/pre-push/check-changelog +24 -0
- data/bin/git/hooks/pre-push/rubocop +7 -0
- data/bin/git/update-hooks +123 -0
- data/bin/show_running_yang.rb +233 -0
- data/cisco_node_utils.gemspec +41 -0
- data/docs/README-develop-best-practices.md +521 -0
- data/docs/README-develop-node-utils-APIs.md +570 -0
- data/docs/README-maintainers.md +77 -0
- data/docs/README-test-execution.md +57 -0
- data/docs/README-utilities.md +14 -0
- data/docs/agent_files.png +0 -0
- data/docs/cisco_node_utils.yaml.example +36 -0
- data/docs/template-router.rb +123 -0
- data/docs/template-test_router.rb +104 -0
- data/ext/mkrf_conf.rb +63 -0
- data/lib/.rubocop.yml +18 -0
- data/lib/cisco_node_utils/aaa_authentication_login.rb +95 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +138 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +156 -0
- data/lib/cisco_node_utils/ace.rb +467 -0
- data/lib/cisco_node_utils/acl.rb +101 -0
- data/lib/cisco_node_utils/banner.rb +63 -0
- data/lib/cisco_node_utils/bfd_global.rb +305 -0
- data/lib/cisco_node_utils/bgp.rb +988 -0
- data/lib/cisco_node_utils/bgp_af.rb +545 -0
- data/lib/cisco_node_utils/bgp_af_aggr_addr.rb +207 -0
- data/lib/cisco_node_utils/bgp_neighbor.rb +527 -0
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +780 -0
- data/lib/cisco_node_utils/bridge_domain.rb +178 -0
- data/lib/cisco_node_utils/bridge_domain_vni.rb +206 -0
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +444 -0
- data/lib/cisco_node_utils/client/client.rb +238 -0
- data/lib/cisco_node_utils/client/grpc/client.rb +395 -0
- data/lib/cisco_node_utils/client/grpc/ems.proto +148 -0
- data/lib/cisco_node_utils/client/grpc/ems.rb +111 -0
- data/lib/cisco_node_utils/client/grpc/ems_services.rb +49 -0
- data/lib/cisco_node_utils/client/grpc.rb +33 -0
- data/lib/cisco_node_utils/client/nxapi/client.rb +368 -0
- data/lib/cisco_node_utils/client/nxapi.rb +31 -0
- data/lib/cisco_node_utils/client/utils.rb +180 -0
- data/lib/cisco_node_utils/client.rb +35 -0
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +590 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/banner.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/bfd_global.yaml +117 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +383 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +223 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af_aa.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +174 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +236 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/bridge_domain_vni.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/dhcp_relay_global.yaml +128 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/encapsulation.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multicast.yaml +12 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_multisite.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_stormcontrol.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +48 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +183 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +126 -0
- data/lib/cisco_node_utils/cmd_ref/hostname.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/hsrp_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +781 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/interface_evpn_multisite.yaml +17 -0
- data/lib/cisco_node_utils/cmd_ref/interface_hsrp_group.yaml +120 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +112 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +87 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/ip_multicast.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/itd_device_group.yaml +83 -0
- data/lib/cisco_node_utils/cmd_ref/itd_service.yaml +119 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +24 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_auth_key.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +27 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/object_group.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/ospf_area_vlink.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +100 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +19 -0
- data/lib/cisco_node_utils/cmd_ref/route_map.yaml +601 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +84 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +81 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +91 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +57 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/span_session.yaml +65 -0
- data/lib/cisco_node_utils/cmd_ref/stp_global.yaml +235 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_facility.yaml +10 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_global.yaml +37 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +63 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/upgrade.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +52 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +8 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +106 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +233 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +86 -0
- data/lib/cisco_node_utils/cmd_ref/vrf_af.yaml +139 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +114 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +71 -0
- data/lib/cisco_node_utils/cmd_ref/yang.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +68 -0
- data/lib/cisco_node_utils/command_reference.rb +724 -0
- data/lib/cisco_node_utils/configparser_lib.rb +195 -0
- data/lib/cisco_node_utils/constants.rb +40 -0
- data/lib/cisco_node_utils/dhcp_relay_global.rb +302 -0
- data/lib/cisco_node_utils/dns_domain.rb +93 -0
- data/lib/cisco_node_utils/domain_name.rb +82 -0
- data/lib/cisco_node_utils/encapsulation.rb +112 -0
- data/lib/cisco_node_utils/environment.rb +110 -0
- data/lib/cisco_node_utils/evpn_multicast.rb +66 -0
- data/lib/cisco_node_utils/evpn_multisite.rb +96 -0
- data/lib/cisco_node_utils/evpn_stormcontrol.rb +84 -0
- data/lib/cisco_node_utils/evpn_vni.rb +159 -0
- data/lib/cisco_node_utils/exceptions.rb +140 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +405 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +137 -0
- data/lib/cisco_node_utils/feature.rb +377 -0
- data/lib/cisco_node_utils/hostname.rb +62 -0
- data/lib/cisco_node_utils/hsrp_global.rb +97 -0
- data/lib/cisco_node_utils/interface.rb +2128 -0
- data/lib/cisco_node_utils/interface_channel_group.rb +142 -0
- data/lib/cisco_node_utils/interface_evpn_multisite.rb +72 -0
- data/lib/cisco_node_utils/interface_hsrp_group.rb +557 -0
- data/lib/cisco_node_utils/interface_ospf.rb +378 -0
- data/lib/cisco_node_utils/interface_portchannel.rb +180 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/ip_multicast.rb +90 -0
- data/lib/cisco_node_utils/itd_device_group.rb +228 -0
- data/lib/cisco_node_utils/itd_device_group_node.rb +144 -0
- data/lib/cisco_node_utils/itd_service.rb +511 -0
- data/lib/cisco_node_utils/logger.rb +78 -0
- data/lib/cisco_node_utils/name_server.rb +64 -0
- data/lib/cisco_node_utils/node.rb +443 -0
- data/lib/cisco_node_utils/node_util.rb +111 -0
- data/lib/cisco_node_utils/ntp_auth_key.rb +67 -0
- data/lib/cisco_node_utils/ntp_config.rb +83 -0
- data/lib/cisco_node_utils/ntp_server.rb +86 -0
- data/lib/cisco_node_utils/object_group.rb +75 -0
- data/lib/cisco_node_utils/object_group_entry.rb +143 -0
- data/lib/cisco_node_utils/overlay_global.rb +142 -0
- data/lib/cisco_node_utils/pim.rb +131 -0
- data/lib/cisco_node_utils/pim_group_list.rb +109 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +103 -0
- data/lib/cisco_node_utils/platform.rb +217 -0
- data/lib/cisco_node_utils/portchannel_global.rb +347 -0
- data/lib/cisco_node_utils/radius_global.rb +165 -0
- data/lib/cisco_node_utils/radius_server.rb +421 -0
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/route_map.rb +2540 -0
- data/lib/cisco_node_utils/router_ospf.rb +77 -0
- data/lib/cisco_node_utils/router_ospf_area.rb +416 -0
- data/lib/cisco_node_utils/router_ospf_area_vlink.rb +313 -0
- data/lib/cisco_node_utils/router_ospf_vrf.rb +342 -0
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +176 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +109 -0
- data/lib/cisco_node_utils/snmpgroup.rb +54 -0
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +132 -0
- data/lib/cisco_node_utils/snmpuser.rb +403 -0
- data/lib/cisco_node_utils/span_session.rb +149 -0
- data/lib/cisco_node_utils/stp_global.rb +676 -0
- data/lib/cisco_node_utils/syslog_facility.rb +64 -0
- data/lib/cisco_node_utils/syslog_server.rb +146 -0
- data/lib/cisco_node_utils/syslog_settings.rb +174 -0
- data/lib/cisco_node_utils/tacacs_global.rb +137 -0
- data/lib/cisco_node_utils/tacacs_server.rb +173 -0
- data/lib/cisco_node_utils/tacacs_server_group.rb +149 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +216 -0
- data/lib/cisco_node_utils/upgrade.rb +122 -0
- data/lib/cisco_node_utils/vdc.rb +118 -0
- data/lib/cisco_node_utils/version.rb +21 -0
- data/lib/cisco_node_utils/vlan.rb +301 -0
- data/lib/cisco_node_utils/vpc.rb +466 -0
- data/lib/cisco_node_utils/vrf.rb +192 -0
- data/lib/cisco_node_utils/vrf_af.rb +327 -0
- data/lib/cisco_node_utils/vtp.rb +125 -0
- data/lib/cisco_node_utils/vxlan_vtep.rb +286 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +331 -0
- data/lib/cisco_node_utils/yang.rb +160 -0
- data/lib/cisco_node_utils/yum.rb +213 -0
- data/lib/cisco_node_utils.rb +21 -0
- data/lib/minitest/environment_plugin.rb +31 -0
- data/lib/minitest/log_level_plugin.rb +41 -0
- data/spec/client_spec.rb +7 -0
- data/spec/environment_spec.rb +384 -0
- data/spec/grpc_client_spec.rb +23 -0
- data/spec/isolate/all_clients_spec.rb +9 -0
- data/spec/isolate/grpc_only_spec.rb +16 -0
- data/spec/isolate/no_clients_spec.rb +26 -0
- data/spec/isolate/nxapi_only_spec.rb +16 -0
- data/spec/nxapi_client_spec.rb +42 -0
- data/spec/schema.yaml +82 -0
- data/spec/shared_examples_for_clients.rb +14 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/whitespace_spec.rb +10 -0
- data/spec/yaml_spec.rb +42 -0
- data/tests/.rubocop.yml +18 -0
- data/tests/CSCuxdublin-1.0.0-7.0.3.I3.1.lib32_n9000.rpm +0 -0
- data/tests/basetest.rb +243 -0
- data/tests/ciscotest.rb +577 -0
- data/tests/cmd_config.yaml +75 -0
- data/tests/cmd_config_invalid.yaml +16 -0
- data/tests/n9000_sample-1.0.0-7.0.3.x86_64.rpm +0 -0
- data/tests/noop.rb +7 -0
- data/tests/platform_info.rb +63 -0
- data/tests/tacacs_server.yaml.example +6 -0
- data/tests/test_aaa_authentication_login.rb +243 -0
- data/tests/test_aaa_authentication_login_service.rb +761 -0
- data/tests/test_aaa_authorization_service.rb +874 -0
- data/tests/test_ace.rb +304 -0
- data/tests/test_acl.rb +185 -0
- data/tests/test_banner.rb +85 -0
- data/tests/test_bfd_global.rb +272 -0
- data/tests/test_bgp_af.rb +875 -0
- data/tests/test_bgp_af_aa.rb +108 -0
- data/tests/test_bgp_neighbor.rb +596 -0
- data/tests/test_bgp_neighbor_af.rb +781 -0
- data/tests/test_bridge_domain.rb +198 -0
- data/tests/test_bridge_domain_vni.rb +109 -0
- data/tests/test_client_utils.rb +111 -0
- data/tests/test_cmn_utils.rb +76 -0
- data/tests/test_command_config.rb +206 -0
- data/tests/test_command_reference.rb +669 -0
- data/tests/test_dhcp_relay_global.rb +286 -0
- data/tests/test_dns_domain.rb +123 -0
- data/tests/test_domain_name.rb +96 -0
- data/tests/test_encapsulation.rb +75 -0
- data/tests/test_evpn_multicast.rb +65 -0
- data/tests/test_evpn_multisite.rb +70 -0
- data/tests/test_evpn_stormcontrol.rb +56 -0
- data/tests/test_evpn_vni.rb +131 -0
- data/tests/test_fabricpath_global.rb +246 -0
- data/tests/test_fabricpath_topology.rb +77 -0
- data/tests/test_feature.rb +272 -0
- data/tests/test_grpc.rb +166 -0
- data/tests/test_hostname.rb +64 -0
- data/tests/test_hsrp_global.rb +79 -0
- data/tests/test_interface.rb +1958 -0
- data/tests/test_interface_bdi.rb +80 -0
- data/tests/test_interface_channel_group.rb +131 -0
- data/tests/test_interface_evpn_multisite.rb +94 -0
- data/tests/test_interface_hsrp.rb +134 -0
- data/tests/test_interface_hsrp_group.rb +570 -0
- data/tests/test_interface_ospf.rb +820 -0
- data/tests/test_interface_portchannel.rb +135 -0
- data/tests/test_interface_private_vlan.rb +365 -0
- data/tests/test_interface_service_vni.rb +203 -0
- data/tests/test_interface_svi.rb +210 -0
- data/tests/test_interface_switchport.rb +468 -0
- data/tests/test_ip_multicast.rb +80 -0
- data/tests/test_itd_device_group.rb +145 -0
- data/tests/test_itd_device_group_node.rb +199 -0
- data/tests/test_itd_service.rb +314 -0
- data/tests/test_logger.rb +43 -0
- data/tests/test_name_server.rb +94 -0
- data/tests/test_node.rb +50 -0
- data/tests/test_node_ext.rb +406 -0
- data/tests/test_node_util.rb +119 -0
- data/tests/test_ntp_auth_key.rb +77 -0
- data/tests/test_ntp_config.rb +100 -0
- data/tests/test_ntp_server.rb +146 -0
- data/tests/test_nxapi.rb +236 -0
- data/tests/test_object_group.rb +122 -0
- data/tests/test_overlay_global.rb +108 -0
- data/tests/test_pim.rb +203 -0
- data/tests/test_pim_group_list.rb +147 -0
- data/tests/test_pim_rp_address.rb +155 -0
- data/tests/test_platform.rb +254 -0
- data/tests/test_portchannel_global.rb +322 -0
- data/tests/test_radius_global.rb +108 -0
- data/tests/test_radius_server.rb +377 -0
- data/tests/test_radius_server_group.rb +151 -0
- data/tests/test_route_map.rb +1479 -0
- data/tests/test_router_bgp.rb +1325 -0
- data/tests/test_router_ospf.rb +56 -0
- data/tests/test_router_ospf_area.rb +433 -0
- data/tests/test_router_ospf_area_vlink.rb +298 -0
- data/tests/test_router_ospf_vrf.rb +690 -0
- data/tests/test_snmp_notification_receiver.rb +169 -0
- data/tests/test_snmpcommunity.rb +422 -0
- data/tests/test_snmpgroup.rb +71 -0
- data/tests/test_snmpnotification.rb +91 -0
- data/tests/test_snmpserver.rb +251 -0
- data/tests/test_snmpuser.rb +666 -0
- data/tests/test_span_session.rb +155 -0
- data/tests/test_stp_global.rb +575 -0
- data/tests/test_syslog_facility.rb +80 -0
- data/tests/test_syslog_server.rb +119 -0
- data/tests/test_syslog_settings.rb +123 -0
- data/tests/test_tacacs_global.rb +109 -0
- data/tests/test_tacacs_server.rb +436 -0
- data/tests/test_tacacs_server_group.rb +434 -0
- data/tests/test_tacacs_server_host.rb +427 -0
- data/tests/test_upgrade.rb +105 -0
- data/tests/test_vdc.rb +64 -0
- data/tests/test_vlan.rb +386 -0
- data/tests/test_vlan_private.rb +656 -0
- data/tests/test_vpc.rb +548 -0
- data/tests/test_vrf.rb +248 -0
- data/tests/test_vrf_af.rb +288 -0
- data/tests/test_vtp.rb +278 -0
- data/tests/test_vxlan_vtep.rb +327 -0
- data/tests/test_vxlan_vtep_vni.rb +326 -0
- data/tests/test_yang.rb +369 -0
- data/tests/test_yum.rb +109 -0
- data/tests/upgrade_info.yaml.example +3 -0
- data/tests/yum_package.yaml +94 -0
- metadata +534 -0
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
#
|
|
2
|
+
# October 2016, Sai Chintalapudi
|
|
3
|
+
#
|
|
4
|
+
# Copyright (c) 2016-2018 Cisco and/or its affiliates.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
# you may not use this file except in compliance with the License.
|
|
8
|
+
# You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
# See the License for the specific language governing permissions and
|
|
16
|
+
# limitations under the License.
|
|
17
|
+
|
|
18
|
+
require_relative 'node_util'
|
|
19
|
+
require_relative 'interface'
|
|
20
|
+
|
|
21
|
+
module Cisco
|
|
22
|
+
# node_utils class for interface_hsrp_group
|
|
23
|
+
class InterfaceHsrpGroup < NodeUtil
|
|
24
|
+
attr_reader :name, :group, :iptype
|
|
25
|
+
|
|
26
|
+
def initialize(interface, group_id, ip_type, instantiate=true)
|
|
27
|
+
fail TypeError unless interface.is_a?(String)
|
|
28
|
+
fail ArgumentError unless ip_type[/ipv4|ipv6/]
|
|
29
|
+
@name = interface.downcase
|
|
30
|
+
@group = group_id
|
|
31
|
+
@iptype = ip_type
|
|
32
|
+
|
|
33
|
+
set_args_keys_default
|
|
34
|
+
create if instantiate
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.groups
|
|
38
|
+
hash = {}
|
|
39
|
+
return hash unless Feature.hsrp_enabled?
|
|
40
|
+
all_hsrp = config_get('interface_hsrp_group', 'all_hsrp')
|
|
41
|
+
interfaces = all_hsrp.scan(/interface (.*)/).flatten
|
|
42
|
+
interfaces.each do|intf|
|
|
43
|
+
groups = config_get('interface_hsrp_group', 'groups', name: intf)
|
|
44
|
+
next if groups.nil?
|
|
45
|
+
hash[intf] = {}
|
|
46
|
+
groups.each do |id, type|
|
|
47
|
+
iptype = type
|
|
48
|
+
iptype = 'ipv4' if type.nil?
|
|
49
|
+
hash[intf][id] ||= {}
|
|
50
|
+
hash[intf][id][iptype] =
|
|
51
|
+
InterfaceHsrpGroup.new(intf, id, iptype, false)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
hash
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Helper method to delete @set_args hash keys
|
|
58
|
+
def set_args_keys_default
|
|
59
|
+
@set_args = { name: @name, group: @group, iptype: iptype }
|
|
60
|
+
@set_args[:iptype] = '' if @iptype == 'ipv4'
|
|
61
|
+
@get_args = @set_args
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# rubocop:disable Style/AccessorMethodName
|
|
65
|
+
def set_args_keys(hash={})
|
|
66
|
+
set_args_keys_default
|
|
67
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Create one interface hsrp group instance
|
|
71
|
+
def create
|
|
72
|
+
Feature.hsrp_enable
|
|
73
|
+
set_args_keys(state: '')
|
|
74
|
+
config_set('interface_hsrp_group', 'groups', @set_args)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def destroy
|
|
78
|
+
return unless Feature.hsrp_enabled?
|
|
79
|
+
# for ipv4 types, 'no' cmd needs the type to be specified
|
|
80
|
+
# explicitly if another ipv6 group exists with the same
|
|
81
|
+
# group id
|
|
82
|
+
set_args_keys(state: 'no', iptype: @iptype)
|
|
83
|
+
config_set('interface_hsrp_group', 'groups', @set_args)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
########################################################
|
|
87
|
+
# PROPERTIES #
|
|
88
|
+
########################################################
|
|
89
|
+
|
|
90
|
+
# This CLI is very complicated, it can take many forms
|
|
91
|
+
# authentication text Test
|
|
92
|
+
# authentication md5 key-chain abcd
|
|
93
|
+
# authentication md5 key-string 7 => 7 is key-string
|
|
94
|
+
# authentication md5 key-string 7 12345678901234567890
|
|
95
|
+
# authentication md5 key-string ABCXYZ => enctype is 0
|
|
96
|
+
# authentication md5 key-string ABCXYZ compatibility
|
|
97
|
+
# authentication md5 key-string ABCXYZ compatibility timeout 22
|
|
98
|
+
# authentication md5 key-string ABCXYZ timeout 22
|
|
99
|
+
# authentication md5 key-string 7 12345678901234567890 timeout 22
|
|
100
|
+
# authentication md5 key-string 7 123456789 compatibility timeout 22
|
|
101
|
+
# if passwd
|
|
102
|
+
# req auth_enc_type
|
|
103
|
+
# if encrypted
|
|
104
|
+
# req authentication_key_type, authentication_enc_type
|
|
105
|
+
# if key-string
|
|
106
|
+
# optional compat and timeout
|
|
107
|
+
def authentication
|
|
108
|
+
hash = {}
|
|
109
|
+
hash[:auth_type] = default_authentication_auth_type
|
|
110
|
+
hash[:key_type] = default_authentication_key_type
|
|
111
|
+
hash[:enc_type] = default_authentication_enc_type
|
|
112
|
+
hash[:password] = default_authentication_string
|
|
113
|
+
hash[:compat] = default_authentication_compatibility
|
|
114
|
+
hash[:timeout] = default_authentication_timeout
|
|
115
|
+
str = config_get('interface_hsrp_group', 'authentication', @get_args)
|
|
116
|
+
return hash if str.nil?
|
|
117
|
+
regexp = Regexp.new('(?<authtype>text|md5)'\
|
|
118
|
+
' *(?<keytype>key-chain|key-string|\S+)'\
|
|
119
|
+
' *(?<enctype>7|\S+)?'\
|
|
120
|
+
' *(?<keystring>\S+)?')
|
|
121
|
+
params = regexp.match(str)
|
|
122
|
+
if params[:authtype] == 'text'
|
|
123
|
+
hash[:password] = params[:keytype]
|
|
124
|
+
else
|
|
125
|
+
hash[:auth_type] = 'md5'
|
|
126
|
+
hash[:key_type] = params[:keytype]
|
|
127
|
+
if hash[:key_type] == 'key-chain'
|
|
128
|
+
hash[:password] = params[:enctype]
|
|
129
|
+
else
|
|
130
|
+
if params[:enctype] == '7' && params[:keystring].nil?
|
|
131
|
+
hash[:password] = '7'
|
|
132
|
+
elsif params[:enctype] == '7' && !params[:keystring].nil?
|
|
133
|
+
hash[:enc_type] = '7'
|
|
134
|
+
hash[:password] = params[:keystring]
|
|
135
|
+
else
|
|
136
|
+
hash[:password] = params[:enctype]
|
|
137
|
+
end
|
|
138
|
+
# get rid of password from str just in case the password is
|
|
139
|
+
# compatibility or timeout
|
|
140
|
+
str.sub!(hash[:password], '')
|
|
141
|
+
hash[:compat] = true if str.include?('compatibility')
|
|
142
|
+
hash[:timeout] = str.split.last.to_i if str.include?('timeout')
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
hash
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def authentication_auth_type
|
|
149
|
+
authentication[:auth_type]
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def authentication_auth_type=(val)
|
|
153
|
+
@set_args[:authtype] = val
|
|
154
|
+
@set_args[:authtype] = 'text' if val.to_s == 'cleartext'
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def default_authentication_auth_type
|
|
158
|
+
config_get_default('interface_hsrp_group', 'authentication_auth_type')
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def authentication_key_type
|
|
162
|
+
authentication[:key_type]
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def authentication_key_type=(val)
|
|
166
|
+
@set_args[:keytype] = val.to_s
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def default_authentication_key_type
|
|
170
|
+
config_get_default('interface_hsrp_group', 'authentication_key_type')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def authentication_enc_type
|
|
174
|
+
authentication[:enc_type]
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
def authentication_enc_type=(val)
|
|
178
|
+
@set_args[:enctype] = val
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def default_authentication_enc_type
|
|
182
|
+
config_get_default('interface_hsrp_group', 'authentication_enc_type')
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def authentication_string
|
|
186
|
+
authentication[:password]
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def authentication_string=(val)
|
|
190
|
+
@set_args[:passwd] = val
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def default_authentication_string
|
|
194
|
+
config_get_default('interface_hsrp_group', 'authentication_string')
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def authentication_compatibility
|
|
198
|
+
authentication[:compat]
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def authentication_compatibility=(val)
|
|
202
|
+
@set_args[:compatible] = val ? 'compatibility' : ''
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def default_authentication_compatibility
|
|
206
|
+
config_get_default('interface_hsrp_group', 'authentication_compatibility')
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def authentication_timeout
|
|
210
|
+
authentication[:timeout]
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def authentication_timeout=(val)
|
|
214
|
+
if val.nil?
|
|
215
|
+
@set_args[:tval] = ''
|
|
216
|
+
@set_args[:timeout] = ''
|
|
217
|
+
else
|
|
218
|
+
@set_args[:tval] = val
|
|
219
|
+
@set_args[:timeout] = 'timeout'
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
def default_authentication_timeout
|
|
224
|
+
config_get_default('interface_hsrp_group', 'authentication_timeout')
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def authentication_set(attrs)
|
|
228
|
+
set_args_keys_default
|
|
229
|
+
# reset the authentication first
|
|
230
|
+
@set_args[:state] = 'no'
|
|
231
|
+
@set_args[:passwd] = ''
|
|
232
|
+
@set_args[:authtype] = @set_args[:keytype] = @set_args[:enctype] = ''
|
|
233
|
+
@set_args[:compatible] = @set_args[:timeout] = @set_args[:tval] = ''
|
|
234
|
+
config_set('interface_hsrp_group', 'authentication', @set_args)
|
|
235
|
+
set_args_keys(attrs)
|
|
236
|
+
[:authentication_auth_type,
|
|
237
|
+
:authentication_key_type,
|
|
238
|
+
:authentication_enc_type,
|
|
239
|
+
:authentication_string,
|
|
240
|
+
:authentication_compatibility,
|
|
241
|
+
:authentication_timeout,
|
|
242
|
+
].each do |p|
|
|
243
|
+
send(p.to_s + '=', attrs[p])
|
|
244
|
+
end
|
|
245
|
+
return if @set_args[:passwd].nil? || @set_args[:passwd].empty?
|
|
246
|
+
@set_args[:state] = ''
|
|
247
|
+
if @set_args[:authtype] == 'text'
|
|
248
|
+
@set_args[:keytype] = @set_args[:enctype] = ''
|
|
249
|
+
@set_args[:compatible] = @set_args[:timeout] = @set_args[:tval] = ''
|
|
250
|
+
elsif @set_args[:keytype] == 'key-chain'
|
|
251
|
+
@set_args[:enctype] = @set_args[:compatible] = ''
|
|
252
|
+
@set_args[:timeout] = @set_args[:tval] = ''
|
|
253
|
+
end
|
|
254
|
+
config_set('interface_hsrp_group', 'authentication', @set_args)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
def ipv4_enable
|
|
258
|
+
return default_ipv4_enable if @iptype == 'ipv6'
|
|
259
|
+
ip = config_get('interface_hsrp_group', 'ipv4_vip', @get_args)
|
|
260
|
+
ip.empty? ? false : true
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def default_ipv4_enable
|
|
264
|
+
config_get_default('interface_hsrp_group', 'ipv4_enable')
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
def ipv4_vip
|
|
268
|
+
return default_ipv4_vip if @iptype == 'ipv6'
|
|
269
|
+
ip = config_get('interface_hsrp_group', 'ipv4_vip', @get_args)
|
|
270
|
+
return default_ipv4_vip unless ip
|
|
271
|
+
arr = ip.split
|
|
272
|
+
arr[1] ? arr[1] : default_ipv4_vip
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
def ipv4_vip_set(ipenable, vip)
|
|
276
|
+
return if @iptype == 'ipv6'
|
|
277
|
+
# reset it first
|
|
278
|
+
set_args_keys(state: 'no', vip: '')
|
|
279
|
+
config_set('interface_hsrp_group', 'ipv4_vip', @set_args)
|
|
280
|
+
return unless ipenable
|
|
281
|
+
vip = vip ? vip : ''
|
|
282
|
+
set_args_keys(state: '', vip: vip)
|
|
283
|
+
config_set('interface_hsrp_group', 'ipv4_vip', @set_args)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def default_ipv4_vip
|
|
287
|
+
config_get_default('interface_hsrp_group', 'ipv4_vip')
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
def ipv6_autoconfig
|
|
291
|
+
config_get('interface_hsrp_group', 'ipv6_autoconfig', @get_args)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
def ipv6_autoconfig=(val)
|
|
295
|
+
state = val ? '' : 'no'
|
|
296
|
+
set_args_keys(state: state)
|
|
297
|
+
config_set('interface_hsrp_group', 'ipv6_autoconfig', @set_args)
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
def default_ipv6_autoconfig
|
|
301
|
+
config_get_default('interface_hsrp_group', 'ipv6_autoconfig')
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def ipv6_vip
|
|
305
|
+
return default_ipv6_vip if @iptype == 'ipv4'
|
|
306
|
+
list = config_get('interface_hsrp_group', 'ipv6_vip', @get_args)
|
|
307
|
+
# remove autoconfig from the list
|
|
308
|
+
list.delete('autoconfig')
|
|
309
|
+
list
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
def ipv6_vip=(list)
|
|
313
|
+
# reset the current list
|
|
314
|
+
cur = ipv6_vip
|
|
315
|
+
cur.each do |addr|
|
|
316
|
+
state = 'no'
|
|
317
|
+
vip = addr
|
|
318
|
+
set_args_keys(state: state, vip: vip)
|
|
319
|
+
config_set('interface_hsrp_group', 'ipv6_vip', @set_args)
|
|
320
|
+
end
|
|
321
|
+
list.each do |addr|
|
|
322
|
+
state = ''
|
|
323
|
+
vip = addr
|
|
324
|
+
set_args_keys(state: state, vip: vip)
|
|
325
|
+
config_set('interface_hsrp_group', 'ipv6_vip', @set_args)
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
def default_ipv6_vip
|
|
330
|
+
config_get_default('interface_hsrp_group', 'ipv6_vip')
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# CLI returns mac_addr in xxxx.xxxx.xxxx format
|
|
334
|
+
# so convert it to xx:xx:xx:xx:xx:xx format
|
|
335
|
+
def mac_addr
|
|
336
|
+
mac = config_get('interface_hsrp_group', 'mac_addr', @get_args)
|
|
337
|
+
return default_mac_addr unless mac
|
|
338
|
+
mac.tr('.', '').scan(/.{1,2}/).join(':')
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
# CLI expects mac_addr to be in xxxx.xxxx.xxxx format
|
|
342
|
+
# so convert from xx:xx:xx:xx:xx:xx format
|
|
343
|
+
def mac_addr=(val)
|
|
344
|
+
state = val ? '' : 'no'
|
|
345
|
+
mac = val ? val.tr(':', '').scan(/.{1,4}/).join('.') : ''
|
|
346
|
+
set_args_keys(state: state, mac: mac)
|
|
347
|
+
config_set('interface_hsrp_group', 'mac_addr', @set_args)
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def default_mac_addr
|
|
351
|
+
config_get_default('interface_hsrp_group', 'mac_addr')
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def group_name
|
|
355
|
+
config_get('interface_hsrp_group', 'group_name', @get_args)
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def group_name=(val)
|
|
359
|
+
state = val ? '' : 'no'
|
|
360
|
+
word = val ? val : ''
|
|
361
|
+
set_args_keys(state: state, word: word)
|
|
362
|
+
config_set('interface_hsrp_group', 'group_name', @set_args)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def default_group_name
|
|
366
|
+
config_get_default('interface_hsrp_group', 'group_name')
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
# The CLI can take forms like:
|
|
370
|
+
# preempt
|
|
371
|
+
# preempt delay minimum 3 reload 10 sync 15
|
|
372
|
+
def preempt_get
|
|
373
|
+
hash = {}
|
|
374
|
+
hash[:preempt] = default_preempt
|
|
375
|
+
hash[:minimum] = default_preempt_delay_minimum
|
|
376
|
+
hash[:reload] = default_preempt_delay_reload
|
|
377
|
+
hash[:sync] = default_preempt_delay_sync
|
|
378
|
+
arr = config_get('interface_hsrp_group', 'preempt', @get_args)
|
|
379
|
+
if arr
|
|
380
|
+
hash[:preempt] = true
|
|
381
|
+
hash[:minimum] = arr[0]
|
|
382
|
+
hash[:reload] = arr[1]
|
|
383
|
+
hash[:sync] = arr[2]
|
|
384
|
+
end
|
|
385
|
+
hash
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
def preempt
|
|
389
|
+
preempt_get[:preempt]
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def preempt_delay_minimum
|
|
393
|
+
preempt_get[:minimum].to_i
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def preempt_delay_reload
|
|
397
|
+
preempt_get[:reload].to_i
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
def preempt_delay_sync
|
|
401
|
+
preempt_get[:sync].to_i
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
def preempt_set(pree, min, rel, sy)
|
|
405
|
+
if pree
|
|
406
|
+
set_args_keys(state: '', delay: 'delay', minimum: 'minimum',
|
|
407
|
+
minval: min, reload: 'reload', relval: rel,
|
|
408
|
+
sync: 'sync', syncval: sy)
|
|
409
|
+
else
|
|
410
|
+
set_args_keys(state: 'no', delay: '', minimum: '', minval: '',
|
|
411
|
+
reload: '', relval: '', sync: '', syncval: '')
|
|
412
|
+
end
|
|
413
|
+
config_set('interface_hsrp_group', 'preempt', @set_args)
|
|
414
|
+
end
|
|
415
|
+
|
|
416
|
+
def default_preempt
|
|
417
|
+
config_get_default('interface_hsrp_group', 'preempt')
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
def default_preempt_delay_minimum
|
|
421
|
+
config_get_default('interface_hsrp_group', 'preempt_delay_minimum')
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
def default_preempt_delay_reload
|
|
425
|
+
config_get_default('interface_hsrp_group', 'preempt_delay_reload')
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
def default_preempt_delay_sync
|
|
429
|
+
config_get_default('interface_hsrp_group', 'preempt_delay_sync')
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
# This CLI can take forms like:
|
|
433
|
+
# priority 10
|
|
434
|
+
# priority 50 forwarding-threshold lower 10 upper 49
|
|
435
|
+
def priority_level_get
|
|
436
|
+
hash = {}
|
|
437
|
+
hash[:priority] = default_priority
|
|
438
|
+
hash[:lower] = default_priority_forward_thresh_lower
|
|
439
|
+
hash[:upper] = default_priority_forward_thresh_upper
|
|
440
|
+
arr = config_get('interface_hsrp_group', 'priority_level', @get_args)
|
|
441
|
+
if arr
|
|
442
|
+
hash[:priority] = arr[0].to_i
|
|
443
|
+
hash[:lower] = arr[1].to_i if arr[1]
|
|
444
|
+
hash[:upper] = arr[2].to_i if arr[2]
|
|
445
|
+
end
|
|
446
|
+
hash
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
def priority
|
|
450
|
+
priority_level_get[:priority]
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
def default_priority
|
|
454
|
+
config_get_default('interface_hsrp_group', 'priority')
|
|
455
|
+
end
|
|
456
|
+
|
|
457
|
+
def priority_forward_thresh_lower
|
|
458
|
+
priority_level_get[:lower]
|
|
459
|
+
end
|
|
460
|
+
|
|
461
|
+
def default_priority_forward_thresh_lower
|
|
462
|
+
config_get_default('interface_hsrp_group',
|
|
463
|
+
'priority_forward_thresh_lower')
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
def priority_forward_thresh_upper
|
|
467
|
+
priority_level_get[:upper]
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
def default_priority_forward_thresh_upper
|
|
471
|
+
config_get_default('interface_hsrp_group',
|
|
472
|
+
'priority_forward_thresh_upper')
|
|
473
|
+
end
|
|
474
|
+
|
|
475
|
+
def priority_level_set(pri, lower, upper)
|
|
476
|
+
if pri && !lower.to_s.empty? && !upper.to_s.empty?
|
|
477
|
+
set_args_keys(state: '', pri: pri,
|
|
478
|
+
forward: 'forwarding-threshold lower',
|
|
479
|
+
lval: lower, upper: 'upper', uval: upper)
|
|
480
|
+
elsif pri
|
|
481
|
+
set_args_keys(state: '', pri: pri,
|
|
482
|
+
forward: '', lval: '', upper: '', uval: '')
|
|
483
|
+
else
|
|
484
|
+
set_args_keys(state: 'no', pri: pri, forward: '', lval: '',
|
|
485
|
+
upper: '', uval: '')
|
|
486
|
+
end
|
|
487
|
+
config_set('interface_hsrp_group', 'priority_level', @set_args)
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
# This CLI can take forms like:
|
|
491
|
+
# timers 1 3
|
|
492
|
+
# timers msec 300 3
|
|
493
|
+
# timers msec 750 msec 2500
|
|
494
|
+
def timers_get
|
|
495
|
+
hash = {}
|
|
496
|
+
hash[:hello] = default_timers_hello
|
|
497
|
+
hash[:mshello] = default_timers_hello_msec
|
|
498
|
+
hash[:hold] = default_timers_hold
|
|
499
|
+
hash[:mshold] = default_timers_hold_msec
|
|
500
|
+
str = config_get('interface_hsrp_group', 'timers', @get_args)
|
|
501
|
+
return hash if str.nil?
|
|
502
|
+
regexp = Regexp.new('(?<msec1>msec)?'\
|
|
503
|
+
' *(?<he>\d+) *(?<msec2>msec)? *(?<ho>\d+)')
|
|
504
|
+
params = regexp.match(str)
|
|
505
|
+
hash[:mshello] = true if params[:msec1]
|
|
506
|
+
hash[:mshold] = true if params[:msec2]
|
|
507
|
+
hash[:hello] = params[:he].to_i
|
|
508
|
+
hash[:hold] = params[:ho].to_i
|
|
509
|
+
hash
|
|
510
|
+
end
|
|
511
|
+
|
|
512
|
+
def timers_hello
|
|
513
|
+
timers_get[:hello]
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
def timers_hello_msec
|
|
517
|
+
timers_get[:mshello]
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
def default_timers_hello
|
|
521
|
+
config_get_default('interface_hsrp_group', 'timers_hello')
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
def default_timers_hello_msec
|
|
525
|
+
config_get_default('interface_hsrp_group', 'timers_hello_msec')
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
def timers_hold
|
|
529
|
+
timers_get[:hold]
|
|
530
|
+
end
|
|
531
|
+
|
|
532
|
+
def timers_hold_msec
|
|
533
|
+
timers_get[:mshold]
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
def default_timers_hold_msec
|
|
537
|
+
config_get_default('interface_hsrp_group', 'timers_hold_msec')
|
|
538
|
+
end
|
|
539
|
+
|
|
540
|
+
def default_timers_hold
|
|
541
|
+
config_get_default('interface_hsrp_group', 'timers_hold')
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
def timers_set(mshello, hello, mshold, hold)
|
|
545
|
+
if hello && hold
|
|
546
|
+
msechello = mshello ? 'msec' : ''
|
|
547
|
+
msechold = mshold ? 'msec' : ''
|
|
548
|
+
set_args_keys(state: '', mshello: msechello,
|
|
549
|
+
hello: hello, mshold: msechold, hold: hold)
|
|
550
|
+
else
|
|
551
|
+
set_args_keys(state: 'no', mshello: '', hello: '',
|
|
552
|
+
mshold: '', hold: '')
|
|
553
|
+
end
|
|
554
|
+
config_set('interface_hsrp_group', 'timers', @set_args)
|
|
555
|
+
end
|
|
556
|
+
end # class
|
|
557
|
+
end # module
|