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,511 @@
|
|
|
1
|
+
# Mar 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 itd_device_group
|
|
21
|
+
class ItdService < NodeUtil
|
|
22
|
+
attr_reader :name
|
|
23
|
+
|
|
24
|
+
def initialize(name, instantiate=true)
|
|
25
|
+
fail TypeError unless name.is_a?(String)
|
|
26
|
+
fail ArgumentError unless name.length > 0
|
|
27
|
+
@name = name
|
|
28
|
+
|
|
29
|
+
set_args_keys_default
|
|
30
|
+
create if instantiate
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.itds
|
|
34
|
+
hash = {}
|
|
35
|
+
list = []
|
|
36
|
+
services = config_get('itd_service',
|
|
37
|
+
'all_itds')
|
|
38
|
+
return hash if services.nil?
|
|
39
|
+
|
|
40
|
+
services.each do |service|
|
|
41
|
+
# The show cmd shows more than service,
|
|
42
|
+
# we get other things like device-groups etc.
|
|
43
|
+
# so filter it out to just get the service
|
|
44
|
+
next if service.include?('device-group')
|
|
45
|
+
next if service.include?('session')
|
|
46
|
+
next if service.include?('statistics')
|
|
47
|
+
list << service
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
list.each do |id|
|
|
51
|
+
hash[id] = ItdService.new(id, false)
|
|
52
|
+
end
|
|
53
|
+
hash
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
########################################################
|
|
57
|
+
# PROPERTIES #
|
|
58
|
+
########################################################
|
|
59
|
+
|
|
60
|
+
def create
|
|
61
|
+
Feature.itd_enable
|
|
62
|
+
config_set('itd_service', 'create', name: @name)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def destroy
|
|
66
|
+
# the service MUST be shutdown before it can be destroyed
|
|
67
|
+
config_set('itd_service', 'shutdown', name: @name, state: '')
|
|
68
|
+
config_set('itd_service', 'destroy', name: @name)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Helper method to delete @set_args hash keys
|
|
72
|
+
def set_args_keys_default
|
|
73
|
+
keys = { name: @name }
|
|
74
|
+
@get_args = @set_args = keys
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# rubocop:disable Style/AccessorMethodName
|
|
78
|
+
def set_args_keys(hash={})
|
|
79
|
+
set_args_keys_default
|
|
80
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def access_list
|
|
84
|
+
config_get('itd_service', 'access_list', @get_args)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def access_list=(val)
|
|
88
|
+
if val.empty?
|
|
89
|
+
@set_args[:state] = 'no'
|
|
90
|
+
@set_args[:al] = access_list
|
|
91
|
+
config_set('itd_service', 'access_list', @set_args) unless
|
|
92
|
+
access_list.empty?
|
|
93
|
+
else
|
|
94
|
+
@set_args[:state] = ''
|
|
95
|
+
@set_args[:al] = val
|
|
96
|
+
config_set('itd_service', 'access_list', @set_args)
|
|
97
|
+
end
|
|
98
|
+
set_args_keys_default
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def default_access_list
|
|
102
|
+
config_get_default('itd_service', 'access_list')
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def device_group
|
|
106
|
+
config_get('itd_service', 'device_group', @get_args)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def device_group=(val)
|
|
110
|
+
if val.empty?
|
|
111
|
+
@set_args[:state] = 'no'
|
|
112
|
+
@set_args[:dg] = device_group
|
|
113
|
+
config_set('itd_service', 'device_group', @set_args) unless
|
|
114
|
+
device_group.empty?
|
|
115
|
+
else
|
|
116
|
+
@set_args[:state] = ''
|
|
117
|
+
@set_args[:dg] = val
|
|
118
|
+
config_set('itd_service', 'device_group', @set_args)
|
|
119
|
+
end
|
|
120
|
+
set_args_keys_default
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def default_device_group
|
|
124
|
+
config_get_default('itd_service', 'device_group')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def exclude_access_list
|
|
128
|
+
config_get('itd_service', 'exclude_access_list', @get_args)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def exclude_access_list=(val)
|
|
132
|
+
if val.empty?
|
|
133
|
+
@set_args[:state] = 'no'
|
|
134
|
+
@set_args[:al] = exclude_access_list
|
|
135
|
+
config_set('itd_service', 'exclude_access_list', @set_args) unless
|
|
136
|
+
exclude_access_list.empty?
|
|
137
|
+
else
|
|
138
|
+
@set_args[:state] = ''
|
|
139
|
+
@set_args[:al] = val
|
|
140
|
+
config_set('itd_service', 'exclude_access_list', @set_args)
|
|
141
|
+
end
|
|
142
|
+
set_args_keys_default
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def default_exclude_access_list
|
|
146
|
+
config_get_default('itd_service', 'exclude_access_list')
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def fail_action
|
|
150
|
+
config_get('itd_service', 'fail_action', @get_args)
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def fail_action=(state)
|
|
154
|
+
no_cmd = (state ? '' : 'no')
|
|
155
|
+
@set_args[:state] = no_cmd
|
|
156
|
+
config_set('itd_service', 'fail_action', @set_args)
|
|
157
|
+
set_args_keys_default
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def default_fail_action
|
|
161
|
+
config_get_default('itd_service', 'fail_action')
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# this is an array like:
|
|
165
|
+
# [['ethernet 1/1', '1.1.1.1'], ['port-channel 100', '2.2.2.2'],
|
|
166
|
+
# ['vlan 2', '3.3.3.3']]
|
|
167
|
+
# show command output is like: Eth1/1, Po100, Vlan2
|
|
168
|
+
# so translate back to the input format
|
|
169
|
+
def ingress_interface
|
|
170
|
+
list = config_get('itd_service', 'ingress_interface', @get_args)
|
|
171
|
+
rlist = []
|
|
172
|
+
list.each do |intf, next_hop|
|
|
173
|
+
intf.gsub!('Eth', 'ethernet ')
|
|
174
|
+
intf.gsub!('Po', 'port-channel ')
|
|
175
|
+
intf.gsub!('Vlan', 'vlan ')
|
|
176
|
+
next_hop = '' if next_hop.nil?
|
|
177
|
+
rlist << [intf, next_hop]
|
|
178
|
+
end
|
|
179
|
+
rlist
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def ingress_interface_cleanup
|
|
183
|
+
cur_list = ingress_interface
|
|
184
|
+
return if cur_list.empty?
|
|
185
|
+
@set_args[:state] = 'no'
|
|
186
|
+
@set_args[:next] = ''
|
|
187
|
+
@set_args[:nhop] = ''
|
|
188
|
+
# clean up the current list first
|
|
189
|
+
cur_list.each do |intf, _next_hop|
|
|
190
|
+
@set_args[:interface] = intf
|
|
191
|
+
config_set('itd_service', 'ingress_interface', @set_args)
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# only one next-hop is allowed per interface but
|
|
196
|
+
# due to nxos issues, it allows more than one;
|
|
197
|
+
# so the workaround is to clean up the current ingress
|
|
198
|
+
# intf and configure all of them again
|
|
199
|
+
def ingress_interface=(list)
|
|
200
|
+
ingress_interface_cleanup
|
|
201
|
+
@set_args[:state] = ''
|
|
202
|
+
list.each do |intf, next_hop|
|
|
203
|
+
@set_args[:interface] = intf
|
|
204
|
+
@set_args[:next] = ''
|
|
205
|
+
@set_args[:nhop] = ''
|
|
206
|
+
unless next_hop == '' || next_hop == 'default'
|
|
207
|
+
@set_args[:next] = 'next-hop'
|
|
208
|
+
@set_args[:nhop] = next_hop
|
|
209
|
+
end
|
|
210
|
+
config_set('itd_service', 'ingress_interface', @set_args)
|
|
211
|
+
end
|
|
212
|
+
set_args_keys_default
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
def default_ingress_interface
|
|
216
|
+
config_get_default('itd_service', 'ingress_interface')
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# the load-balance command can take several forms like:
|
|
220
|
+
# load-balance method dst ip
|
|
221
|
+
# load-balance method dst ip-l4port tcp range 3 6
|
|
222
|
+
# load-balance method dst ip-l4port tcp range 3 6 buckets 8 mask-position 2
|
|
223
|
+
# load-balance buckets 8
|
|
224
|
+
# load-balance mask-position 2
|
|
225
|
+
def lb_get
|
|
226
|
+
str = config_get('itd_service', 'load_balance', @get_args)
|
|
227
|
+
return nil if str.nil?
|
|
228
|
+
if str.include?('method') && str.include?('range')
|
|
229
|
+
regexp = Regexp.new('load-balance *(?<bundle_select>method \S+)?'\
|
|
230
|
+
' *(?<bundle_hash>\S+)?'\
|
|
231
|
+
' *(?<proto>\S+)?'\
|
|
232
|
+
' *(?<start_port>range \d+)?'\
|
|
233
|
+
' *(?<end_port>\d+)?'\
|
|
234
|
+
' *(?<buckets>buckets \d+)?'\
|
|
235
|
+
' *(?<mask>mask-position \d+)?')
|
|
236
|
+
elsif str.include?('method')
|
|
237
|
+
regexp = Regexp.new('load-balance *(?<bundle_select>method \S+)?'\
|
|
238
|
+
' *(?<bundle_hash>\S+)?'\
|
|
239
|
+
' *(?<buckets>buckets \d+)?'\
|
|
240
|
+
' *(?<mask>mask-position \d+)?') unless str.include?('range')
|
|
241
|
+
else
|
|
242
|
+
regexp = Regexp.new('load-balance *(?<buckets>buckets \d+)?'\
|
|
243
|
+
' *(?<mask>mask-position \d+)?')
|
|
244
|
+
end
|
|
245
|
+
regexp.match(str)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def load_bal_buckets
|
|
249
|
+
val = Utils.extract_value(lb_get, 'buckets')
|
|
250
|
+
return default_load_bal_buckets if val.nil?
|
|
251
|
+
val.to_i
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
def load_bal_buckets=(buckets)
|
|
255
|
+
@set_args[:buckets] = Utils.attach_prefix(buckets, :buckets)
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def default_load_bal_buckets
|
|
259
|
+
config_get_default('itd_service', 'load_bal_buckets')
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def load_bal_mask_pos
|
|
263
|
+
val = Utils.extract_value(lb_get, 'mask', 'mask-position')
|
|
264
|
+
return default_load_bal_mask_pos if val.nil?
|
|
265
|
+
val.to_i
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def load_bal_mask_pos=(mask)
|
|
269
|
+
@set_args[:mask] = Utils.attach_prefix(mask, :mask, 'mask-position')
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def default_load_bal_mask_pos
|
|
273
|
+
config_get_default('itd_service', 'load_bal_mask_pos')
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
def load_bal_method_bundle_hash
|
|
277
|
+
val = default_load_bal_method_bundle_hash
|
|
278
|
+
match = lb_get
|
|
279
|
+
return val if match.nil?
|
|
280
|
+
match.names.include?('bundle_hash') ? match[:bundle_hash] : val
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def load_bal_method_bundle_hash=(bh)
|
|
284
|
+
@set_args[:bundle_hash] = bh
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
def default_load_bal_method_bundle_hash
|
|
288
|
+
config_get_default('itd_service', 'load_bal_method_bundle_hash')
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
def load_bal_method_bundle_select
|
|
292
|
+
val = Utils.extract_value(lb_get, 'bundle_select', 'method')
|
|
293
|
+
return default_load_bal_method_bundle_select if val.nil?
|
|
294
|
+
val
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
def load_bal_method_bundle_select=(bs)
|
|
298
|
+
@set_args[:bundle_select] =
|
|
299
|
+
Utils.attach_prefix(bs, :bundle_select, 'method')
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def default_load_bal_method_bundle_select
|
|
303
|
+
config_get_default('itd_service', 'load_bal_method_bundle_select')
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
def load_bal_method_end_port
|
|
307
|
+
val = default_load_bal_method_end_port
|
|
308
|
+
match = lb_get
|
|
309
|
+
return val if match.nil?
|
|
310
|
+
match.names.include?('end_port') ? match[:end_port].to_i : val
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
def load_bal_method_end_port=(enport)
|
|
314
|
+
@set_args[:endPort] = enport
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
def default_load_bal_method_end_port
|
|
318
|
+
config_get_default('itd_service', 'load_bal_method_end_port')
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
def load_bal_method_start_port
|
|
322
|
+
val = Utils.extract_value(lb_get, 'start_port', 'range')
|
|
323
|
+
return default_load_bal_method_start_port if val.nil?
|
|
324
|
+
val.to_i
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
def load_bal_method_start_port=(start)
|
|
328
|
+
@set_args[:start_port] = Utils.attach_prefix(start, :start_port, 'range')
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
def default_load_bal_method_start_port
|
|
332
|
+
config_get_default('itd_service', 'load_bal_method_start_port')
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def load_bal_method_proto
|
|
336
|
+
val = default_load_bal_method_proto
|
|
337
|
+
match = lb_get
|
|
338
|
+
return val if match.nil?
|
|
339
|
+
match.names.include?('proto') ? match[:proto] : val
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
def load_bal_method_proto=(proto)
|
|
343
|
+
@set_args[:proto] = proto
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def default_load_bal_method_proto
|
|
347
|
+
config_get_default('itd_service', 'load_bal_method_proto')
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def load_bal_enable
|
|
351
|
+
lb_get.nil? ? default_load_bal_enable : true
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def load_bal_enable=(enable)
|
|
355
|
+
@set_args[:state] = enable ? '' : 'no'
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
def default_load_bal_enable
|
|
359
|
+
config_get_default('itd_service', 'load_bal_enable')
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
def load_balance_set(attrs)
|
|
363
|
+
set_args_keys_default
|
|
364
|
+
set_args_keys(attrs)
|
|
365
|
+
[:load_bal_buckets,
|
|
366
|
+
:load_bal_mask_pos,
|
|
367
|
+
:load_bal_method_bundle_hash,
|
|
368
|
+
:load_bal_method_bundle_select,
|
|
369
|
+
:load_bal_method_end_port,
|
|
370
|
+
:load_bal_method_start_port,
|
|
371
|
+
:load_bal_method_proto,
|
|
372
|
+
:load_bal_enable,
|
|
373
|
+
].each do |p|
|
|
374
|
+
attrs[p] = '' if attrs[p].nil? || attrs[p] == false
|
|
375
|
+
send(p.to_s + '=', attrs[p])
|
|
376
|
+
end
|
|
377
|
+
# for boolean we need to do this
|
|
378
|
+
send('load_bal_enable=', false) if attrs[:load_bal_enable] == ''
|
|
379
|
+
if Platform.image_version[/9.3\(1\)/] && @set_args[:state] == 'no'
|
|
380
|
+
# In the 9.3(1) release image, the load_balance config cannot
|
|
381
|
+
# be removed using 'no load-balance'. It requires a valid
|
|
382
|
+
# parameter but it can be any parameter, even if not configured.
|
|
383
|
+
# For this version only we send the following command to
|
|
384
|
+
# remove load-balance config: 'no load-balance mask-position 0'
|
|
385
|
+
@set_args[:mask] = 'mask-position 0'
|
|
386
|
+
end
|
|
387
|
+
@get_args = @set_args
|
|
388
|
+
config_set('itd_service', 'load_balance', @set_args)
|
|
389
|
+
set_args_keys_default
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
def nat_destination
|
|
393
|
+
config_get('itd_service', 'nat_destination', @get_args)
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
def nat_destination=(state)
|
|
397
|
+
no_cmd = (state ? '' : 'no')
|
|
398
|
+
@set_args[:state] = no_cmd
|
|
399
|
+
config_set('itd_service', 'nat_destination', @set_args)
|
|
400
|
+
set_args_keys_default
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def default_nat_destination
|
|
404
|
+
config_get_default('itd_service', 'nat_destination')
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
def peer_local
|
|
408
|
+
config_get('itd_service', 'peer_local', @get_args)
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
def peer_local=(val)
|
|
412
|
+
if val.empty?
|
|
413
|
+
@set_args[:state] = 'no'
|
|
414
|
+
current_peer_local = peer_local
|
|
415
|
+
@set_args[:service] = current_peer_local
|
|
416
|
+
config_set('itd_service', 'peer_local', @set_args) unless
|
|
417
|
+
current_peer_local.nil? || current_peer_local.empty?
|
|
418
|
+
else
|
|
419
|
+
@set_args[:state] = ''
|
|
420
|
+
@set_args[:service] = val
|
|
421
|
+
config_set('itd_service', 'peer_local', @set_args)
|
|
422
|
+
end
|
|
423
|
+
set_args_keys_default
|
|
424
|
+
end
|
|
425
|
+
|
|
426
|
+
def default_peer_local
|
|
427
|
+
config_get_default('itd_service', 'peer_local')
|
|
428
|
+
end
|
|
429
|
+
|
|
430
|
+
# peer_vdc is an array of vdc and service
|
|
431
|
+
def peer_vdc
|
|
432
|
+
config_get('itd_service', 'peer_vdc', @get_args)
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
# peer_vdc is an array of vdc and service
|
|
436
|
+
# only one peer_vdc is allowed per service
|
|
437
|
+
# ex: ['switch', 'myservice']
|
|
438
|
+
def peer_vdc=(parray)
|
|
439
|
+
if parray.empty?
|
|
440
|
+
@set_args[:state] = 'no'
|
|
441
|
+
current_peer_vdc = peer_vdc
|
|
442
|
+
@set_args[:vdc] = current_peer_vdc[0]
|
|
443
|
+
@set_args[:service] = current_peer_vdc[1]
|
|
444
|
+
config_set('itd_service', 'peer_vdc', @set_args) unless
|
|
445
|
+
current_peer_vdc[0].nil? || current_peer_vdc[1].nil?
|
|
446
|
+
else
|
|
447
|
+
@set_args[:state] = ''
|
|
448
|
+
@set_args[:vdc] = parray[0]
|
|
449
|
+
@set_args[:service] = parray[1]
|
|
450
|
+
config_set('itd_service', 'peer_vdc', @set_args)
|
|
451
|
+
end
|
|
452
|
+
set_args_keys_default
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
def default_peer_vdc
|
|
456
|
+
config_get_default('itd_service', 'peer_vdc')
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
# show command shows nothing when the service is
|
|
460
|
+
# shutdown which is default, but it shows "no shut"
|
|
461
|
+
# when it is not shut
|
|
462
|
+
def shutdown
|
|
463
|
+
config_get('itd_service', 'shutdown', @get_args)
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
def shutdown=(state)
|
|
467
|
+
no_cmd = (state ? '' : 'no')
|
|
468
|
+
@set_args[:state] = no_cmd
|
|
469
|
+
config_set('itd_service', 'shutdown', @set_args)
|
|
470
|
+
set_args_keys_default
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
def default_shutdown
|
|
474
|
+
config_get_default('itd_service', 'shutdown')
|
|
475
|
+
end
|
|
476
|
+
|
|
477
|
+
def virtual_ip
|
|
478
|
+
config_get('itd_service', 'virtual_ip', @get_args)
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
# VIP is a large string like:
|
|
482
|
+
# virtual ip 2.2.2.2 10.0.0.0 udp 10 advertise enable device-group icmpGroup
|
|
483
|
+
# virtual ip 2.2.2.2 10.0.0.0 udp 10 advertise enable
|
|
484
|
+
# virtual ip 2.2.2.2 10.0.0.0 udp 10
|
|
485
|
+
# virtual ip 2.2.2.2 10.0.0.0
|
|
486
|
+
# all of the above are unique and can be added one after the other
|
|
487
|
+
# the entire string is unique but not individual parts of it
|
|
488
|
+
# currently, only one VIP can be configured due to nxos issue
|
|
489
|
+
# else, the switch crashes, this limitation will be set in
|
|
490
|
+
# puppet manifest. Also remove the current VIPs before configuring more
|
|
491
|
+
def virtual_ip=(values)
|
|
492
|
+
@set_args[:state] = 'no'
|
|
493
|
+
list = virtual_ip
|
|
494
|
+
# remove all the virtual configs first
|
|
495
|
+
list.each do |line|
|
|
496
|
+
@set_args[:string] = line
|
|
497
|
+
config_set('itd_service', 'virtual_ip', @set_args)
|
|
498
|
+
end
|
|
499
|
+
@set_args[:state] = ''
|
|
500
|
+
values.each do |value|
|
|
501
|
+
@set_args[:string] = value
|
|
502
|
+
config_set('itd_service', 'virtual_ip', @set_args)
|
|
503
|
+
end
|
|
504
|
+
set_args_keys_default
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
def default_virtual_ip
|
|
508
|
+
config_get_default('itd_service', 'virtual_ip')
|
|
509
|
+
end
|
|
510
|
+
end # Class
|
|
511
|
+
end # Module
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Cisco Logger Library.
|
|
3
|
+
#
|
|
4
|
+
# January 2015, Jie Yang
|
|
5
|
+
#
|
|
6
|
+
# Copyright (c) 2015 Cisco and/or its affiliates.
|
|
7
|
+
#
|
|
8
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
# you may not use this file except in compliance with the License.
|
|
10
|
+
# You may obtain a copy of the License at
|
|
11
|
+
#
|
|
12
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
#
|
|
14
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
# See the License for the specific language governing permissions and
|
|
18
|
+
# limitations under the License.
|
|
19
|
+
|
|
20
|
+
require 'logger'
|
|
21
|
+
|
|
22
|
+
# Ensure module Cisco is defined
|
|
23
|
+
module Cisco
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Module for logging in CiscoNodeUtils. Will automatically
|
|
27
|
+
# tie into Puppet or Chef logging modules if available.
|
|
28
|
+
module Cisco::Logger
|
|
29
|
+
module_function
|
|
30
|
+
|
|
31
|
+
# Figure out what provider logging utility we
|
|
32
|
+
# should use: Puppet or Chef.
|
|
33
|
+
# If not found use the Ruby Logger/STDOUT/INFO.
|
|
34
|
+
if defined? (Puppet::Util::Logging)
|
|
35
|
+
@@logger = Puppet # rubocop:disable Style/ClassVars
|
|
36
|
+
def error(string)
|
|
37
|
+
@@logger.err(string)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def warn(string)
|
|
41
|
+
@@logger.warning(string)
|
|
42
|
+
end
|
|
43
|
+
else
|
|
44
|
+
if defined? (Chef::Log)
|
|
45
|
+
@@logger = Chef::Log # rubocop:disable Style/ClassVars
|
|
46
|
+
else
|
|
47
|
+
@@logger = Logger.new(STDOUT) # rubocop:disable Style/ClassVars
|
|
48
|
+
@@logger.formatter = proc do |severity, _datetime, _progname, msg|
|
|
49
|
+
"#{severity} -- : #{msg}\n"
|
|
50
|
+
end
|
|
51
|
+
@@logger.level = Logger::INFO
|
|
52
|
+
|
|
53
|
+
def level
|
|
54
|
+
@@logger.level
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def level=(level)
|
|
58
|
+
@@logger.level = level
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def error(string)
|
|
63
|
+
@@logger.error(string)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def warn(string)
|
|
67
|
+
@@logger.warn(string)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def debug(string)
|
|
72
|
+
@@logger.debug(string)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def info(string)
|
|
76
|
+
@@logger.info(string)
|
|
77
|
+
end
|
|
78
|
+
end # module
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NXAPI implementation of NameServer 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
|
+
# NameServer - node utility class for DNS client name server config management
|
|
28
|
+
class NameServer < NodeUtil
|
|
29
|
+
attr_reader :name
|
|
30
|
+
|
|
31
|
+
def initialize(name, instantiate=true)
|
|
32
|
+
unless name.is_a? String
|
|
33
|
+
fail TypeError, "Expected a string, got a #{name.inspect}"
|
|
34
|
+
end
|
|
35
|
+
@name = name
|
|
36
|
+
create if instantiate
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.nameservers
|
|
40
|
+
hosts = config_get('dnsclient', 'name_server')
|
|
41
|
+
return {} if hosts.nil?
|
|
42
|
+
|
|
43
|
+
hash = {}
|
|
44
|
+
# Join and split because config_get returns array of strings separated by
|
|
45
|
+
# spaces (regexes are a subset of PDA)
|
|
46
|
+
hosts.join(' ').split(' ').each do |name|
|
|
47
|
+
hash[name] = NameServer.new(name, false)
|
|
48
|
+
end
|
|
49
|
+
hash
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def ==(other)
|
|
53
|
+
name == other.name
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def create
|
|
57
|
+
config_set('dnsclient', 'name_server', state: '', ip: @name)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def destroy
|
|
61
|
+
config_set('dnsclient', 'name_server', state: 'no', ip: @name)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|