cisco_node_utils 1.1.0 → 1.2.0
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 +4 -4
- data/.gitignore +2 -1
- data/CHANGELOG.md +126 -1
- data/README.md +19 -12
- data/Rakefile +1 -0
- data/bin/git/hooks/commit-msg/enforce_style +8 -0
- data/cisco_node_utils.gemspec +4 -3
- data/docs/README-develop-best-practices.md +127 -109
- data/docs/README-develop-node-utils-APIs.md +47 -39
- data/docs/template-router.rb +3 -7
- data/lib/.rubocop.yml +4 -4
- data/lib/cisco_node_utils.rb +1 -1
- data/lib/cisco_node_utils/aaa_authentication_login.rb +96 -0
- data/lib/cisco_node_utils/aaa_authentication_login_service.rb +133 -0
- data/lib/cisco_node_utils/aaa_authorization_service.rb +150 -0
- data/lib/cisco_node_utils/ace.rb +196 -0
- data/lib/cisco_node_utils/acl.rb +100 -0
- data/lib/cisco_node_utils/bgp.rb +301 -163
- data/lib/cisco_node_utils/bgp_af.rb +187 -19
- data/lib/cisco_node_utils/bgp_neighbor.rb +18 -33
- data/lib/cisco_node_utils/bgp_neighbor_af.rb +25 -48
- data/lib/cisco_node_utils/cisco_cmn_utils.rb +23 -4
- data/lib/cisco_node_utils/cmd_ref/README_YAML.md +593 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_auth_login_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authentication_login.yaml +31 -0
- data/lib/cisco_node_utils/cmd_ref/aaa_authorization_service.yaml +22 -0
- data/lib/cisco_node_utils/cmd_ref/acl.yaml +43 -0
- data/lib/cisco_node_utils/cmd_ref/bgp.yaml +242 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_af.yaml +164 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor.yaml +131 -0
- data/lib/cisco_node_utils/cmd_ref/bgp_neighbor_af.yaml +179 -0
- data/lib/cisco_node_utils/cmd_ref/dnsclient.yaml +34 -0
- data/lib/cisco_node_utils/cmd_ref/evpn_vni.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath.yaml +172 -0
- data/lib/cisco_node_utils/cmd_ref/fabricpath_topology.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/feature.yaml +42 -0
- data/lib/cisco_node_utils/cmd_ref/fex.yaml +9 -0
- data/lib/cisco_node_utils/cmd_ref/images.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/interface.yaml +339 -0
- data/lib/cisco_node_utils/cmd_ref/interface_channel_group.yaml +28 -0
- data/lib/cisco_node_utils/cmd_ref/interface_ospf.yaml +61 -0
- data/lib/cisco_node_utils/cmd_ref/interface_portchannel.yaml +54 -0
- data/lib/cisco_node_utils/cmd_ref/interface_service_vni.yaml +32 -0
- data/lib/cisco_node_utils/cmd_ref/inventory.yaml +45 -0
- data/lib/cisco_node_utils/cmd_ref/memory.yaml +13 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_config.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/ntp_server.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/ospf.yaml +74 -0
- data/lib/cisco_node_utils/cmd_ref/overlay_global.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/pim.yaml +40 -0
- data/lib/cisco_node_utils/cmd_ref/portchannel_global.yaml +69 -0
- data/lib/cisco_node_utils/cmd_ref/radius_global.yaml +25 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server.yaml +64 -0
- data/lib/cisco_node_utils/cmd_ref/radius_server_group.yaml +14 -0
- data/lib/cisco_node_utils/cmd_ref/show_system.yaml +5 -0
- data/lib/cisco_node_utils/cmd_ref/show_version.yaml +72 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_community.yaml +23 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_group.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_notification_receiver.yaml +50 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_server.yaml +51 -0
- data/lib/cisco_node_utils/cmd_ref/snmp_user.yaml +55 -0
- data/lib/cisco_node_utils/cmd_ref/snmpnotification.yaml +11 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_server.yaml +18 -0
- data/lib/cisco_node_utils/cmd_ref/syslog_settings.yaml +7 -0
- data/lib/cisco_node_utils/cmd_ref/system.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server.yaml +49 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_group.yaml +33 -0
- data/lib/cisco_node_utils/cmd_ref/tacacs_server_host.yaml +35 -0
- data/lib/cisco_node_utils/cmd_ref/vdc.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/virtual_service.yaml +6 -0
- data/lib/cisco_node_utils/cmd_ref/vlan.yaml +56 -0
- data/lib/cisco_node_utils/cmd_ref/vni.yaml +76 -0
- data/lib/cisco_node_utils/cmd_ref/vpc.yaml +197 -0
- data/lib/cisco_node_utils/cmd_ref/vrf.yaml +88 -0
- data/lib/cisco_node_utils/cmd_ref/vtp.yaml +38 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep.yaml +60 -0
- data/lib/cisco_node_utils/cmd_ref/vxlan_vtep_vni.yaml +39 -0
- data/lib/cisco_node_utils/cmd_ref/yum.yaml +13 -0
- data/lib/cisco_node_utils/command_reference.rb +359 -187
- data/lib/cisco_node_utils/configparser_lib.rb +1 -1
- data/lib/cisco_node_utils/dns_domain.rb +19 -5
- data/lib/cisco_node_utils/domain_name.rb +4 -8
- data/lib/cisco_node_utils/evpn_vni.rb +157 -0
- data/lib/cisco_node_utils/fabricpath_global.rb +388 -0
- data/lib/cisco_node_utils/fabricpath_topology.rb +150 -0
- data/lib/cisco_node_utils/feature.rb +111 -0
- data/lib/cisco_node_utils/interface.rb +390 -97
- data/lib/cisco_node_utils/interface_channel_group.rb +124 -0
- data/lib/cisco_node_utils/interface_ospf.rb +11 -34
- data/lib/cisco_node_utils/interface_portchannel.rb +157 -0
- data/lib/cisco_node_utils/interface_service_vni.rb +132 -0
- data/lib/cisco_node_utils/name_server.rb +1 -1
- data/lib/cisco_node_utils/node.rb +55 -249
- data/lib/cisco_node_utils/node_util.rb +5 -1
- data/lib/cisco_node_utils/ntp_config.rb +2 -2
- data/lib/cisco_node_utils/ntp_server.rb +14 -5
- data/lib/cisco_node_utils/overlay_global.rb +153 -0
- data/lib/cisco_node_utils/pim.rb +124 -0
- data/lib/cisco_node_utils/pim_group_list.rb +108 -0
- data/lib/cisco_node_utils/pim_rp_address.rb +102 -0
- data/lib/cisco_node_utils/platform.rb +8 -9
- data/lib/cisco_node_utils/portchannel_global.rb +277 -0
- data/lib/cisco_node_utils/radius_global.rb +9 -19
- data/lib/cisco_node_utils/radius_server.rb +31 -41
- data/lib/cisco_node_utils/radius_server_group.rb +117 -0
- data/lib/cisco_node_utils/router_ospf.rb +1 -1
- data/lib/cisco_node_utils/router_ospf_vrf.rb +14 -19
- data/lib/cisco_node_utils/snmp_notification_receiver.rb +158 -0
- data/lib/cisco_node_utils/snmpcommunity.rb +3 -5
- data/lib/cisco_node_utils/snmpgroup.rb +1 -1
- data/lib/cisco_node_utils/snmpnotification.rb +57 -0
- data/lib/cisco_node_utils/snmpserver.rb +8 -17
- data/lib/cisco_node_utils/snmpuser.rb +67 -28
- data/lib/cisco_node_utils/syslog_server.rb +3 -9
- data/lib/cisco_node_utils/syslog_settings.rb +2 -10
- data/lib/cisco_node_utils/tacacs_server.rb +9 -14
- data/lib/cisco_node_utils/tacacs_server_group.rb +145 -0
- data/lib/cisco_node_utils/tacacs_server_host.rb +5 -9
- data/lib/cisco_node_utils/vdc.rb +88 -0
- data/lib/cisco_node_utils/version.rb +5 -2
- data/lib/cisco_node_utils/vlan.rb +71 -8
- data/lib/cisco_node_utils/vni.rb +227 -0
- data/lib/cisco_node_utils/vpc.rb +377 -0
- data/lib/cisco_node_utils/vrf.rb +60 -9
- data/lib/cisco_node_utils/vrf_af.rb +191 -0
- data/lib/cisco_node_utils/vtp.rb +8 -6
- data/lib/cisco_node_utils/vxlan_vtep.rb +151 -0
- data/lib/cisco_node_utils/vxlan_vtep_vni.rb +234 -0
- data/lib/cisco_node_utils/yum.rb +1 -1
- data/tests/.rubocop.yml +1 -1
- data/tests/basetest.rb +16 -7
- data/tests/ciscotest.rb +55 -13
- data/tests/cmd_config.yaml +2 -2
- data/tests/platform_info.rb +3 -2
- data/tests/test_aaa_authentication_login.rb +219 -0
- data/tests/test_aaa_authentication_login_service.rb +759 -0
- data/tests/test_aaa_authorization_service.rb +1041 -0
- data/tests/test_ace.rb +160 -0
- data/tests/test_acl.rb +176 -0
- data/tests/test_bgp_af.rb +269 -13
- data/tests/test_bgp_neighbor.rb +38 -40
- data/tests/test_bgp_neighbor_af.rb +92 -32
- data/tests/test_command_config.rb +5 -5
- data/tests/test_command_reference.rb +284 -101
- data/tests/test_dns_domain.rb +1 -1
- data/tests/test_domain_name.rb +1 -1
- data/tests/test_evpn_vni.rb +106 -0
- data/tests/test_fabricpath_global.rb +243 -0
- data/tests/test_fabricpath_topology.rb +98 -0
- data/tests/test_interface.rb +292 -74
- data/tests/test_interface_channel_group.rb +74 -0
- data/tests/test_interface_ospf.rb +9 -4
- data/tests/test_interface_portchannel.rb +105 -0
- data/tests/test_interface_service_vni.rb +232 -0
- data/tests/test_interface_svi.rb +77 -62
- data/tests/test_interface_switchport.rb +17 -5
- data/tests/test_name_server.rb +1 -1
- data/tests/test_node.rb +1 -1
- data/tests/test_node_ext.rb +10 -20
- data/tests/test_ntp_config.rb +1 -1
- data/tests/test_ntp_server.rb +18 -6
- data/tests/test_overlay_global.rb +102 -0
- data/tests/test_pim.rb +177 -0
- data/tests/test_pim_group_list.rb +181 -0
- data/tests/test_pim_rp_address.rb +153 -0
- data/tests/test_platform.rb +3 -3
- data/tests/test_portchannel_global.rb +202 -0
- data/tests/test_radius_global.rb +1 -1
- data/tests/test_radius_server.rb +92 -57
- data/tests/test_radius_server_group.rb +149 -0
- data/tests/test_router_bgp.rb +283 -112
- data/tests/test_router_ospf.rb +2 -2
- data/tests/test_router_ospf_vrf.rb +4 -4
- data/tests/test_snmp_notification_receiver.rb +167 -0
- data/tests/test_snmpcommunity.rb +1 -1
- data/tests/test_snmpgroup.rb +1 -1
- data/tests/test_snmpnotification.rb +72 -0
- data/tests/test_snmpserver.rb +29 -105
- data/tests/test_snmpuser.rb +32 -30
- data/tests/test_syslog_server.rb +36 -10
- data/tests/test_syslog_settings.rb +1 -1
- data/tests/test_tacacs_server.rb +1 -1
- data/tests/test_tacacs_server_group.rb +405 -0
- data/tests/test_tacacs_server_host.rb +1 -1
- data/tests/test_vdc.rb +78 -0
- data/tests/test_vlan.rb +74 -19
- data/tests/test_vlan_mt_full.rb +95 -0
- data/tests/test_vni.rb +106 -0
- data/tests/test_vpc.rb +361 -0
- data/tests/test_vrf.rb +172 -29
- data/tests/test_vtp.rb +1 -1
- data/tests/test_vxlan_vtep.rb +214 -0
- data/tests/test_vxlan_vtep_vni.rb +201 -0
- data/tests/test_yum.rb +1 -1
- metadata +120 -11
- data/lib/cisco_node_utils/README_YAML.md +0 -325
- data/lib/cisco_node_utils/command_reference_common.yaml +0 -1051
- data/lib/cisco_node_utils/command_reference_common_bgp.yaml +0 -535
- data/lib/cisco_node_utils/command_reference_n3064.yaml +0 -13
- data/lib/cisco_node_utils/command_reference_n7k.yaml +0 -52
- data/lib/cisco_node_utils/command_reference_n9k.yaml +0 -26
- data/tests/platform_info.yaml +0 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Shared Library to compare configurations.
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c) 2013-
|
|
3
|
+
# Copyright (c) 2013-2016 Cisco and/or its affiliates.
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
6
|
# you may not use this file except in compliance with the License.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#
|
|
4
4
|
# September 2015, Hunter Haugen
|
|
5
5
|
#
|
|
6
|
-
# Copyright (c) 2015 Cisco and/or its affiliates.
|
|
6
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
|
7
7
|
#
|
|
8
8
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
9
|
# you may not use this file except in compliance with the License.
|
|
@@ -43,8 +43,6 @@ module Cisco
|
|
|
43
43
|
else
|
|
44
44
|
domains = config_get('dnsclient', 'domain_list_vrf', vrf: vrf)
|
|
45
45
|
end
|
|
46
|
-
return {} if domains.nil?
|
|
47
|
-
|
|
48
46
|
hash = {}
|
|
49
47
|
domains.each do |name|
|
|
50
48
|
hash[name] = DnsDomain.new(name, vrf, false)
|
|
@@ -61,8 +59,24 @@ module Cisco
|
|
|
61
59
|
config_set('dnsclient', 'domain_list',
|
|
62
60
|
state: '', name: @name)
|
|
63
61
|
else
|
|
64
|
-
|
|
65
|
-
|
|
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 10 times
|
|
65
|
+
# with a 1 second delay between attempts before giving up.
|
|
66
|
+
tries = 10
|
|
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
|
|
66
80
|
end
|
|
67
81
|
end
|
|
68
82
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# October 2015, Bryan Jen
|
|
4
4
|
#
|
|
5
|
-
# Copyright (c) 2014-
|
|
5
|
+
# Copyright (c) 2014-2016 Cisco and/or its affiliates.
|
|
6
6
|
#
|
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
8
|
# you may not use this file except in compliance with the License.
|
|
@@ -32,15 +32,11 @@ module Cisco
|
|
|
32
32
|
def self.domainnames(vrf=nil)
|
|
33
33
|
hash = {}
|
|
34
34
|
if vrf.nil?
|
|
35
|
-
|
|
35
|
+
domain = config_get('dnsclient', 'domain_name')
|
|
36
36
|
else
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
return hash if domains.nil?
|
|
40
|
-
|
|
41
|
-
domains.each do |name|
|
|
42
|
-
hash[name] = DomainName.new(name, vrf, false)
|
|
37
|
+
domain = config_get('dnsclient', 'domain_name_vrf', vrf: vrf)
|
|
43
38
|
end
|
|
39
|
+
hash[domain] = DomainName.new(domain, vrf, false) unless domain.empty?
|
|
44
40
|
hash
|
|
45
41
|
end
|
|
46
42
|
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# December 2015, Andi Shen
|
|
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 'cisco_cmn_utils'
|
|
18
|
+
require_relative 'node_util'
|
|
19
|
+
require_relative 'feature'
|
|
20
|
+
|
|
21
|
+
module Cisco
|
|
22
|
+
# node_utils class for evpn_vni
|
|
23
|
+
class EvpnVni < NodeUtil
|
|
24
|
+
attr_reader :vni
|
|
25
|
+
|
|
26
|
+
def initialize(vni, instantiate=true)
|
|
27
|
+
err_msg = "vni must be either a 'String' or an" \
|
|
28
|
+
" 'Integer' object"
|
|
29
|
+
fail ArgumentError, err_msg unless vni.is_a?(Integer) ||
|
|
30
|
+
vni.is_a?(String)
|
|
31
|
+
@vni = vni.to_i
|
|
32
|
+
@get_args = @set_args = { vni: @vni }
|
|
33
|
+
create if instantiate
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Creat a hash of all vni instance
|
|
37
|
+
def self.vnis
|
|
38
|
+
hash = {}
|
|
39
|
+
return hash unless Feature.bgp_enabled?
|
|
40
|
+
vni_list = config_get('evpn_vni', 'vni')
|
|
41
|
+
return hash if vni_list.nil?
|
|
42
|
+
|
|
43
|
+
vni_list.each do |vni_id|
|
|
44
|
+
hash[vni_id] = EvpnVni.new(vni_id, false)
|
|
45
|
+
end
|
|
46
|
+
hash
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def create
|
|
50
|
+
EvpnVni.enable unless EvpnVni.enabled
|
|
51
|
+
@set_args[:state] = ''
|
|
52
|
+
config_set('evpn_vni', 'vni', @set_args)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def destroy
|
|
56
|
+
@set_args[:state] = 'no'
|
|
57
|
+
config_set('evpn_vni', 'vni', @set_args)
|
|
58
|
+
|
|
59
|
+
# no evpn if no vni left
|
|
60
|
+
vni_list = config_get('evpn_vni', 'vni')
|
|
61
|
+
config_set('evpn_vni', 'evpn', @set_args) if vni_list.nil?
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# enable feature bgp and nv overlay evpn
|
|
65
|
+
def self.enable
|
|
66
|
+
Feature.bgp_enable
|
|
67
|
+
Feature.nv_overlay_evpn_enable
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.enabled
|
|
71
|
+
Feature.bgp_enabled? && Feature.nv_overlay_evpn_enabled?
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def set_args_keys_default
|
|
75
|
+
@set_args = { vni: @vni }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Attributes:
|
|
79
|
+
# Route Distinguisher (Getter/Setter/Default)
|
|
80
|
+
def route_distinguisher
|
|
81
|
+
config_get('evpn_vni', 'route_distinguisher', @get_args)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def route_distinguisher=(rd)
|
|
85
|
+
if rd == default_route_distinguisher
|
|
86
|
+
@set_args[:state] = 'no'
|
|
87
|
+
@set_args[:rd] = ''
|
|
88
|
+
else
|
|
89
|
+
@set_args[:state] = ''
|
|
90
|
+
@set_args[:rd] = rd
|
|
91
|
+
end
|
|
92
|
+
config_set('evpn_vni', 'route_distinguisher', @set_args)
|
|
93
|
+
set_args_keys_default
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def default_route_distinguisher
|
|
97
|
+
config_get_default('evpn_vni', 'route_distinguisher')
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# route target both
|
|
101
|
+
def route_target_both
|
|
102
|
+
cmds = config_get('evpn_vni', 'route_target_both', @get_args)
|
|
103
|
+
cmds.sort
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def route_target_both=(should)
|
|
107
|
+
route_target_delta(should, route_target_both, 'route_target_both')
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def default_route_target_both
|
|
111
|
+
config_get_default('evpn_vni', 'route_target_both')
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# route target export
|
|
115
|
+
def route_target_export
|
|
116
|
+
cmds = config_get('evpn_vni', 'route_target_export', @get_args)
|
|
117
|
+
cmds.sort
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def route_target_export=(should)
|
|
121
|
+
route_target_delta(should, route_target_export, 'route_target_export')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def default_route_target_export
|
|
125
|
+
config_get_default('evpn_vni', 'route_target_export')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# route target import
|
|
129
|
+
def route_target_import
|
|
130
|
+
cmds = config_get('evpn_vni', 'route_target_import', @get_args)
|
|
131
|
+
cmds.sort
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def route_target_import=(should)
|
|
135
|
+
route_target_delta(should, route_target_import, 'route_target_import')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def default_route_target_import
|
|
139
|
+
config_get_default('evpn_vni', 'route_target_import')
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def route_target_delta(should, is, prop)
|
|
143
|
+
delta_hash = Utils.delta_add_remove(should, is)
|
|
144
|
+
return if delta_hash.values.flatten.empty?
|
|
145
|
+
[:add, :remove].each do |action|
|
|
146
|
+
CiscoLogger.debug("#{prop}" \
|
|
147
|
+
"#{@get_args}\n #{action}: #{delta_hash[action]}")
|
|
148
|
+
delta_hash[action].each do |community|
|
|
149
|
+
state = (action == :add) ? '' : 'no'
|
|
150
|
+
@set_args[:state] = state
|
|
151
|
+
@set_args[:community] = community
|
|
152
|
+
config_set('evpn_vni', prop, @set_args)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NXAPI implementation of Fabricpath Global class
|
|
3
|
+
#
|
|
4
|
+
# November 2015, Deepak Cherian
|
|
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
|
+
require_relative 'node_util'
|
|
21
|
+
|
|
22
|
+
module Cisco
|
|
23
|
+
# node_utils class for fabricpath_global
|
|
24
|
+
class FabricpathGlobal < NodeUtil
|
|
25
|
+
attr_reader :name
|
|
26
|
+
|
|
27
|
+
def initialize(name, instantiate=true)
|
|
28
|
+
fail ArgumentError unless name.to_s == 'default'
|
|
29
|
+
@name = name.downcase
|
|
30
|
+
|
|
31
|
+
create if instantiate
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.globals
|
|
35
|
+
hash = {}
|
|
36
|
+
is_fabricpath_feature = config_get('fabricpath', 'feature')
|
|
37
|
+
return hash if (:enabled != is_fabricpath_feature.to_sym)
|
|
38
|
+
hash['default'] = FabricpathGlobal.new('default', false)
|
|
39
|
+
hash
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.fabricpath_feature
|
|
43
|
+
fabricpath = config_get('fabricpath', 'feature')
|
|
44
|
+
fail 'fabricpath_feature not found' if fabricpath.nil?
|
|
45
|
+
return :disabled if fabricpath.nil?
|
|
46
|
+
fabricpath.to_sym
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.fabricpath_feature_set(fabricpath_set)
|
|
50
|
+
curr = FabricpathGlobal.fabricpath_feature
|
|
51
|
+
return if curr == fabricpath_set
|
|
52
|
+
|
|
53
|
+
case fabricpath_set
|
|
54
|
+
when :enabled
|
|
55
|
+
config_set('fabricpath', 'feature_install',
|
|
56
|
+
state: '') if curr == :uninstalled
|
|
57
|
+
config_set('fabricpath', 'feature', state: '')
|
|
58
|
+
when :disabled
|
|
59
|
+
config_set('fabricpath', 'feature', state: 'no') if curr == :enabled
|
|
60
|
+
return
|
|
61
|
+
when :installed
|
|
62
|
+
config_set('fabricpath', 'feature_install',
|
|
63
|
+
state: '') if curr == :uninstalled
|
|
64
|
+
when :uninstalled
|
|
65
|
+
config_set('fabricpath', 'feature', state: 'no') if curr == :enabled
|
|
66
|
+
config_set('fabricpath', 'feature_install', state: 'no')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def create
|
|
71
|
+
FabricpathGlobal.fabricpath_feature_set(:enabled) unless
|
|
72
|
+
:enabled == FabricpathGlobal.fabricpath_feature
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def destroy
|
|
76
|
+
@name = nil
|
|
77
|
+
FabricpathGlobal.fabricpath_feature_set(:disabled)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def my_munge(property, set_val)
|
|
81
|
+
val = config_get_default('fabricpath', property)
|
|
82
|
+
case property
|
|
83
|
+
when /loadbalance_algorithm/
|
|
84
|
+
if (val == 'source-destination') &&
|
|
85
|
+
(set_val == 'symmetric' || set_val == 'xor')
|
|
86
|
+
val
|
|
87
|
+
else
|
|
88
|
+
set_val
|
|
89
|
+
end
|
|
90
|
+
when /loadbalance_.*_rotate/
|
|
91
|
+
if val == false || set_val == ''
|
|
92
|
+
''
|
|
93
|
+
else
|
|
94
|
+
"rotate-amount 0x#{set_val.to_s(16)}"
|
|
95
|
+
end
|
|
96
|
+
else
|
|
97
|
+
set_val
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
########################################################
|
|
102
|
+
# PROPERTIES #
|
|
103
|
+
########################################################
|
|
104
|
+
|
|
105
|
+
def aggregate_multicast_routes
|
|
106
|
+
config_get('fabricpath', 'aggregate_multicast_routes')
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def aggregate_multicast_routes=(val)
|
|
110
|
+
state = val ? '' : 'no'
|
|
111
|
+
config_set('fabricpath', 'aggregate_multicast_routes', state: state)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def default_aggregate_multicast_routes
|
|
115
|
+
config_get_default('fabricpath', 'aggregate_multicast_routes')
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def allocate_delay
|
|
119
|
+
config_get('fabricpath', 'allocate_delay')
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def allocate_delay=(val)
|
|
123
|
+
state = val ? '' : 'no'
|
|
124
|
+
delay = val ? val : ''
|
|
125
|
+
config_set('fabricpath', 'allocate_delay', state: state, delay: delay)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def default_allocate_delay
|
|
129
|
+
config_get_default('fabricpath', 'allocate_delay')
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def auto_switch_id
|
|
133
|
+
config_get('fabricpath', 'auto_switch_id')
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def graceful_merge
|
|
137
|
+
graceful_merge_conf = config_get('fabricpath', 'graceful_merge')
|
|
138
|
+
# opposite meaning with the cli
|
|
139
|
+
return :enable if graceful_merge_conf.nil?
|
|
140
|
+
graceful_merge_conf ? :disable : :enable
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def graceful_merge=(val)
|
|
144
|
+
state = val == :enable ? 'no' : ''
|
|
145
|
+
config_set('fabricpath', 'graceful_merge', state: state)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def default_graceful_merge
|
|
149
|
+
graceful_merge = config_get_default('fabricpath', 'graceful_merge')
|
|
150
|
+
graceful_merge.to_sym
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
def linkup_delay
|
|
154
|
+
config_get('fabricpath', 'linkup_delay')
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def linkup_delay=(val)
|
|
158
|
+
state = val ? '' : 'no'
|
|
159
|
+
delay = val ? val : ''
|
|
160
|
+
config_set('fabricpath', 'linkup_delay', state: state, delay: delay)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def default_linkup_delay
|
|
164
|
+
config_get_default('fabricpath', 'linkup_delay')
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def linkup_delay_always
|
|
168
|
+
config_get('fabricpath', 'linkup_delay_always')
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def linkup_delay_always=(val)
|
|
172
|
+
if val == '' || val == true
|
|
173
|
+
state = ''
|
|
174
|
+
else
|
|
175
|
+
state = 'no'
|
|
176
|
+
end
|
|
177
|
+
config_set('fabricpath', 'linkup_delay_always', state: state)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def default_linkup_delay_always
|
|
181
|
+
config_get_default('fabricpath', 'linkup_delay_always')
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def linkup_delay_enable
|
|
185
|
+
delay = config_get('fabricpath', 'linkup_delay_enable')
|
|
186
|
+
return false if delay.nil?
|
|
187
|
+
delay
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def linkup_delay_enable=(val)
|
|
191
|
+
if val == '' || val == true
|
|
192
|
+
state = ''
|
|
193
|
+
else
|
|
194
|
+
state = 'no'
|
|
195
|
+
end
|
|
196
|
+
config_set('fabricpath', 'linkup_delay_enable', state: state)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def default_linkup_delay_enable
|
|
200
|
+
config_get_default('fabricpath', 'linkup_delay_enable')
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def loadbalance_algorithm
|
|
204
|
+
algo = config_get('fabricpath', 'loadbalance_algorithm')
|
|
205
|
+
algo.downcase
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def loadbalance_algorithm=(val)
|
|
209
|
+
val = my_munge('loadbalance_algorithm', val)
|
|
210
|
+
state = val ? '' : 'no'
|
|
211
|
+
algo = val ? val : ''
|
|
212
|
+
config_set('fabricpath', 'loadbalance_algorithm', state: state,
|
|
213
|
+
algo: algo)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def default_loadbalance_algorithm
|
|
217
|
+
config_get_default('fabricpath', 'loadbalance_algorithm')
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def loadbalance_multicast_rotate
|
|
221
|
+
config_get('fabricpath', 'loadbalance_multicast_rotate')
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def loadbalance_multicast_has_vlan
|
|
225
|
+
val = config_get('fabricpath', 'loadbalance_multicast_has_vlan')
|
|
226
|
+
val.nil? ? false : val
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
def loadbalance_multicast=(rotate, has_vlan)
|
|
230
|
+
if rotate == '' && (has_vlan == '' || has_vlan == false)
|
|
231
|
+
config_set('fabricpath', 'loadbalance_multicast_reset')
|
|
232
|
+
else
|
|
233
|
+
rotate = my_munge('loadbalance_multicast_rotate', rotate)
|
|
234
|
+
has_vlan = (has_vlan == true) ? 'include-vlan' : ''
|
|
235
|
+
config_set('fabricpath', 'loadbalance_multicast_set',
|
|
236
|
+
rotate_amt: rotate, inc_vlan: has_vlan)
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def default_loadbalance_multicast_rotate
|
|
241
|
+
config_get_default('fabricpath', 'loadbalance_multicast_rotate')
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def default_loadbalance_multicast_has_vlan
|
|
245
|
+
config_get_default('fabricpath', 'loadbalance_multicast_has_vlan')
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def loadbalance_unicast_layer
|
|
249
|
+
unicast = config_get('fabricpath', 'loadbalance_unicast_layer')
|
|
250
|
+
return default_loadbalance_unicast_layer if unicast.nil?
|
|
251
|
+
case unicast
|
|
252
|
+
when /L4/
|
|
253
|
+
'layer4'
|
|
254
|
+
when /L3/
|
|
255
|
+
'layer3'
|
|
256
|
+
when /Mixed/
|
|
257
|
+
'mixed'
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
def loadbalance_unicast_rotate
|
|
262
|
+
config_get('fabricpath', 'loadbalance_unicast_rotate')
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def loadbalance_unicast_has_vlan
|
|
266
|
+
val = config_get('fabricpath', 'loadbalance_unicast_has_vlan')
|
|
267
|
+
val.nil? ? false : val
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def split_loadbalance_unicast_layer=(val)
|
|
271
|
+
state = val ? '' : 'no'
|
|
272
|
+
pref = val ? val : ''
|
|
273
|
+
config_set('fabricpath', 'loadbalance_unicast_layer', state: state,
|
|
274
|
+
pref: pref)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
def split_loadbalance_unicast_has_vlan=(val)
|
|
278
|
+
if val == '' || val == false
|
|
279
|
+
state = 'no'
|
|
280
|
+
else
|
|
281
|
+
state = ''
|
|
282
|
+
end
|
|
283
|
+
config_set('fabricpath', 'loadbalance_unicast_has_vlan', state: state)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def loadbalance_unicast=(layer, rotate, has_vlan)
|
|
287
|
+
support = config_get('fabricpath', 'loadbalance_unicast_support')
|
|
288
|
+
if support == 'combined'
|
|
289
|
+
if layer == '' && rotate == '' && (has_vlan == '' || has_vlan == false)
|
|
290
|
+
config_set('fabricpath', 'loadbalance_unicast_reset')
|
|
291
|
+
else
|
|
292
|
+
rotate = my_munge('loadbalance_unicast_rotate', rotate)
|
|
293
|
+
has_vlan = (has_vlan == true) ? 'include-vlan' : ''
|
|
294
|
+
config_set('fabricpath', 'loadbalance_unicast_set',
|
|
295
|
+
pref: layer, rotate_amt: rotate, inc_vlan: has_vlan)
|
|
296
|
+
end
|
|
297
|
+
else
|
|
298
|
+
self.split_loadbalance_unicast_layer = layer
|
|
299
|
+
self.split_loadbalance_unicast_has_vlan = has_vlan
|
|
300
|
+
end
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
def default_loadbalance_unicast_layer
|
|
304
|
+
config_get_default('fabricpath', 'loadbalance_unicast_layer')
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
def default_loadbalance_unicast_rotate
|
|
308
|
+
config_get_default('fabricpath', 'loadbalance_unicast_rotate')
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
def default_loadbalance_unicast_has_vlan
|
|
312
|
+
config_get_default('fabricpath', 'loadbalance_unicast_has_vlan')
|
|
313
|
+
end
|
|
314
|
+
|
|
315
|
+
def mode
|
|
316
|
+
config_get('fabricpath', 'mode')
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def mode=(val)
|
|
320
|
+
if val == '' || val == 'normal'
|
|
321
|
+
state = 'no'
|
|
322
|
+
else
|
|
323
|
+
state = ''
|
|
324
|
+
vdc = config_get('limit_resource', 'vdc')
|
|
325
|
+
# for vdc unsupported platforms, this will be nil
|
|
326
|
+
config_set('limit_resource', 'fabricpath_transit', vdc) unless vdc.nil?
|
|
327
|
+
end
|
|
328
|
+
config_set('fabricpath', 'mode', state: state)
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
def default_mode
|
|
332
|
+
config_get_default('fabricpath', 'mode')
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
def switch_id
|
|
336
|
+
switch_id_conf = config_get('fabricpath', 'switch_id')
|
|
337
|
+
return auto_switch_id if switch_id_conf.nil?
|
|
338
|
+
switch_id_conf
|
|
339
|
+
end
|
|
340
|
+
|
|
341
|
+
def switch_id=(val)
|
|
342
|
+
# There is no no-form for this command
|
|
343
|
+
config_set('fabricpath', 'switch_id', swid: val.to_s)
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
def transition_delay
|
|
347
|
+
config_get('fabricpath', 'transition_delay')
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def transition_delay=(val)
|
|
351
|
+
state = val ? '' : 'no'
|
|
352
|
+
delay = val ? val : ''
|
|
353
|
+
config_set('fabricpath', 'transition_delay', state: state, delay: delay)
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def default_transition_delay
|
|
357
|
+
config_get_default('fabricpath', 'transition_delay')
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
def ttl_multicast
|
|
361
|
+
config_get('fabricpath', 'ttl_multicast')
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
def ttl_multicast=(val)
|
|
365
|
+
state = val ? '' : 'no'
|
|
366
|
+
ttl = val ? val : ''
|
|
367
|
+
config_set('fabricpath', 'ttl_multicast', state: state, ttl: ttl)
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
def default_ttl_multicast
|
|
371
|
+
config_get_default('fabricpath', 'ttl_multicast')
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
def ttl_unicast
|
|
375
|
+
config_get('fabricpath', 'ttl_unicast')
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
def ttl_unicast=(val)
|
|
379
|
+
state = val ? '' : 'no'
|
|
380
|
+
ttl = val ? val : ''
|
|
381
|
+
config_set('fabricpath', 'ttl_unicast', state: state, ttl: ttl)
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
def default_ttl_unicast
|
|
385
|
+
config_get_default('fabricpath', 'ttl_unicast')
|
|
386
|
+
end
|
|
387
|
+
end # class
|
|
388
|
+
end # module
|