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,378 @@
|
|
1
|
+
# March 2015, Alex Hunsberger
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015-2017 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 'ipaddr'
|
18
|
+
require_relative 'node_util'
|
19
|
+
require_relative 'interface'
|
20
|
+
# Interestingly enough, interface OSPF configuration can exist completely
|
21
|
+
# independent of router OSPF configuration... so we don't need RouterOspf here.
|
22
|
+
|
23
|
+
module Cisco
|
24
|
+
# InterfaceOspf - node utility class for per-interface OSPF config management
|
25
|
+
class InterfaceOspf < NodeUtil
|
26
|
+
attr_reader :intf_name, :ospf_name, :area, :show_name
|
27
|
+
|
28
|
+
def initialize(intf_name, ospf_name, area, create=true, show_name=nil)
|
29
|
+
fail TypeError unless intf_name.is_a? String
|
30
|
+
fail TypeError unless ospf_name.is_a? String
|
31
|
+
fail TypeError unless area.is_a? String
|
32
|
+
fail ArgumentError unless intf_name.length > 0
|
33
|
+
fail ArgumentError unless ospf_name.length > 0
|
34
|
+
fail ArgumentError unless area.length > 0
|
35
|
+
|
36
|
+
# normalize
|
37
|
+
@intf_name = intf_name.downcase
|
38
|
+
@show_name = show_name.nil? ? '' : Utils.normalize_intf_pattern(show_name)
|
39
|
+
fail "interface #{@intf_name} does not exist" if
|
40
|
+
Interface.interfaces(nil, @intf_name)[@intf_name].nil?
|
41
|
+
@ospf_name = ospf_name
|
42
|
+
@area = area
|
43
|
+
@get_args = { name: intf_name, show_name: @show_name }
|
44
|
+
set_args_keys_default
|
45
|
+
|
46
|
+
return unless create
|
47
|
+
Feature.ospf_enable
|
48
|
+
self.area = area
|
49
|
+
end
|
50
|
+
|
51
|
+
def set_args_keys_default
|
52
|
+
@set_args = { name: @intf_name, ospf_name: @ospf_name, area: @area }
|
53
|
+
end
|
54
|
+
|
55
|
+
# can't re-use Interface.interfaces because we need to filter based on
|
56
|
+
# "ip router ospf <name>", which Interface doesn't retrieve
|
57
|
+
def self.interfaces(ospf_name=nil, show_name=nil)
|
58
|
+
fail TypeError unless ospf_name.is_a?(String) || ospf_name.nil?
|
59
|
+
ints = {}
|
60
|
+
show_name = Utils.normalize_intf_pattern(show_name)
|
61
|
+
begin
|
62
|
+
intf_list = config_get('interface_ospf', 'all_interfaces',
|
63
|
+
show_name: show_name)
|
64
|
+
rescue CliError => e
|
65
|
+
raise unless show_name
|
66
|
+
# ignore logical interfaces that do not exist
|
67
|
+
debug 'InterfaceOspf.interfaces ignoring CliError => ' + e.to_s
|
68
|
+
end
|
69
|
+
return ints if intf_list.nil?
|
70
|
+
intf_list.each do |name|
|
71
|
+
# Find interfaces with 'ip router ospf <name> area <area>'
|
72
|
+
match = config_get('interface_ospf', 'area',
|
73
|
+
name: name, show_name: show_name)
|
74
|
+
next if match.nil?
|
75
|
+
ospf = match[0]
|
76
|
+
area = match[1]
|
77
|
+
next unless ospf_name.nil? || ospf == ospf_name
|
78
|
+
int = name.downcase
|
79
|
+
ints[int] = InterfaceOspf.new(int, ospf, area, false, show_name)
|
80
|
+
end
|
81
|
+
ints
|
82
|
+
end
|
83
|
+
|
84
|
+
def area
|
85
|
+
match = config_get('interface_ospf', 'area', @get_args)
|
86
|
+
return nil if match.nil?
|
87
|
+
val = match[1]
|
88
|
+
# Coerce numeric area to the expected dot-decimal format.
|
89
|
+
val = IPAddr.new(val.to_i, Socket::AF_INET).to_s unless val.match(/\./)
|
90
|
+
val
|
91
|
+
end
|
92
|
+
|
93
|
+
def area=(a)
|
94
|
+
config_set('interface_ospf', 'area',
|
95
|
+
@set_args.merge!(state: '', area: a))
|
96
|
+
set_args_keys_default
|
97
|
+
end
|
98
|
+
|
99
|
+
def destroy
|
100
|
+
config_set('interface_ospf', 'area', @set_args.merge!(state: 'no'))
|
101
|
+
set_args_keys_default
|
102
|
+
# Reset everything else back to default as well:
|
103
|
+
self.message_digest = default_message_digest
|
104
|
+
message_digest_key_set(default_message_digest_key_id, '', '', '')
|
105
|
+
self.cost = default_cost
|
106
|
+
destroy_interval('hello_interval')
|
107
|
+
destroy_interval('dead_interval')
|
108
|
+
self.bfd = default_bfd
|
109
|
+
self.mtu_ignore = default_mtu_ignore
|
110
|
+
self.priority = default_priority
|
111
|
+
self.network_type = default_network_type
|
112
|
+
self.passive_interface = default_passive_interface if passive_interface
|
113
|
+
self.shutdown = default_shutdown
|
114
|
+
self.transmit_delay = default_transmit_delay
|
115
|
+
end
|
116
|
+
|
117
|
+
def default_message_digest
|
118
|
+
config_get_default('interface_ospf', 'message_digest')
|
119
|
+
end
|
120
|
+
|
121
|
+
def message_digest
|
122
|
+
config_get('interface_ospf', 'message_digest', @get_args)
|
123
|
+
end
|
124
|
+
|
125
|
+
def message_digest=(enable)
|
126
|
+
return if enable == message_digest
|
127
|
+
@set_args[:state] = (enable ? '' : 'no')
|
128
|
+
config_set('interface_ospf', 'message_digest', @set_args)
|
129
|
+
set_args_keys_default
|
130
|
+
end
|
131
|
+
|
132
|
+
def default_message_digest_key_id
|
133
|
+
config_get_default('interface_ospf', 'message_digest_key_id')
|
134
|
+
end
|
135
|
+
|
136
|
+
def message_digest_key_id
|
137
|
+
config_get('interface_ospf', 'message_digest_key_id', @get_args)
|
138
|
+
end
|
139
|
+
|
140
|
+
def default_message_digest_algorithm_type
|
141
|
+
config_get_default('interface_ospf',
|
142
|
+
'message_digest_alg_type').to_sym
|
143
|
+
end
|
144
|
+
|
145
|
+
def message_digest_algorithm_type
|
146
|
+
match = config_get('interface_ospf', 'message_digest_alg_type',
|
147
|
+
@get_args)
|
148
|
+
match.to_sym
|
149
|
+
end
|
150
|
+
|
151
|
+
def default_message_digest_encryption_type
|
152
|
+
Encryption.cli_to_symbol(
|
153
|
+
config_get_default('interface_ospf', 'message_digest_enc_type'))
|
154
|
+
end
|
155
|
+
|
156
|
+
def message_digest_encryption_type
|
157
|
+
match = config_get('interface_ospf', 'message_digest_enc_type',
|
158
|
+
@get_args)
|
159
|
+
Encryption.cli_to_symbol(match)
|
160
|
+
end
|
161
|
+
|
162
|
+
def message_digest_password
|
163
|
+
config_get('interface_ospf', 'message_digest_password', @get_args)
|
164
|
+
end
|
165
|
+
|
166
|
+
def default_message_digest_password
|
167
|
+
config_get_default('interface_ospf', 'message_digest_password')
|
168
|
+
end
|
169
|
+
|
170
|
+
def message_digest_key_set(keyid, algtype, enctype, password)
|
171
|
+
current_keyid = message_digest_key_id
|
172
|
+
if keyid == default_message_digest_key_id && current_keyid != keyid
|
173
|
+
@set_args.merge!(state: 'no',
|
174
|
+
keyid: current_keyid,
|
175
|
+
algtype: '',
|
176
|
+
enctype: '',
|
177
|
+
password: '')
|
178
|
+
config_set('interface_ospf', 'message_digest_key_set', @set_args)
|
179
|
+
elsif keyid != default_message_digest_key_id
|
180
|
+
fail TypeError unless password.is_a?(String)
|
181
|
+
fail ArgumentError unless password.length > 0
|
182
|
+
enctype = Encryption.symbol_to_cli(enctype)
|
183
|
+
@set_args.merge!(state: '',
|
184
|
+
keyid: keyid,
|
185
|
+
algtype: algtype,
|
186
|
+
enctype: enctype,
|
187
|
+
password: password)
|
188
|
+
config_set('interface_ospf', 'message_digest_key_set', @set_args)
|
189
|
+
end
|
190
|
+
set_args_keys_default
|
191
|
+
end
|
192
|
+
|
193
|
+
def cost
|
194
|
+
config_get('interface_ospf', 'cost', @get_args)
|
195
|
+
end
|
196
|
+
|
197
|
+
def default_cost
|
198
|
+
config_get_default('interface_ospf', 'cost')
|
199
|
+
end
|
200
|
+
|
201
|
+
def cost=(c)
|
202
|
+
if c == default_cost
|
203
|
+
@set_args.merge!(state: 'no', cost: '')
|
204
|
+
else
|
205
|
+
@set_args.merge!(state: '', cost: c)
|
206
|
+
end
|
207
|
+
config_set('interface_ospf', 'cost', @set_args)
|
208
|
+
set_args_keys_default
|
209
|
+
end
|
210
|
+
|
211
|
+
def hello_interval
|
212
|
+
config_get('interface_ospf', 'hello_interval', @get_args)
|
213
|
+
end
|
214
|
+
|
215
|
+
def default_hello_interval
|
216
|
+
config_get_default('interface_ospf', 'hello_interval')
|
217
|
+
end
|
218
|
+
|
219
|
+
def hello_interval=(interval)
|
220
|
+
# Previous behavior always sets interval and ignores 'no' cmd
|
221
|
+
@set_args.merge!(state: '', interval: interval.to_i)
|
222
|
+
config_set('interface_ospf', 'hello_interval', @set_args)
|
223
|
+
set_args_keys_default
|
224
|
+
end
|
225
|
+
|
226
|
+
def destroy_interval(prop)
|
227
|
+
# Helper to remove cli completely
|
228
|
+
@set_args.merge!(state: 'no', interval: '')
|
229
|
+
config_set('interface_ospf', prop, @set_args)
|
230
|
+
set_args_keys_default
|
231
|
+
end
|
232
|
+
|
233
|
+
def dead_interval
|
234
|
+
config_get('interface_ospf', 'dead_interval', @get_args)
|
235
|
+
end
|
236
|
+
|
237
|
+
def default_dead_interval
|
238
|
+
config_get_default('interface_ospf', 'dead_interval')
|
239
|
+
end
|
240
|
+
|
241
|
+
def dead_interval=(interval)
|
242
|
+
# Previous behavior always sets interval and ignores 'no' cmd
|
243
|
+
@set_args.merge!(state: '', interval: interval.to_i)
|
244
|
+
config_set('interface_ospf', 'dead_interval', @set_args)
|
245
|
+
set_args_keys_default
|
246
|
+
end
|
247
|
+
|
248
|
+
# CLI can be either of the following or none
|
249
|
+
# ip ospf bfd
|
250
|
+
# ip ospf bfd disable
|
251
|
+
def bfd
|
252
|
+
val = config_get('interface_ospf', 'bfd', @get_args)
|
253
|
+
return if val.nil?
|
254
|
+
val.include?('disable') ? false : true
|
255
|
+
end
|
256
|
+
|
257
|
+
def bfd=(val)
|
258
|
+
return if val == bfd
|
259
|
+
Feature.bfd_enable
|
260
|
+
state = (val == default_bfd) ? 'no' : ''
|
261
|
+
disable = val ? '' : 'disable'
|
262
|
+
config_set('interface_ospf', 'bfd',
|
263
|
+
@set_args.merge!(state: state, disable: disable))
|
264
|
+
set_args_keys_default
|
265
|
+
end
|
266
|
+
|
267
|
+
def default_bfd
|
268
|
+
config_get_default('interface_ospf', 'bfd')
|
269
|
+
end
|
270
|
+
|
271
|
+
def default_network_type
|
272
|
+
case @intf_name
|
273
|
+
when /loopback/i
|
274
|
+
lookup = 'network_type_loopback_default'
|
275
|
+
else
|
276
|
+
lookup = 'network_type_default'
|
277
|
+
end
|
278
|
+
config_get_default('interface_ospf', lookup)
|
279
|
+
end
|
280
|
+
|
281
|
+
def mtu_ignore
|
282
|
+
config_get('interface_ospf', 'mtu_ignore', @get_args)
|
283
|
+
end
|
284
|
+
|
285
|
+
def mtu_ignore=(enable)
|
286
|
+
@set_args[:state] = enable ? '' : 'no'
|
287
|
+
config_set('interface_ospf', 'mtu_ignore', @set_args)
|
288
|
+
set_args_keys_default
|
289
|
+
end
|
290
|
+
|
291
|
+
def default_mtu_ignore
|
292
|
+
config_get_default('interface_ospf', 'mtu_ignore')
|
293
|
+
end
|
294
|
+
|
295
|
+
def network_type
|
296
|
+
type = config_get('interface_ospf', 'network_type', @get_args)
|
297
|
+
return 'p2p' if type == 'point-to-point'
|
298
|
+
return default_network_type if type.nil?
|
299
|
+
type
|
300
|
+
end
|
301
|
+
|
302
|
+
def network_type=(type)
|
303
|
+
if type == default_network_type
|
304
|
+
@set_args.merge!(state: 'no', network_type: '')
|
305
|
+
else
|
306
|
+
network = 'point-to-point' if type.to_s == 'p2p'
|
307
|
+
@set_args.merge!(state: '', network_type: network)
|
308
|
+
end
|
309
|
+
config_set('interface_ospf', 'network_type', @set_args)
|
310
|
+
set_args_keys_default
|
311
|
+
end
|
312
|
+
|
313
|
+
def default_passive_interface
|
314
|
+
config_get_default('interface_ospf', 'passive_interface')
|
315
|
+
end
|
316
|
+
|
317
|
+
def passive_interface
|
318
|
+
config_get('interface_ospf', 'passive_interface', @get_args)
|
319
|
+
end
|
320
|
+
|
321
|
+
def passive_interface=(enable)
|
322
|
+
fail TypeError unless enable == true || enable == false
|
323
|
+
@set_args[:state] = enable ? '' : 'no'
|
324
|
+
config_set('interface_ospf', 'passive_interface', @set_args)
|
325
|
+
set_args_keys_default
|
326
|
+
end
|
327
|
+
|
328
|
+
def priority
|
329
|
+
config_get('interface_ospf', 'priority', @get_args)
|
330
|
+
end
|
331
|
+
|
332
|
+
def priority=(val)
|
333
|
+
if val == default_priority
|
334
|
+
@set_args.merge!(state: 'no', priority: '')
|
335
|
+
else
|
336
|
+
@set_args.merge!(state: '', priority: val)
|
337
|
+
end
|
338
|
+
config_set('interface_ospf', 'priority', @set_args)
|
339
|
+
set_args_keys_default
|
340
|
+
end
|
341
|
+
|
342
|
+
def default_priority
|
343
|
+
config_get_default('interface_ospf', 'priority')
|
344
|
+
end
|
345
|
+
|
346
|
+
def shutdown
|
347
|
+
config_get('interface_ospf', 'shutdown', @get_args)
|
348
|
+
end
|
349
|
+
|
350
|
+
def shutdown=(enable)
|
351
|
+
@set_args[:state] = enable ? '' : 'no'
|
352
|
+
config_set('interface_ospf', 'shutdown', @set_args)
|
353
|
+
set_args_keys_default
|
354
|
+
end
|
355
|
+
|
356
|
+
def default_shutdown
|
357
|
+
config_get_default('interface_ospf', 'shutdown')
|
358
|
+
end
|
359
|
+
|
360
|
+
def transmit_delay
|
361
|
+
config_get('interface_ospf', 'transmit_delay', @get_args)
|
362
|
+
end
|
363
|
+
|
364
|
+
def transmit_delay=(val)
|
365
|
+
if val == default_transmit_delay
|
366
|
+
@set_args.merge!(state: 'no', delay: '')
|
367
|
+
else
|
368
|
+
@set_args.merge!(state: '', delay: val)
|
369
|
+
end
|
370
|
+
config_set('interface_ospf', 'transmit_delay', @set_args)
|
371
|
+
set_args_keys_default
|
372
|
+
end
|
373
|
+
|
374
|
+
def default_transmit_delay
|
375
|
+
config_get_default('interface_ospf', 'transmit_delay')
|
376
|
+
end
|
377
|
+
end
|
378
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
# December 2015, Sai Chintalapudi
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015-2017 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
|
+
require_relative 'interface'
|
19
|
+
|
20
|
+
# Add some interface-specific constants to the Cisco namespace
|
21
|
+
module Cisco
|
22
|
+
# InterfacePortChannel - node utility class for port channel config management
|
23
|
+
class InterfacePortChannel < NodeUtil
|
24
|
+
attr_reader :name
|
25
|
+
|
26
|
+
def initialize(name, instantiate=true)
|
27
|
+
fail TypeError unless name.is_a?(String)
|
28
|
+
fail ArgumentError unless name.length > 0
|
29
|
+
@name = name.downcase
|
30
|
+
fail ArgumentError unless @name.start_with?('port-channel')
|
31
|
+
|
32
|
+
create if instantiate
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
"interface_port_channel #{name}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.interfaces
|
40
|
+
hash = {}
|
41
|
+
intf_list = config_get('interface_portchannel', 'all_interfaces')
|
42
|
+
return hash if intf_list.nil?
|
43
|
+
|
44
|
+
intf_list.each do |id|
|
45
|
+
id = id.downcase
|
46
|
+
next unless id.start_with?('port-channel')
|
47
|
+
hash[id] = InterfacePortChannel.new(id, false)
|
48
|
+
end
|
49
|
+
hash
|
50
|
+
end
|
51
|
+
|
52
|
+
def create
|
53
|
+
config_set('interface_portchannel', 'create', @name)
|
54
|
+
end
|
55
|
+
|
56
|
+
def destroy
|
57
|
+
config_set('interface_portchannel', 'destroy', @name)
|
58
|
+
end
|
59
|
+
|
60
|
+
########################################################
|
61
|
+
# PROPERTIES #
|
62
|
+
########################################################
|
63
|
+
|
64
|
+
def bfd_per_link
|
65
|
+
config_get('interface_portchannel', 'bfd_per_link', @name)
|
66
|
+
end
|
67
|
+
|
68
|
+
def bfd_per_link=(state)
|
69
|
+
return if state == bfd_per_link
|
70
|
+
no_cmd = (state ? '' : 'no')
|
71
|
+
Feature.bfd_enable
|
72
|
+
config_set('interface_portchannel',
|
73
|
+
'bfd_per_link', @name, no_cmd)
|
74
|
+
end
|
75
|
+
|
76
|
+
def default_bfd_per_link
|
77
|
+
config_get_default('interface_portchannel', 'bfd_per_link')
|
78
|
+
end
|
79
|
+
|
80
|
+
def lacp_graceful_convergence
|
81
|
+
config_get('interface_portchannel', 'lacp_graceful_convergence', @name)
|
82
|
+
end
|
83
|
+
|
84
|
+
def lacp_graceful_convergence=(state)
|
85
|
+
no_cmd = (state ? '' : 'no')
|
86
|
+
config_set('interface_portchannel',
|
87
|
+
'lacp_graceful_convergence', @name, no_cmd)
|
88
|
+
end
|
89
|
+
|
90
|
+
def default_lacp_graceful_convergence
|
91
|
+
config_get_default('interface_portchannel', 'lacp_graceful_convergence')
|
92
|
+
end
|
93
|
+
|
94
|
+
def lacp_max_bundle
|
95
|
+
config_get('interface_portchannel', 'lacp_max_bundle', @name)
|
96
|
+
end
|
97
|
+
|
98
|
+
def lacp_max_bundle=(val)
|
99
|
+
config_set('interface_portchannel', 'lacp_max_bundle', @name, val)
|
100
|
+
end
|
101
|
+
|
102
|
+
def default_lacp_max_bundle
|
103
|
+
config_get_default('interface_portchannel', 'lacp_max_bundle')
|
104
|
+
end
|
105
|
+
|
106
|
+
def lacp_min_links
|
107
|
+
config_get('interface_portchannel', 'lacp_min_links', @name)
|
108
|
+
end
|
109
|
+
|
110
|
+
def lacp_min_links=(val)
|
111
|
+
config_set('interface_portchannel', 'lacp_min_links', @name, val)
|
112
|
+
end
|
113
|
+
|
114
|
+
def default_lacp_min_links
|
115
|
+
config_get_default('interface_portchannel', 'lacp_min_links')
|
116
|
+
end
|
117
|
+
|
118
|
+
def lacp_suspend_shut_needed?
|
119
|
+
config_get('interface_portchannel', 'lacp_suspend_shut_needed')
|
120
|
+
end
|
121
|
+
|
122
|
+
def lacp_suspend_individual
|
123
|
+
config_get('interface_portchannel', 'lacp_suspend_individual', @name)
|
124
|
+
end
|
125
|
+
|
126
|
+
def lacp_suspend_individual=(state)
|
127
|
+
no_cmd = (state ? '' : 'no')
|
128
|
+
# This property can only be set if the port-channel is shutdown on
|
129
|
+
# some platforms.
|
130
|
+
# This setter will:
|
131
|
+
# 1) Query the current state of the port-channel interface.
|
132
|
+
# 2) Shutdown the port-channel interface if needed.
|
133
|
+
# 3) Set the lacp_suspend_individual property.
|
134
|
+
# 4) Restore the original state of the port-channel interface if needed.
|
135
|
+
int = Interface.new(@name, false)
|
136
|
+
current_state = int.shutdown
|
137
|
+
int.shutdown = true if lacp_suspend_shut_needed? && !current_state
|
138
|
+
config_set('interface_portchannel',
|
139
|
+
'lacp_suspend_individual', @name, no_cmd)
|
140
|
+
int.shutdown = current_state unless current_state == int.shutdown
|
141
|
+
end
|
142
|
+
|
143
|
+
def default_lacp_suspend_individual
|
144
|
+
config_get_default('interface_portchannel', 'lacp_suspend_individual')
|
145
|
+
end
|
146
|
+
|
147
|
+
def port_hash_distribution
|
148
|
+
config_get('interface_portchannel', 'port_hash_distribution', @name)
|
149
|
+
end
|
150
|
+
|
151
|
+
def port_hash_distribution=(val)
|
152
|
+
if val
|
153
|
+
state = ''
|
154
|
+
else
|
155
|
+
state = 'no'
|
156
|
+
val = ''
|
157
|
+
end
|
158
|
+
config_set('interface_portchannel',
|
159
|
+
'port_hash_distribution', @name, state, val)
|
160
|
+
end
|
161
|
+
|
162
|
+
def default_port_hash_distribution
|
163
|
+
config_get_default('interface_portchannel', 'port_hash_distribution')
|
164
|
+
end
|
165
|
+
|
166
|
+
def port_load_defer
|
167
|
+
config_get('interface_portchannel', 'port_load_defer', @name)
|
168
|
+
end
|
169
|
+
|
170
|
+
def port_load_defer=(state)
|
171
|
+
no_cmd = (state ? '' : 'no')
|
172
|
+
config_set('interface_portchannel',
|
173
|
+
'port_load_defer', @name, no_cmd)
|
174
|
+
end
|
175
|
+
|
176
|
+
def default_port_load_defer
|
177
|
+
config_get_default('interface_portchannel', 'port_load_defer')
|
178
|
+
end
|
179
|
+
end # Class
|
180
|
+
end # Module
|
@@ -0,0 +1,132 @@
|
|
1
|
+
# December 2015, Chris Van Heuveln
|
2
|
+
#
|
3
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require_relative 'node_util'
|
18
|
+
require_relative 'feature'
|
19
|
+
|
20
|
+
module Cisco
|
21
|
+
# InterfaceServiceVni - node utility class for Service VNI Instance commands
|
22
|
+
class InterfaceServiceVni < NodeUtil
|
23
|
+
attr_reader :name
|
24
|
+
|
25
|
+
def initialize(intf, sid, instantiate=true)
|
26
|
+
@name = intf.to_s.downcase
|
27
|
+
@sid = sid.to_s
|
28
|
+
fail ArgumentError if @name.empty? || @sid.empty?
|
29
|
+
set_args_keys_default
|
30
|
+
create if instantiate
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_s
|
34
|
+
"interface_service_vni #{name} #{@sid}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.svc_vni_ids
|
38
|
+
hash = {}
|
39
|
+
intf_list = config_get('interface_service_vni', 'all_interfaces')
|
40
|
+
return hash if intf_list.nil?
|
41
|
+
|
42
|
+
intf_list.each do |intf|
|
43
|
+
intf.downcase!
|
44
|
+
svc_ids = config_get('interface_service_vni', 'all_service_vni_ids',
|
45
|
+
name: intf)
|
46
|
+
next if svc_ids.nil?
|
47
|
+
hash[intf] = {}
|
48
|
+
svc_ids.each do |sid|
|
49
|
+
hash[intf][sid] = InterfaceServiceVni.new(intf, sid, false)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
hash
|
53
|
+
end
|
54
|
+
|
55
|
+
def create
|
56
|
+
Feature.vni_enable
|
57
|
+
@set_args[:state] = ''
|
58
|
+
config_set('interface_service_vni', 'create_destroy', @set_args)
|
59
|
+
end
|
60
|
+
|
61
|
+
def destroy
|
62
|
+
@set_args[:state] = 'no'
|
63
|
+
config_set('interface_service_vni', 'create_destroy', @set_args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_args_keys_default
|
67
|
+
keys = { name: @name, sid: @sid }
|
68
|
+
@get_args = @set_args = keys
|
69
|
+
end
|
70
|
+
|
71
|
+
# rubocop:disable Style/AccessorMethodName
|
72
|
+
def set_args_keys(hash={})
|
73
|
+
set_args_keys_default
|
74
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
75
|
+
end
|
76
|
+
# rubocop:enable Style/AccessorMethodNamefor
|
77
|
+
|
78
|
+
########################################################
|
79
|
+
# PROPERTIES #
|
80
|
+
########################################################
|
81
|
+
|
82
|
+
#
|
83
|
+
# encapsulation_profile_vni
|
84
|
+
#
|
85
|
+
# cli: service instance 1 vni
|
86
|
+
# encapsulation profile vni_500_5000 default
|
87
|
+
# type: 'vni_500_5000'
|
88
|
+
def encapsulation_profile_vni
|
89
|
+
config_get('interface_service_vni', 'encapsulation_profile_vni',
|
90
|
+
@get_args)
|
91
|
+
end
|
92
|
+
|
93
|
+
def encapsulation_profile_vni=(profile)
|
94
|
+
Feature.vni_enable
|
95
|
+
state = profile.empty? ? 'no' : ''
|
96
|
+
current = encapsulation_profile_vni
|
97
|
+
|
98
|
+
if state[/no/]
|
99
|
+
config_set('interface_service_vni', 'encapsulation_profile_vni',
|
100
|
+
set_args_keys(state: state, profile: current)) unless
|
101
|
+
current.empty?
|
102
|
+
else
|
103
|
+
# Remove current profile before adding a new one
|
104
|
+
config_set('interface_service_vni', 'encapsulation_profile_vni',
|
105
|
+
set_args_keys(state: 'no', profile: current)) unless
|
106
|
+
current.empty?
|
107
|
+
config_set('interface_service_vni', 'encapsulation_profile_vni',
|
108
|
+
set_args_keys(state: state, profile: profile))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def default_encapsulation_profile_vni
|
113
|
+
config_get_default('interface_service_vni', 'encapsulation_profile_vni')
|
114
|
+
end
|
115
|
+
|
116
|
+
#
|
117
|
+
# shutdown
|
118
|
+
#
|
119
|
+
def shutdown
|
120
|
+
config_get('interface_service_vni', 'shutdown', @get_args)
|
121
|
+
end
|
122
|
+
|
123
|
+
def shutdown=(state)
|
124
|
+
config_set('interface_service_vni', 'shutdown',
|
125
|
+
set_args_keys(state: state ? '' : 'no'))
|
126
|
+
end
|
127
|
+
|
128
|
+
def default_shutdown
|
129
|
+
config_get_default('interface_service_vni', 'shutdown')
|
130
|
+
end
|
131
|
+
end # Class
|
132
|
+
end # Module
|