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,137 @@
|
|
1
|
+
# Fabricpath Topology provider class
|
2
|
+
#
|
3
|
+
# Deepak Cherian, November 2015
|
4
|
+
#
|
5
|
+
# Copyright (c) 2015-2016 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
|
+
require_relative 'fabricpath_global'
|
21
|
+
|
22
|
+
module Cisco
|
23
|
+
# node_utils class for fabricpath_topology
|
24
|
+
class FabricpathTopo < NodeUtil
|
25
|
+
attr_reader :topo_id
|
26
|
+
|
27
|
+
def initialize(topo_id, instantiate=true)
|
28
|
+
@topo_id = topo_id.to_s
|
29
|
+
fail ArgumentError, "Invalid value(non-numeric
|
30
|
+
Topo id #{@topo_id})" unless @topo_id[/^\d+$/]
|
31
|
+
|
32
|
+
create if instantiate
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.topos
|
36
|
+
hash = {}
|
37
|
+
feature = config_get('fabricpath', 'feature')
|
38
|
+
return hash if feature.nil? || feature.to_sym != :enabled
|
39
|
+
topo_list = config_get('fabricpath_topology', 'all_topos')
|
40
|
+
return hash if topo_list.nil?
|
41
|
+
|
42
|
+
topo_list.each do |id|
|
43
|
+
hash[id] = FabricpathTopo.new(id, false)
|
44
|
+
end
|
45
|
+
hash
|
46
|
+
rescue Cisco::CliError => e
|
47
|
+
# cmd will syntax reject when feature is not enabled
|
48
|
+
raise unless e.clierror =~ /Syntax error/
|
49
|
+
return {}
|
50
|
+
end
|
51
|
+
|
52
|
+
def create
|
53
|
+
fabricpath_feature_set(:enabled) unless :enabled == fabricpath_feature
|
54
|
+
config_set('fabricpath_topology', 'create',
|
55
|
+
topo_id: @topo_id) unless @topo_id == '0'
|
56
|
+
end
|
57
|
+
|
58
|
+
def destroy
|
59
|
+
config_set('fabricpath_topology', 'destroy', topo_id: @topo_id)
|
60
|
+
end
|
61
|
+
|
62
|
+
def fabricpath_feature
|
63
|
+
FabricpathGlobal.fabricpath_feature
|
64
|
+
end
|
65
|
+
|
66
|
+
def fabricpath_feature_set(fabricpath_set)
|
67
|
+
FabricpathGlobal.fabricpath_feature_set(fabricpath_set)
|
68
|
+
end
|
69
|
+
|
70
|
+
def member_vlans
|
71
|
+
config_get('fabricpath_topology', 'member_vlans',
|
72
|
+
@topo_id).gsub(/\s+/, '')
|
73
|
+
end
|
74
|
+
|
75
|
+
def member_vlans=(str)
|
76
|
+
if str.empty?
|
77
|
+
state = 'no'
|
78
|
+
range = ''
|
79
|
+
else
|
80
|
+
state = ''
|
81
|
+
range = str
|
82
|
+
# reset existing range since we don't want incremental sets
|
83
|
+
config_set('fabricpath_topology', 'member_vlans', topo_id: @topo_id,
|
84
|
+
state: 'no', vlan_range: '') if member_vlans != ''
|
85
|
+
end
|
86
|
+
config_set('fabricpath_topology', 'member_vlans', topo_id: @topo_id,
|
87
|
+
state: state, vlan_range: range)
|
88
|
+
end
|
89
|
+
|
90
|
+
def default_member_vlans
|
91
|
+
config_get_default('fabricpath_topology', 'member_vlans')
|
92
|
+
end
|
93
|
+
|
94
|
+
def member_vnis
|
95
|
+
config_get('fabricpath_topology', 'member_vnis', @topo_id).gsub(/\s+/, '')
|
96
|
+
end
|
97
|
+
|
98
|
+
def member_vnis=(str)
|
99
|
+
debug "str is #{str} whose class is #{str.class}"
|
100
|
+
str = str.join(',') unless str.empty?
|
101
|
+
if str.empty?
|
102
|
+
state = 'no'
|
103
|
+
range = ''
|
104
|
+
else
|
105
|
+
state = ''
|
106
|
+
range = str
|
107
|
+
end
|
108
|
+
config_set('fabricpath_topology', 'member_vnis', topo_id: @topo_id,
|
109
|
+
state: state, vni_range: range)
|
110
|
+
end
|
111
|
+
|
112
|
+
def default_member_vnis
|
113
|
+
config_get_default('fabricpath_topology', 'member_vlans')
|
114
|
+
end
|
115
|
+
|
116
|
+
def topo_name
|
117
|
+
config_get('fabricpath_topology', 'description', @topo_id)
|
118
|
+
end
|
119
|
+
|
120
|
+
def topo_name=(desc)
|
121
|
+
fail TypeError unless desc.is_a?(String)
|
122
|
+
if desc.empty?
|
123
|
+
state = 'no'
|
124
|
+
name = ''
|
125
|
+
else
|
126
|
+
state = ''
|
127
|
+
name = desc
|
128
|
+
end
|
129
|
+
config_set('fabricpath_topology', 'description', topo_id: @topo_id,
|
130
|
+
state: state, name: name)
|
131
|
+
end
|
132
|
+
|
133
|
+
def default_topo_name
|
134
|
+
config_get_default('fabricpath_topology', 'description')
|
135
|
+
end
|
136
|
+
end # class
|
137
|
+
end # module
|
@@ -0,0 +1,377 @@
|
|
1
|
+
# January 2016, Robert W Gries
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015-2019 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
|
+
module Cisco
|
20
|
+
# Feature - node util class for managing common features
|
21
|
+
class Feature < NodeUtil
|
22
|
+
# Note that in most cases the enable methods should only enable;
|
23
|
+
# however, for test purposes it is sometimes convenient to support
|
24
|
+
# feature disablement for cleanup purposes.
|
25
|
+
# ---------------------------
|
26
|
+
def self.bfd_enable
|
27
|
+
return if bfd_enabled?
|
28
|
+
config_set('feature', 'bfd')
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.bfd_enabled?
|
32
|
+
config_get('feature', 'bfd')
|
33
|
+
rescue Cisco::CliError => e
|
34
|
+
# cmd will syntax reject when feature is not enabled.
|
35
|
+
raise unless e.clierror =~ /Syntax error/
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
|
39
|
+
# ---------------------------
|
40
|
+
def self.bgp_enable
|
41
|
+
return if bgp_enabled?
|
42
|
+
config_set('feature', 'bgp')
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.bgp_enabled?
|
46
|
+
config_get('feature', 'bgp')
|
47
|
+
end
|
48
|
+
|
49
|
+
# ---------------------------
|
50
|
+
def self.dhcp_enable
|
51
|
+
return if dhcp_enabled?
|
52
|
+
config_set('feature', 'dhcp')
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.dhcp_enabled?
|
56
|
+
config_get('feature', 'dhcp')
|
57
|
+
rescue Cisco::CliError => e
|
58
|
+
# cmd will syntax reject when feature is not enabled.
|
59
|
+
raise unless e.clierror =~ /Syntax error/
|
60
|
+
return false
|
61
|
+
end
|
62
|
+
|
63
|
+
# ---------------------------
|
64
|
+
def self.fabric_enable
|
65
|
+
# install feature-set and enable it
|
66
|
+
return if fabric_enabled?
|
67
|
+
config_set('feature', 'fabric', state: 'install') unless fabric_installed?
|
68
|
+
config_set('feature', 'fabric', state: '')
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.fabric_enabled?
|
72
|
+
config_get('feature', 'fabric') =~ /^enabled/
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.fabric_installed?
|
76
|
+
config_get('feature', 'fabric') !~ /^uninstalled/
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.fabric_supported?
|
80
|
+
config_get('feature', 'fabric')
|
81
|
+
end
|
82
|
+
|
83
|
+
# ---------------------------
|
84
|
+
def self.fabricpath_enable
|
85
|
+
# install feature-set and enable it
|
86
|
+
return if fabricpath_enabled?
|
87
|
+
config_set('feature', 'fabricpath', state: 'install') unless
|
88
|
+
fabricpath_installed?
|
89
|
+
config_set('feature', 'fabricpath', state: '')
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.fabricpath_enabled?
|
93
|
+
config_get('feature', 'fabricpath') =~ /^enabled/
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.fabricpath_installed?
|
97
|
+
config_get('feature', 'fabricpath') !~ /^uninstalled/
|
98
|
+
end
|
99
|
+
|
100
|
+
def self.fabricpath_supported?
|
101
|
+
config_get('feature', 'fabricpath')
|
102
|
+
end
|
103
|
+
|
104
|
+
# ---------------------------
|
105
|
+
def self.fabric_forwarding_enable
|
106
|
+
return if fabric_forwarding_enabled?
|
107
|
+
Feature.fabric_enable if Feature.fabric_supported?
|
108
|
+
# The feature fabric-forwarding cli is required in some older nxos images
|
109
|
+
# but is not present in newer images because nv_overlay_evpn handles
|
110
|
+
# both features; therefore feature fabric-forwarding is best-effort
|
111
|
+
# and ignored on cli failure.
|
112
|
+
begin
|
113
|
+
config_set('feature', 'fabric_forwarding')
|
114
|
+
rescue Cisco::CliError
|
115
|
+
Cisco::Logger.debug '"feature fabric forwarding" CLI was rejected'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def self.fabric_forwarding_enabled?
|
120
|
+
config_get('feature', 'fabric_forwarding')
|
121
|
+
end
|
122
|
+
|
123
|
+
# ---------------------------
|
124
|
+
def self.fex_enable
|
125
|
+
# install feature-set and enable it
|
126
|
+
return if fex_enabled?
|
127
|
+
config_set('feature', 'fex', state: 'install') unless fex_installed?
|
128
|
+
config_set('feature', 'fex', state: '')
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.fex_enabled?
|
132
|
+
config_get('feature', 'fex') =~ /^enabled/
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.fex_installed?
|
136
|
+
config_get('feature', 'fex') !~ /^uninstalled/
|
137
|
+
end
|
138
|
+
|
139
|
+
def self.fex_supported?
|
140
|
+
config_get('feature', 'fex')
|
141
|
+
end
|
142
|
+
|
143
|
+
# ---------------------------
|
144
|
+
def self.hsrp_enable
|
145
|
+
return if hsrp_enabled?
|
146
|
+
config_set('feature', 'hsrp')
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.hsrp_enabled?
|
150
|
+
config_get('feature', 'hsrp')
|
151
|
+
rescue Cisco::CliError => e
|
152
|
+
# cmd will syntax reject when feature is not enabled.
|
153
|
+
raise unless e.clierror =~ /Syntax error/
|
154
|
+
return false
|
155
|
+
end
|
156
|
+
|
157
|
+
# ---------------------------
|
158
|
+
def self.itd_enable
|
159
|
+
return if itd_enabled?
|
160
|
+
config_set('feature', 'itd')
|
161
|
+
end
|
162
|
+
|
163
|
+
def self.itd_enabled?
|
164
|
+
config_get('feature', 'itd')
|
165
|
+
rescue Cisco::CliError => e
|
166
|
+
# cmd will syntax reject when feature is not enabled.
|
167
|
+
raise unless e.clierror =~ /Syntax error/
|
168
|
+
return false
|
169
|
+
end
|
170
|
+
|
171
|
+
def self.lacp_enable
|
172
|
+
return if lacp_enabled?
|
173
|
+
config_set('feature', 'lacp')
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.lacp_enabled?
|
177
|
+
config_get('feature', 'lacp')
|
178
|
+
rescue Cisco::CliError => e
|
179
|
+
# cmd will syntax reject when feature is not enabled.
|
180
|
+
raise unless e.clierror =~ /Syntax error/
|
181
|
+
return false
|
182
|
+
end
|
183
|
+
|
184
|
+
# ---------------------------
|
185
|
+
def self.ngmvpn_enable
|
186
|
+
return if ngmvpn_enabled?
|
187
|
+
config_set('feature', 'ngmvpn', state: '')
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.ngmvpn_enabled?
|
191
|
+
config_get('feature', 'ngmvpn')
|
192
|
+
rescue Cisco::CliError => e
|
193
|
+
# cmd will syntax reject when feature is not enabled.
|
194
|
+
raise unless e.clierror =~ /Syntax error/
|
195
|
+
return false
|
196
|
+
end
|
197
|
+
|
198
|
+
def self.ngmvpn_disable
|
199
|
+
return unless ngmvpn_enabled?
|
200
|
+
config_set('feature', 'ngmvpn', state: 'no')
|
201
|
+
end
|
202
|
+
|
203
|
+
# ---------------------------
|
204
|
+
def self.nv_overlay_enable
|
205
|
+
# Note: vdc platforms restrict this feature to F3 or newer linecards
|
206
|
+
return if nv_overlay_enabled?
|
207
|
+
result = config_set('feature', 'nv_overlay', state: '')
|
208
|
+
cli_error_check(result)
|
209
|
+
sleep 1
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.nv_overlay_disable
|
213
|
+
# Note: vdc platforms restrict this feature to F3 or newer linecards
|
214
|
+
# Note: this is for test purposes only
|
215
|
+
return unless nv_overlay_enabled?
|
216
|
+
config_set('feature', 'nv_overlay', state: 'no')
|
217
|
+
sleep 1
|
218
|
+
end
|
219
|
+
|
220
|
+
def self.nv_overlay_enabled?
|
221
|
+
config_get('feature', 'nv_overlay')
|
222
|
+
rescue Cisco::CliError => e
|
223
|
+
# cmd will syntax reject when feature is not enabled.
|
224
|
+
raise unless e.clierror =~ /Syntax error/
|
225
|
+
return false
|
226
|
+
end
|
227
|
+
|
228
|
+
def self.nv_overlay_supported?
|
229
|
+
node.cmd_ref.supports?('feature', 'nv_overlay')
|
230
|
+
end
|
231
|
+
|
232
|
+
# ---------------------------
|
233
|
+
def self.nv_overlay_evpn_enable
|
234
|
+
return if nv_overlay_evpn_enabled?
|
235
|
+
config_set('feature', 'nv_overlay_evpn')
|
236
|
+
end
|
237
|
+
|
238
|
+
def self.nv_overlay_evpn_enabled?
|
239
|
+
config_get('feature', 'nv_overlay_evpn')
|
240
|
+
end
|
241
|
+
|
242
|
+
def self.nv_overlay_evpn_supported?
|
243
|
+
node.cmd_ref.supports?('feature', 'nv_overlay_evpn')
|
244
|
+
end
|
245
|
+
|
246
|
+
# ---------------------------
|
247
|
+
def self.ospf_enable
|
248
|
+
return if ospf_enabled?
|
249
|
+
config_set('feature', 'ospf')
|
250
|
+
end
|
251
|
+
|
252
|
+
def self.ospf_enabled?
|
253
|
+
config_get('feature', 'ospf')
|
254
|
+
end
|
255
|
+
|
256
|
+
# ---------------------------
|
257
|
+
def self.pim_enable
|
258
|
+
return if pim_enabled?
|
259
|
+
config_set('feature', 'pim')
|
260
|
+
end
|
261
|
+
|
262
|
+
def self.pim_enabled?
|
263
|
+
config_get('feature', 'pim')
|
264
|
+
end
|
265
|
+
|
266
|
+
# ---------------------------
|
267
|
+
def self.private_vlan_enable
|
268
|
+
return if private_vlan_enabled?
|
269
|
+
config_set('feature', 'private_vlan')
|
270
|
+
end
|
271
|
+
|
272
|
+
def self.private_vlan_enabled?
|
273
|
+
config_get('feature', 'private_vlan')
|
274
|
+
end
|
275
|
+
|
276
|
+
# ---------------------------
|
277
|
+
def self.tacacs_enable
|
278
|
+
return if tacacs_enabled? || platform == :ios_xr
|
279
|
+
config_set('feature', 'tacacs')
|
280
|
+
end
|
281
|
+
|
282
|
+
def self.tacacs_enabled?
|
283
|
+
config_get('feature', 'tacacs')
|
284
|
+
end
|
285
|
+
|
286
|
+
# ---------------------------
|
287
|
+
def self.vn_segment_vlan_based_enable
|
288
|
+
return if vn_segment_vlan_based_enabled?
|
289
|
+
result = config_set('feature', 'vn_segment_vlan_based')
|
290
|
+
cli_error_check(result)
|
291
|
+
end
|
292
|
+
|
293
|
+
def self.vn_segment_vlan_based_enabled?
|
294
|
+
config_get('feature', 'vn_segment_vlan_based')
|
295
|
+
end
|
296
|
+
|
297
|
+
# ---------------------------
|
298
|
+
def self.vni_enable
|
299
|
+
return if vni_enabled?
|
300
|
+
result = config_set('feature', 'vni')
|
301
|
+
cli_error_check(result)
|
302
|
+
end
|
303
|
+
|
304
|
+
def self.vni_enabled?
|
305
|
+
config_get('feature', 'vni')
|
306
|
+
end
|
307
|
+
|
308
|
+
# ---------------------------
|
309
|
+
def self.vtp_enable
|
310
|
+
return if vtp_enabled?
|
311
|
+
result = config_set('feature', 'vtp', state: '')
|
312
|
+
cli_error_check(result)
|
313
|
+
end
|
314
|
+
|
315
|
+
# Special Case: The only way to remove a vtp instance
|
316
|
+
# is by disabling the feature.
|
317
|
+
def self.vtp_disable
|
318
|
+
return unless vtp_enabled?
|
319
|
+
config_set('feature', 'vtp', state: 'no')
|
320
|
+
end
|
321
|
+
|
322
|
+
def self.vtp_enabled?
|
323
|
+
config_get('feature', 'vtp')
|
324
|
+
rescue Cisco::CliError => e
|
325
|
+
# cmd will syntax reject when feature is not enabled.
|
326
|
+
raise unless e.clierror =~ /Syntax error/
|
327
|
+
return false
|
328
|
+
end
|
329
|
+
|
330
|
+
# ---------------------------
|
331
|
+
def self.cli_error_check(result)
|
332
|
+
# The NXOS feature cli may not raise an exception in some conditions and
|
333
|
+
# instead just displays a STDOUT error message; thus NXAPI does not detect
|
334
|
+
# the failure and we must catch it by inspecting the "body" hash entry
|
335
|
+
# returned by NXAPI. This cli behavior is unlikely to change soon.
|
336
|
+
patterns = [
|
337
|
+
'Hardware is not capable of supporting',
|
338
|
+
'is unsupported on this node',
|
339
|
+
'Feature NOT supported on this Platform',
|
340
|
+
]
|
341
|
+
fail result[2]['body'] if
|
342
|
+
result[2].is_a?(Hash) &&
|
343
|
+
result[2]['body'].to_s[Regexp.union(patterns)]
|
344
|
+
|
345
|
+
# Some test environments get result as a string instead of a hash
|
346
|
+
fail result if
|
347
|
+
result.is_a?(String) && result[Regexp.union(patterns)]
|
348
|
+
end
|
349
|
+
|
350
|
+
# ---------------------------
|
351
|
+
def self.compatible_interfaces(feature, property='supported_module_pids')
|
352
|
+
# Figure out the interfaces in a modular switch that are
|
353
|
+
# compatible with the given feature (or property within a feature)
|
354
|
+
# and return an array of such interfaces
|
355
|
+
module_pids = config_get(feature, property)
|
356
|
+
return [] if module_pids.nil?
|
357
|
+
module_regex = Regexp.new module_pids
|
358
|
+
# first get the compatible modules present in the switch
|
359
|
+
slots = Platform.slots.select do |_slot, filt_mod|
|
360
|
+
filt_mod['pid'] =~ module_regex
|
361
|
+
end
|
362
|
+
return [] if slots.empty?
|
363
|
+
# get the slot numbers only into filtered slots array
|
364
|
+
filt_slots = slots.keys.map { |key| key[/\d+/] }
|
365
|
+
# now filter interfaces in the vdc based on compatible slots
|
366
|
+
begin
|
367
|
+
vdc = Vdc.new(Vdc.default_vdc_name)
|
368
|
+
filt_intfs = vdc.interface_membership.select do |intf|
|
369
|
+
filt_slots.include? intf[/\d+/]
|
370
|
+
end
|
371
|
+
rescue CliError
|
372
|
+
filt_intfs = []
|
373
|
+
end
|
374
|
+
filt_intfs
|
375
|
+
end
|
376
|
+
end
|
377
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Hostname provider class
|
2
|
+
#
|
3
|
+
# September 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
|
+
# Hostname- node utility class for hostname configuration
|
23
|
+
class HostName < NodeUtil
|
24
|
+
attr_reader :name
|
25
|
+
|
26
|
+
def initialize(name, instantiate=true)
|
27
|
+
@name = name
|
28
|
+
create if instantiate
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.hostname
|
32
|
+
hash = {}
|
33
|
+
hostname = config_get('hostname', 'name')
|
34
|
+
hash[hostname] = HostName.new(hostname, false)
|
35
|
+
hash
|
36
|
+
end
|
37
|
+
|
38
|
+
def hostname=(host)
|
39
|
+
if host
|
40
|
+
config_set(
|
41
|
+
'hostname', 'name',
|
42
|
+
state: '', name: host)
|
43
|
+
else
|
44
|
+
config_set(
|
45
|
+
'hostname', 'name',
|
46
|
+
state: 'no', name: '')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def ==(other)
|
51
|
+
name == other.name
|
52
|
+
end
|
53
|
+
|
54
|
+
def create
|
55
|
+
config_set('hostname', 'name', state: '', name: @name)
|
56
|
+
end
|
57
|
+
|
58
|
+
def destroy
|
59
|
+
config_set('hostname', 'name', state: 'no', name: @name)
|
60
|
+
end
|
61
|
+
end # class
|
62
|
+
end # module
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# October 2016, Sai Chintalapudi
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 Cisco and/or its affiliates.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require_relative 'node_util'
|
18
|
+
|
19
|
+
module Cisco
|
20
|
+
# node_utils class for hsrp_global
|
21
|
+
class HsrpGlobal < NodeUtil
|
22
|
+
def initialize(instantiate=true)
|
23
|
+
Feature.hsrp_enable if instantiate
|
24
|
+
set_args_keys_default
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.globals
|
28
|
+
hash = {}
|
29
|
+
hash['default'] = HsrpGlobal.new(false) if Feature.hsrp_enabled?
|
30
|
+
hash
|
31
|
+
end
|
32
|
+
|
33
|
+
# Helper method to delete @set_args hash keys
|
34
|
+
def set_args_keys_default
|
35
|
+
@set_args = {}
|
36
|
+
@get_args = @set_args
|
37
|
+
end
|
38
|
+
|
39
|
+
# rubocop:disable Style/AccessorMethodName
|
40
|
+
def set_args_keys(hash={})
|
41
|
+
set_args_keys_default
|
42
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
return unless Feature.hsrp_enabled?
|
47
|
+
[:bfd_all_intf,
|
48
|
+
:extended_hold,
|
49
|
+
].each do |prop|
|
50
|
+
send("#{prop}=", send("default_#{prop}")) if send prop
|
51
|
+
end
|
52
|
+
set_args_keys_default
|
53
|
+
end
|
54
|
+
|
55
|
+
########################################################
|
56
|
+
# PROPERTIES #
|
57
|
+
########################################################
|
58
|
+
|
59
|
+
def bfd_all_intf
|
60
|
+
config_get('hsrp_global', 'bfd_all_intf')
|
61
|
+
end
|
62
|
+
|
63
|
+
def bfd_all_intf=(val)
|
64
|
+
state = val ? '' : 'no'
|
65
|
+
set_args_keys(state: state)
|
66
|
+
Feature.bfd_enable if val
|
67
|
+
config_set('hsrp_global', 'bfd_all_intf', @set_args)
|
68
|
+
end
|
69
|
+
|
70
|
+
def default_bfd_all_intf
|
71
|
+
config_get_default('hsrp_global', 'bfd_all_intf')
|
72
|
+
end
|
73
|
+
|
74
|
+
# CLI can be either of the following or none
|
75
|
+
# hsrp timers extended-hold (in this case, the time is 10)
|
76
|
+
# hsrp timers extended-hold <time>
|
77
|
+
def extended_hold
|
78
|
+
hold = config_get('hsrp_global', 'extended_hold', @get_args)
|
79
|
+
return default_extended_hold unless hold
|
80
|
+
arr = hold.split('hsrp timers extended-hold')
|
81
|
+
return config_get('hsrp_global', 'extended_hold_enable', @get_args) if
|
82
|
+
arr.empty?
|
83
|
+
arr[1].strip
|
84
|
+
end
|
85
|
+
|
86
|
+
def extended_hold=(val)
|
87
|
+
state = val ? '' : 'no'
|
88
|
+
time = val ? val : ''
|
89
|
+
set_args_keys(state: state, time: time)
|
90
|
+
config_set('hsrp_global', 'extended_hold', @set_args)
|
91
|
+
end
|
92
|
+
|
93
|
+
def default_extended_hold
|
94
|
+
config_get_default('hsrp_global', 'extended_hold')
|
95
|
+
end
|
96
|
+
end # class
|
97
|
+
end # module
|