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,195 @@
|
|
1
|
+
# Shared Library to compare configurations.
|
2
|
+
#
|
3
|
+
# Copyright (c) 2013-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
|
+
# Current | Target | Configuration Case
|
18
|
+
# no command | no command | to Match Existing
|
19
|
+
# ------------------------------------------
|
20
|
+
# - - | - a | (no match or trans match)
|
21
|
+
# - - | y a | no match nor base match
|
22
|
+
# - a | - a | match
|
23
|
+
# - a | y a | (base match)
|
24
|
+
# y a | - a | (base match)
|
25
|
+
# y a | y a | match
|
26
|
+
# - b | - a | trans match
|
27
|
+
# - b | y a | (base match)
|
28
|
+
# y b | - a | (base match)
|
29
|
+
# y b | y a | trans match)
|
30
|
+
|
31
|
+
module Cisco
|
32
|
+
module ConfigParser
|
33
|
+
# Configuration class - helper for dealing with config CLI
|
34
|
+
class Configuration
|
35
|
+
attr_accessor :configuration
|
36
|
+
|
37
|
+
# Constructor for Configuration
|
38
|
+
#
|
39
|
+
# @raise [ArgumentError] if config_str is not a String
|
40
|
+
# @param config_str [String] to parse
|
41
|
+
def initialize(config_str)
|
42
|
+
unless config_str.kind_of? String
|
43
|
+
fail ArgumentError, 'Argument is not a String.'
|
44
|
+
end
|
45
|
+
|
46
|
+
@configuration = {}
|
47
|
+
@ordered_keys = []
|
48
|
+
@indent = ''
|
49
|
+
parse(config_str)
|
50
|
+
end # initialize
|
51
|
+
|
52
|
+
# build_min_config_hash
|
53
|
+
#
|
54
|
+
# Build a config hash of the minimum keys that would be needed to update
|
55
|
+
# current config to all of the changes in the "must" config. Each hash key
|
56
|
+
# is a configuration command; some keys have subconfigs which must be
|
57
|
+
# checked before dismissing top-level keys as present. This method is
|
58
|
+
# used primarily by the free-form command_config providers.
|
59
|
+
#
|
60
|
+
# @param current [Hash] superset of running-config & must config
|
61
|
+
# @param must [Hash] pending config from recipe, manifest, etc
|
62
|
+
# @param min_config [Hash] in-progress recursion-built minimum config
|
63
|
+
# @return min_config [Hash] in-progress recursion-built minimum config
|
64
|
+
#
|
65
|
+
def self.build_min_config_hash(current, must, min_config={})
|
66
|
+
return {} if must.empty? # base case
|
67
|
+
must.each do |k, v| # check each must{k} is present in current{}
|
68
|
+
if current.key?(k) # if cmd is in current then compare subconfig
|
69
|
+
min_config[k] = Configuration.new('')
|
70
|
+
min_config[k].configuration =
|
71
|
+
build_min_config_hash(current[k].configuration,
|
72
|
+
v.configuration, {})
|
73
|
+
if min_config[k].configuration.empty?
|
74
|
+
# no differing subconfigs, so empty hash is returned
|
75
|
+
min_config.delete(k)
|
76
|
+
end
|
77
|
+
else # command NOT in current, apply it + all subcommands
|
78
|
+
min_config[k] = v
|
79
|
+
end
|
80
|
+
end
|
81
|
+
min_config
|
82
|
+
end # build_min_config_hash
|
83
|
+
|
84
|
+
def self.config_hash_to_str(cmd_hash, str='')
|
85
|
+
return '' if cmd_hash.empty?
|
86
|
+
cmd_hash.each do |k, v|
|
87
|
+
str += k + "\n"
|
88
|
+
str += config_hash_to_str(v.configuration, '')
|
89
|
+
end
|
90
|
+
str
|
91
|
+
end # config_hash_to_str
|
92
|
+
|
93
|
+
# Get base command and prefix
|
94
|
+
#
|
95
|
+
# @param command [String]
|
96
|
+
# @return [String, String] containing prefix (if any) and
|
97
|
+
# base command.
|
98
|
+
def base_commands(command)
|
99
|
+
prefix, base = command.match(/^(no )?(.*)$/).captures
|
100
|
+
prefix = '' if prefix.nil?
|
101
|
+
[prefix, base]
|
102
|
+
end # base_commands
|
103
|
+
|
104
|
+
# Compare ConfigParser::Configuration objects
|
105
|
+
#
|
106
|
+
# @param config [ConfigParser::Configuration] obj to search
|
107
|
+
# for match.
|
108
|
+
# @return [String] containing match, empty if no match found.
|
109
|
+
def compare_with(config)
|
110
|
+
return nil if config.nil?
|
111
|
+
existing = ''
|
112
|
+
@ordered_keys.each do |config_line|
|
113
|
+
command = config_line.strip
|
114
|
+
submode = @configuration[command]
|
115
|
+
fail StopIteration, 'Could not find submode.' if submode.nil?
|
116
|
+
|
117
|
+
if special_command?(command)
|
118
|
+
# match special exit/end command
|
119
|
+
existing << config_line
|
120
|
+
break
|
121
|
+
elsif config.include_command?(command)
|
122
|
+
# match whole command
|
123
|
+
existing << config_line
|
124
|
+
config_submode = config.submode_config(command)
|
125
|
+
existing << submode.compare_with(config_submode)
|
126
|
+
next
|
127
|
+
end # if
|
128
|
+
end
|
129
|
+
existing
|
130
|
+
end # compare_with
|
131
|
+
|
132
|
+
# @return [Array] containing command with leading/trailing
|
133
|
+
# whitespace removed.
|
134
|
+
def mode_configuration
|
135
|
+
@ordered_keys.collect(&:strip)
|
136
|
+
end # mode_configuration
|
137
|
+
|
138
|
+
# Check command [Array] for test command
|
139
|
+
#
|
140
|
+
# @param command [String] test command
|
141
|
+
# @return [Boolean] true if command found, else false
|
142
|
+
def include_command?(command)
|
143
|
+
commands = mode_configuration
|
144
|
+
commands.include?(command)
|
145
|
+
end # include_command?
|
146
|
+
|
147
|
+
# Parse each config command line and create a
|
148
|
+
# hash of ConfigParser::Configuration objects
|
149
|
+
#
|
150
|
+
# @param config_str [String] Config command
|
151
|
+
def parse(config_str)
|
152
|
+
config_str += "\n"
|
153
|
+
config_str.gsub!(/^\s*$\n/, '')
|
154
|
+
# ignore leading ! or # (comments)
|
155
|
+
config_str.gsub!(/^\s*[!#].*$\n/, '')
|
156
|
+
if config_str.match(/^ *\t/)
|
157
|
+
highlight_str = config_str.gsub(/\t/, '[TAB]')
|
158
|
+
fail "Tab character detected in indentation area:\n" + highlight_str
|
159
|
+
end
|
160
|
+
indent_level = config_str.match(/^\s*/)
|
161
|
+
@indent = indent_level.to_s # capture indentation of level
|
162
|
+
escaped_indent = Regexp.escape(@indent)
|
163
|
+
# Find current configuration mode lines
|
164
|
+
@ordered_keys = config_str.scan(/^#{escaped_indent}\S.*\n/)
|
165
|
+
@ordered_keys.each do |config_line|
|
166
|
+
command = config_line.strip
|
167
|
+
escaped_cmd = Regexp.escape(config_line)
|
168
|
+
submode_string = config_str.match(
|
169
|
+
/^(?:#{escaped_cmd})((?:#{escaped_indent}\s.+\n)*)/).captures.join
|
170
|
+
@configuration[command] = Configuration.new(submode_string)
|
171
|
+
end
|
172
|
+
end # parse
|
173
|
+
|
174
|
+
# Process 'exit' and 'end' commands
|
175
|
+
#
|
176
|
+
# @param command [String] Configuration command.
|
177
|
+
# @return [Boolean] true when command is
|
178
|
+
# 'exit' or 'end', else false
|
179
|
+
def special_command?(command)
|
180
|
+
command =~ /^(?:exit|end)/
|
181
|
+
end # special_command?
|
182
|
+
|
183
|
+
# Fetch ConfigParser::Configuration object containing config_line
|
184
|
+
#
|
185
|
+
# @param config_line [String]
|
186
|
+
# @return [ConfigParser::Configuration] containing config_line
|
187
|
+
def submode_config(config_line)
|
188
|
+
command = config_line.strip
|
189
|
+
@configuration[command]
|
190
|
+
end # submode_config
|
191
|
+
|
192
|
+
private :base_commands, :parse, :special_command?
|
193
|
+
end # Configuration
|
194
|
+
end # ConfigParser
|
195
|
+
end # Cisco
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# January 2016, Glenn F. Matthews
|
2
|
+
#
|
3
|
+
# Copyright (c) 2014-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
|
+
# Shared constants for the Cisco module
|
18
|
+
module Cisco
|
19
|
+
PLATFORMS = [
|
20
|
+
# Cisco IOS XR
|
21
|
+
:ios_xr,
|
22
|
+
# Cisco NX-OS (Nexus switches)
|
23
|
+
:nexus,
|
24
|
+
]
|
25
|
+
|
26
|
+
DATA_FORMATS = [
|
27
|
+
# Cisco CLI. Indentation is significant.
|
28
|
+
:cli,
|
29
|
+
# Structured data format specific to NX-API
|
30
|
+
:nxapi_structured,
|
31
|
+
# YANG JSON
|
32
|
+
:yang_json,
|
33
|
+
]
|
34
|
+
|
35
|
+
YANG_SET_MODE = [
|
36
|
+
:merge_config,
|
37
|
+
:replace_config,
|
38
|
+
:delete_config,
|
39
|
+
]
|
40
|
+
end
|
@@ -0,0 +1,302 @@
|
|
1
|
+
# September 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 dhcp_relay_global
|
21
|
+
class DhcpRelayGlobal < NodeUtil
|
22
|
+
attr_reader :name
|
23
|
+
|
24
|
+
def initialize(instantiate=true)
|
25
|
+
Feature.dhcp_enable if instantiate
|
26
|
+
set_args_keys_default
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.globals
|
30
|
+
hash = {}
|
31
|
+
hash['default'] = DhcpRelayGlobal.new(false) if Feature.dhcp_enabled?
|
32
|
+
hash
|
33
|
+
end
|
34
|
+
|
35
|
+
# Helper method to delete @set_args hash keys
|
36
|
+
def set_args_keys_default
|
37
|
+
@set_args = {}
|
38
|
+
@get_args = @set_args
|
39
|
+
end
|
40
|
+
|
41
|
+
# rubocop:disable Style/AccessorMethodName
|
42
|
+
def set_args_keys(hash={})
|
43
|
+
set_args_keys_default
|
44
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
def destroy
|
48
|
+
return unless Feature.dhcp_enabled?
|
49
|
+
[:ipv4_information_option,
|
50
|
+
:ipv4_information_option_trust,
|
51
|
+
:ipv4_information_option_vpn,
|
52
|
+
:ipv4_information_trust_all,
|
53
|
+
:ipv4_relay,
|
54
|
+
:ipv4_smart_relay,
|
55
|
+
:ipv4_src_addr_hsrp,
|
56
|
+
:ipv4_src_intf,
|
57
|
+
:ipv4_sub_option_circuit_id_custom,
|
58
|
+
:ipv4_sub_option_circuit_id_string,
|
59
|
+
:ipv4_sub_option_cisco,
|
60
|
+
:ipv6_option_cisco,
|
61
|
+
:ipv6_option_vpn,
|
62
|
+
:ipv6_relay,
|
63
|
+
:ipv6_src_intf,
|
64
|
+
].each do |prop|
|
65
|
+
send("#{prop}=", send("default_#{prop}")) if send prop
|
66
|
+
end
|
67
|
+
set_args_keys_default
|
68
|
+
end
|
69
|
+
|
70
|
+
########################################################
|
71
|
+
# PROPERTIES #
|
72
|
+
########################################################
|
73
|
+
|
74
|
+
def ipv4_information_option
|
75
|
+
config_get('dhcp_relay_global', 'ipv4_information_option')
|
76
|
+
end
|
77
|
+
|
78
|
+
def ipv4_information_option=(val)
|
79
|
+
state = val ? '' : 'no'
|
80
|
+
set_args_keys(state: state)
|
81
|
+
config_set('dhcp_relay_global', 'ipv4_information_option', @set_args)
|
82
|
+
end
|
83
|
+
|
84
|
+
def default_ipv4_information_option
|
85
|
+
config_get_default('dhcp_relay_global', 'ipv4_information_option')
|
86
|
+
end
|
87
|
+
|
88
|
+
def ipv4_information_option_trust
|
89
|
+
config_get('dhcp_relay_global', 'ipv4_information_option_trust')
|
90
|
+
end
|
91
|
+
|
92
|
+
def ipv4_information_option_trust=(val)
|
93
|
+
state = val ? '' : 'no'
|
94
|
+
set_args_keys(state: state)
|
95
|
+
config_set('dhcp_relay_global', 'ipv4_information_option_trust',
|
96
|
+
@set_args)
|
97
|
+
end
|
98
|
+
|
99
|
+
def default_ipv4_information_option_trust
|
100
|
+
config_get_default('dhcp_relay_global', 'ipv4_information_option_trust')
|
101
|
+
end
|
102
|
+
|
103
|
+
def ipv4_information_option_vpn
|
104
|
+
config_get('dhcp_relay_global', 'ipv4_information_option_vpn')
|
105
|
+
end
|
106
|
+
|
107
|
+
def ipv4_information_option_vpn=(val)
|
108
|
+
state = val ? '' : 'no'
|
109
|
+
set_args_keys(state: state)
|
110
|
+
config_set('dhcp_relay_global', 'ipv4_information_option_vpn', @set_args)
|
111
|
+
end
|
112
|
+
|
113
|
+
def default_ipv4_information_option_vpn
|
114
|
+
config_get_default('dhcp_relay_global', 'ipv4_information_option_vpn')
|
115
|
+
end
|
116
|
+
|
117
|
+
def ipv4_information_trust_all
|
118
|
+
config_get('dhcp_relay_global', 'ipv4_information_trust_all')
|
119
|
+
end
|
120
|
+
|
121
|
+
def ipv4_information_trust_all=(val)
|
122
|
+
state = val ? '' : 'no'
|
123
|
+
set_args_keys(state: state)
|
124
|
+
config_set('dhcp_relay_global', 'ipv4_information_trust_all', @set_args)
|
125
|
+
end
|
126
|
+
|
127
|
+
def default_ipv4_information_trust_all
|
128
|
+
config_get_default('dhcp_relay_global', 'ipv4_information_trust_all')
|
129
|
+
end
|
130
|
+
|
131
|
+
def ipv4_relay
|
132
|
+
config_get('dhcp_relay_global', 'ipv4_relay')
|
133
|
+
end
|
134
|
+
|
135
|
+
def ipv4_relay=(val)
|
136
|
+
state = val ? '' : 'no'
|
137
|
+
set_args_keys(state: state)
|
138
|
+
config_set('dhcp_relay_global', 'ipv4_relay', @set_args)
|
139
|
+
end
|
140
|
+
|
141
|
+
def default_ipv4_relay
|
142
|
+
config_get_default('dhcp_relay_global', 'ipv4_relay')
|
143
|
+
end
|
144
|
+
|
145
|
+
def ipv4_smart_relay
|
146
|
+
config_get('dhcp_relay_global', 'ipv4_smart_relay')
|
147
|
+
end
|
148
|
+
|
149
|
+
def ipv4_smart_relay=(val)
|
150
|
+
state = val ? '' : 'no'
|
151
|
+
set_args_keys(state: state)
|
152
|
+
config_set('dhcp_relay_global', 'ipv4_smart_relay', @set_args)
|
153
|
+
end
|
154
|
+
|
155
|
+
def default_ipv4_smart_relay
|
156
|
+
config_get_default('dhcp_relay_global', 'ipv4_smart_relay')
|
157
|
+
end
|
158
|
+
|
159
|
+
def ipv4_src_addr_hsrp
|
160
|
+
config_get('dhcp_relay_global', 'ipv4_src_addr_hsrp')
|
161
|
+
end
|
162
|
+
|
163
|
+
def ipv4_src_addr_hsrp=(val)
|
164
|
+
state = val ? '' : 'no'
|
165
|
+
set_args_keys(state: state)
|
166
|
+
config_set('dhcp_relay_global', 'ipv4_src_addr_hsrp', @set_args)
|
167
|
+
end
|
168
|
+
|
169
|
+
def default_ipv4_src_addr_hsrp
|
170
|
+
config_get_default('dhcp_relay_global', 'ipv4_src_addr_hsrp')
|
171
|
+
end
|
172
|
+
|
173
|
+
def ipv4_src_intf
|
174
|
+
intf = config_get('dhcp_relay_global', 'ipv4_src_intf')
|
175
|
+
intf = intf.downcase.delete(' ') if intf
|
176
|
+
intf
|
177
|
+
end
|
178
|
+
|
179
|
+
def ipv4_src_intf=(val)
|
180
|
+
state = val == default_ipv4_src_intf ? 'no' : ''
|
181
|
+
intf = val == default_ipv4_src_intf ? '' : val
|
182
|
+
set_args_keys(state: state, intf: intf)
|
183
|
+
config_set('dhcp_relay_global', 'ipv4_src_intf', @set_args)
|
184
|
+
end
|
185
|
+
|
186
|
+
def default_ipv4_src_intf
|
187
|
+
config_get_default('dhcp_relay_global', 'ipv4_src_intf')
|
188
|
+
end
|
189
|
+
|
190
|
+
def ipv4_sub_option_circuit_id_custom
|
191
|
+
config_get('dhcp_relay_global', 'ipv4_sub_option_circuit_id_custom')
|
192
|
+
end
|
193
|
+
|
194
|
+
def ipv4_sub_option_circuit_id_custom=(val)
|
195
|
+
state = val ? '' : 'no'
|
196
|
+
set_args_keys(state: state)
|
197
|
+
config_set('dhcp_relay_global', 'ipv4_sub_option_circuit_id_custom',
|
198
|
+
@set_args)
|
199
|
+
end
|
200
|
+
|
201
|
+
def default_ipv4_sub_option_circuit_id_custom
|
202
|
+
config_get_default('dhcp_relay_global',
|
203
|
+
'ipv4_sub_option_circuit_id_custom')
|
204
|
+
end
|
205
|
+
|
206
|
+
def ipv4_sub_option_circuit_id_string
|
207
|
+
str = config_get('dhcp_relay_global', 'ipv4_sub_option_circuit_id_string')
|
208
|
+
# Normalize by removing white space and add quotes
|
209
|
+
str.strip! if str.kind_of?(String)
|
210
|
+
str
|
211
|
+
end
|
212
|
+
|
213
|
+
def ipv4_sub_option_circuit_id_string=(val)
|
214
|
+
state = val == default_ipv4_sub_option_circuit_id_string ? 'no' : ''
|
215
|
+
format = val == default_ipv4_sub_option_circuit_id_string ? '' : 'format'
|
216
|
+
word = val == default_ipv4_sub_option_circuit_id_string ? '' : val
|
217
|
+
word = Utils.add_quotes(word) unless word.empty?
|
218
|
+
set_args_keys(state: state, format: format, word: word)
|
219
|
+
config_set('dhcp_relay_global', 'ipv4_sub_option_circuit_id_string',
|
220
|
+
@set_args)
|
221
|
+
end
|
222
|
+
|
223
|
+
def default_ipv4_sub_option_circuit_id_string
|
224
|
+
config_get_default('dhcp_relay_global',
|
225
|
+
'ipv4_sub_option_circuit_id_string')
|
226
|
+
end
|
227
|
+
|
228
|
+
def ipv4_sub_option_cisco
|
229
|
+
config_get('dhcp_relay_global', 'ipv4_sub_option_cisco')
|
230
|
+
end
|
231
|
+
|
232
|
+
def ipv4_sub_option_cisco=(val)
|
233
|
+
state = val ? '' : 'no'
|
234
|
+
set_args_keys(state: state)
|
235
|
+
config_set('dhcp_relay_global', 'ipv4_sub_option_cisco', @set_args)
|
236
|
+
end
|
237
|
+
|
238
|
+
def default_ipv4_sub_option_cisco
|
239
|
+
config_get_default('dhcp_relay_global', 'ipv4_sub_option_cisco')
|
240
|
+
end
|
241
|
+
|
242
|
+
def ipv6_option_cisco
|
243
|
+
config_get('dhcp_relay_global', 'ipv6_option_cisco')
|
244
|
+
end
|
245
|
+
|
246
|
+
def ipv6_option_cisco=(val)
|
247
|
+
state = val ? '' : 'no'
|
248
|
+
set_args_keys(state: state)
|
249
|
+
config_set('dhcp_relay_global', 'ipv6_option_cisco', @set_args)
|
250
|
+
end
|
251
|
+
|
252
|
+
def default_ipv6_option_cisco
|
253
|
+
config_get_default('dhcp_relay_global', 'ipv6_option_cisco')
|
254
|
+
end
|
255
|
+
|
256
|
+
def ipv6_option_vpn
|
257
|
+
config_get('dhcp_relay_global', 'ipv6_option_vpn')
|
258
|
+
end
|
259
|
+
|
260
|
+
def ipv6_option_vpn=(val)
|
261
|
+
state = val ? '' : 'no'
|
262
|
+
set_args_keys(state: state)
|
263
|
+
config_set('dhcp_relay_global', 'ipv6_option_vpn', @set_args)
|
264
|
+
end
|
265
|
+
|
266
|
+
def default_ipv6_option_vpn
|
267
|
+
config_get_default('dhcp_relay_global', 'ipv6_option_vpn')
|
268
|
+
end
|
269
|
+
|
270
|
+
def ipv6_relay
|
271
|
+
config_get('dhcp_relay_global', 'ipv6_relay')
|
272
|
+
end
|
273
|
+
|
274
|
+
def ipv6_relay=(val)
|
275
|
+
state = val ? '' : 'no'
|
276
|
+
set_args_keys(state: state)
|
277
|
+
config_set('dhcp_relay_global', 'ipv6_relay', @set_args)
|
278
|
+
end
|
279
|
+
|
280
|
+
def default_ipv6_relay
|
281
|
+
config_get_default('dhcp_relay_global', 'ipv6_relay')
|
282
|
+
end
|
283
|
+
|
284
|
+
def ipv6_src_intf
|
285
|
+
intf = config_get('dhcp_relay_global', 'ipv6_src_intf')
|
286
|
+
# Normalize by downcasing and removing white space
|
287
|
+
intf = intf.downcase.delete(' ') if intf
|
288
|
+
intf
|
289
|
+
end
|
290
|
+
|
291
|
+
def ipv6_src_intf=(val)
|
292
|
+
state = val == default_ipv6_src_intf ? 'no' : ''
|
293
|
+
intf = val == default_ipv6_src_intf ? '' : val
|
294
|
+
set_args_keys(state: state, intf: intf)
|
295
|
+
config_set('dhcp_relay_global', 'ipv6_src_intf', @set_args)
|
296
|
+
end
|
297
|
+
|
298
|
+
def default_ipv6_src_intf
|
299
|
+
config_get_default('dhcp_relay_global', 'ipv6_src_intf')
|
300
|
+
end
|
301
|
+
end # class
|
302
|
+
end # module
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# NXAPI implementation of DnsDomain class
|
3
|
+
#
|
4
|
+
# September 2015, Hunter Haugen
|
5
|
+
#
|
6
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
7
|
+
#
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
# you may not use this file except in compliance with the License.
|
10
|
+
# You may obtain a copy of the License at
|
11
|
+
#
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
#
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
# See the License for the specific language governing permissions and
|
18
|
+
# limitations under the License.
|
19
|
+
#
|
20
|
+
# "group" is a standard SNMP term but in NXOS "role" is used to serve the
|
21
|
+
# purpose of group; thus this provider utility does not create snmp groups
|
22
|
+
# and is limited to reporting group (role) existence only.
|
23
|
+
|
24
|
+
require_relative 'node_util'
|
25
|
+
|
26
|
+
module Cisco
|
27
|
+
# DnsDomain - node utility class for DNS search domain config management
|
28
|
+
class DnsDomain < NodeUtil
|
29
|
+
attr_reader :name, :vrf
|
30
|
+
|
31
|
+
def initialize(name, vrf=nil, instantiate=true)
|
32
|
+
unless name.is_a? String
|
33
|
+
fail TypeError, "Expected a string, got a #{name.class.inspect}"
|
34
|
+
end
|
35
|
+
@name = name
|
36
|
+
@vrf = vrf
|
37
|
+
create if instantiate
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.dnsdomains(vrf=nil)
|
41
|
+
if vrf.nil?
|
42
|
+
domains = config_get('dnsclient', 'domain_list')
|
43
|
+
else
|
44
|
+
domains = config_get('dnsclient', 'domain_list_vrf', vrf: vrf)
|
45
|
+
end
|
46
|
+
hash = {}
|
47
|
+
domains.each do |name|
|
48
|
+
hash[name] = DnsDomain.new(name, vrf, false)
|
49
|
+
end
|
50
|
+
hash
|
51
|
+
end
|
52
|
+
|
53
|
+
def ==(other)
|
54
|
+
(name == other.name) && (vrf == other.vrf)
|
55
|
+
end
|
56
|
+
|
57
|
+
def create
|
58
|
+
if @vrf.nil?
|
59
|
+
config_set('dnsclient', 'domain_list',
|
60
|
+
state: '', name: @name)
|
61
|
+
else
|
62
|
+
# On some platforms attempts to create a new domain-list results
|
63
|
+
# in the error. 'ERROR: Deletion of VRF test in progresswait
|
64
|
+
# for it to complete'. We handle this by trying up to 20 times
|
65
|
+
# with a 1 second delay between attempts before giving up.
|
66
|
+
tries = 20
|
67
|
+
begin
|
68
|
+
config_set('dnsclient', 'domain_list_vrf',
|
69
|
+
state: '', name: @name, vrf: @vrf)
|
70
|
+
rescue Cisco::CliError => e
|
71
|
+
if /ERROR: Deletion of VRF .* in progress/.match(e.to_s)
|
72
|
+
sleep 1
|
73
|
+
tries -= 1
|
74
|
+
# rubocop:disable Metrics/BlockNesting
|
75
|
+
retry if tries > 0
|
76
|
+
# rubocop:enable Metrics/BlockNesting
|
77
|
+
end
|
78
|
+
raise
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def destroy
|
84
|
+
if @vrf.nil?
|
85
|
+
config_set('dnsclient', 'domain_list',
|
86
|
+
state: 'no', name: @name)
|
87
|
+
else
|
88
|
+
config_set('dnsclient', 'domain_list_vrf',
|
89
|
+
state: 'no', name: @name, vrf: @vrf)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|