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
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# VRF_AF provider class
|
|
2
|
+
#
|
|
3
|
+
# January 2016, Chris Van Heuveln
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2015-2016 Cisco and/or its affiliates.
|
|
6
|
+
#
|
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
# you may not use this file except in compliance with the License.
|
|
9
|
+
# You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
# See the License for the specific language governing permissions and
|
|
17
|
+
# limitations under the License.
|
|
18
|
+
|
|
19
|
+
require_relative 'cisco_cmn_utils'
|
|
20
|
+
require_relative 'node_util'
|
|
21
|
+
require_relative 'feature'
|
|
22
|
+
|
|
23
|
+
module Cisco
|
|
24
|
+
# VrfAF - node utility class for VRF Address-Family configuration
|
|
25
|
+
class VrfAF < NodeUtil
|
|
26
|
+
attr_reader :name
|
|
27
|
+
|
|
28
|
+
def initialize(vrf, af, instantiate=true)
|
|
29
|
+
validate_args(vrf, af)
|
|
30
|
+
create if instantiate
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.afs
|
|
34
|
+
hash = {}
|
|
35
|
+
vrfs = config_get('vrf', 'all_vrfs')
|
|
36
|
+
vrfs.each do |vrf|
|
|
37
|
+
hash[vrf] = {}
|
|
38
|
+
afs = config_get('vrf', 'all_vrf_afs', vrf: vrf)
|
|
39
|
+
|
|
40
|
+
next if afs.nil?
|
|
41
|
+
afs.each do |af|
|
|
42
|
+
hash[vrf][af] = VrfAF.new(vrf, af, false)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
hash
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def create
|
|
49
|
+
config_set('vrf', 'address_family', set_args_keys(state: ''))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def destroy
|
|
53
|
+
config_set('vrf', 'address_family', set_args_keys(state: 'no'))
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def validate_args(vrf, af)
|
|
57
|
+
fail ArgumentError unless vrf.is_a?(String) && (vrf.length > 0)
|
|
58
|
+
fail ArgumentError, "'af' must be an array specifying afi and safi" unless
|
|
59
|
+
af.is_a?(Array) || af.length == 2
|
|
60
|
+
@vrf = vrf.downcase
|
|
61
|
+
@afi, @safi = af
|
|
62
|
+
set_args_keys_default
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def set_args_keys_default
|
|
66
|
+
keys = { afi: @afi, safi: @safi }
|
|
67
|
+
keys[:vrf] = @vrf unless @vrf == 'default'
|
|
68
|
+
@get_args = @set_args = keys
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def set_args_keys(hash={}) # rubocop:disable Style/AccessorMethodName
|
|
72
|
+
set_args_keys_default
|
|
73
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def route_target_feature_enable
|
|
77
|
+
Feature.bgp_enable
|
|
78
|
+
Feature.nv_overlay_enable
|
|
79
|
+
Feature.nv_overlay_evpn_enable
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
########################################################
|
|
83
|
+
# PROPERTIES #
|
|
84
|
+
########################################################
|
|
85
|
+
|
|
86
|
+
def route_target_both_auto
|
|
87
|
+
config_get('vrf', 'route_target_both_auto', @get_args)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def route_target_both_auto=(state)
|
|
91
|
+
route_target_feature_enable
|
|
92
|
+
set_args_keys(state: (state ? '' : 'no'))
|
|
93
|
+
config_set('vrf', 'route_target_both_auto', @set_args)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def default_route_target_both_auto
|
|
97
|
+
config_get_default('vrf', 'route_target_both_auto')
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# --------------------------
|
|
101
|
+
def route_target_both_auto_evpn
|
|
102
|
+
config_get('vrf', 'route_target_both_auto_evpn', @get_args)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def route_target_both_auto_evpn=(state)
|
|
106
|
+
route_target_feature_enable
|
|
107
|
+
set_args_keys(state: (state ? '' : 'no'))
|
|
108
|
+
config_set('vrf', 'route_target_both_auto_evpn', @set_args)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def default_route_target_both_auto_evpn
|
|
112
|
+
config_get_default('vrf', 'route_target_both_auto_evpn')
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# --------------------------
|
|
116
|
+
def route_target_export
|
|
117
|
+
cmds = config_get('vrf', 'route_target_export', @get_args)
|
|
118
|
+
cmds.sort
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def route_target_export=(should)
|
|
122
|
+
route_target_delta(should, route_target_export, 'route_target_export')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def default_route_target_export
|
|
126
|
+
config_get_default('vrf', 'route_target_export')
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# --------------------------
|
|
130
|
+
def route_target_export_evpn
|
|
131
|
+
cmds = config_get('vrf', 'route_target_export_evpn', @get_args)
|
|
132
|
+
cmds.sort
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def route_target_export_evpn=(should)
|
|
136
|
+
route_target_delta(should, route_target_export_evpn,
|
|
137
|
+
'route_target_export_evpn')
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def default_route_target_export_evpn
|
|
141
|
+
config_get_default('vrf', 'route_target_export_evpn')
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# --------------------------
|
|
145
|
+
def route_target_import
|
|
146
|
+
cmds = config_get('vrf', 'route_target_import', @get_args)
|
|
147
|
+
cmds.sort
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def route_target_import=(should)
|
|
151
|
+
route_target_delta(should, route_target_import, 'route_target_import')
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def default_route_target_import
|
|
155
|
+
config_get_default('vrf', 'route_target_import')
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# --------------------------
|
|
159
|
+
def route_target_import_evpn
|
|
160
|
+
cmds = config_get('vrf', 'route_target_import_evpn', @get_args)
|
|
161
|
+
cmds.sort
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def route_target_import_evpn=(should)
|
|
165
|
+
route_target_delta(should, route_target_import_evpn,
|
|
166
|
+
'route_target_import_evpn')
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def default_route_target_import_evpn
|
|
170
|
+
config_get_default('vrf', 'route_target_import_evpn')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# --------------------------
|
|
174
|
+
# route_target_delta is a common helper function for the route_target
|
|
175
|
+
# properties. It walks the delta hash and adds/removes each target cli.
|
|
176
|
+
def route_target_delta(should, is, prop)
|
|
177
|
+
route_target_feature_enable
|
|
178
|
+
delta_hash = Utils.delta_add_remove(should, is)
|
|
179
|
+
return if delta_hash.values.flatten.empty?
|
|
180
|
+
[:add, :remove].each do |action|
|
|
181
|
+
CiscoLogger.debug("#{prop}" \
|
|
182
|
+
"#{@get_args}\n #{action}: #{delta_hash[action]}")
|
|
183
|
+
delta_hash[action].each do |community|
|
|
184
|
+
state = (action == :add) ? '' : 'no'
|
|
185
|
+
set_args_keys(state: state, community: community)
|
|
186
|
+
config_set('vrf', prop, @set_args)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end # class
|
|
191
|
+
end # module
|
data/lib/cisco_node_utils/vtp.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Mike Wiebe, November 2014
|
|
2
2
|
#
|
|
3
|
-
# Copyright (c) 2014-
|
|
3
|
+
# Copyright (c) 2014-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.
|
|
@@ -30,7 +30,11 @@ module Cisco
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def self.enabled
|
|
33
|
-
|
|
33
|
+
config_get('vtp', 'feature')
|
|
34
|
+
rescue Cisco::CliError => e
|
|
35
|
+
# cmd will syntax reject when feature is not enabled
|
|
36
|
+
raise unless e.clierror =~ /Syntax error/
|
|
37
|
+
return false
|
|
34
38
|
end
|
|
35
39
|
|
|
36
40
|
def enable
|
|
@@ -99,8 +103,7 @@ module Cisco
|
|
|
99
103
|
|
|
100
104
|
# Get vtp filename
|
|
101
105
|
def filename
|
|
102
|
-
|
|
103
|
-
match.nil? ? default_filename : match.first
|
|
106
|
+
config_get('vtp', 'filename')
|
|
104
107
|
end
|
|
105
108
|
|
|
106
109
|
# Set vtp filename
|
|
@@ -121,8 +124,7 @@ module Cisco
|
|
|
121
124
|
|
|
122
125
|
# Get vtp version
|
|
123
126
|
def version
|
|
124
|
-
|
|
125
|
-
match.nil? ? default_version : match.first.to_i
|
|
127
|
+
Vtp.enabled ? config_get('vtp', 'version') : default_version
|
|
126
128
|
end
|
|
127
129
|
|
|
128
130
|
# Set vtp version
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NXAPI implementation of VXLAN_VTEP 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
|
+
require_relative 'vrf'
|
|
22
|
+
|
|
23
|
+
module Cisco
|
|
24
|
+
# node_utils class for vxlan_vtep
|
|
25
|
+
class VxlanVtep < NodeUtil
|
|
26
|
+
attr_reader :name
|
|
27
|
+
|
|
28
|
+
def initialize(name, instantiate=true)
|
|
29
|
+
fail TypeError unless name.is_a?(String)
|
|
30
|
+
fail ArgumentError unless name.length > 0
|
|
31
|
+
@name = name.downcase
|
|
32
|
+
|
|
33
|
+
create if instantiate
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.vteps
|
|
37
|
+
hash = {}
|
|
38
|
+
return hash unless Feature.nv_overlay_enabled?
|
|
39
|
+
vtep_list = config_get('vxlan_vtep', 'all_interfaces')
|
|
40
|
+
return hash if vtep_list.nil?
|
|
41
|
+
|
|
42
|
+
vtep_list.each do |id|
|
|
43
|
+
id = id.downcase
|
|
44
|
+
hash[id] = VxlanVtep.new(id, false)
|
|
45
|
+
end
|
|
46
|
+
hash
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.mt_full_support
|
|
50
|
+
config_get('vxlan_vtep', 'mt_full_support')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.mt_lite_support
|
|
54
|
+
config_get('vxlan_vtep', 'mt_lite_support')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def create
|
|
58
|
+
Feature.nv_overlay_enable
|
|
59
|
+
Feature.vn_segment_vlan_based_enable if VxlanVtep.mt_lite_support
|
|
60
|
+
# re-use the "interface command ref hooks"
|
|
61
|
+
config_set('interface', 'create', @name)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def destroy
|
|
65
|
+
# re-use the "interface command ref hooks"
|
|
66
|
+
config_set('interface', 'destroy', @name)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def ==(other)
|
|
70
|
+
name == other.name
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
########################################################
|
|
74
|
+
# PROPERTIES #
|
|
75
|
+
########################################################
|
|
76
|
+
|
|
77
|
+
def description
|
|
78
|
+
config_get('interface', 'description', @name)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def description=(desc)
|
|
82
|
+
fail TypeError unless desc.is_a?(String)
|
|
83
|
+
if desc.empty?
|
|
84
|
+
config_set('interface', 'description', @name, 'no', '')
|
|
85
|
+
else
|
|
86
|
+
config_set('interface', 'description', @name, '', desc)
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def default_description
|
|
91
|
+
config_get_default('interface', 'description')
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def host_reachability
|
|
95
|
+
hr = config_get('vxlan_vtep', 'host_reachability', name: @name)
|
|
96
|
+
hr == 'bgp' ? 'evpn' : hr
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def host_reachability=(val)
|
|
100
|
+
set_args = { name: @name, proto: 'bgp' }
|
|
101
|
+
if val.to_s == 'flood' && host_reachability == 'evpn'
|
|
102
|
+
set_args[:state] = 'no'
|
|
103
|
+
elsif val.to_s == 'evpn'
|
|
104
|
+
set_args[:state] = ''
|
|
105
|
+
else
|
|
106
|
+
return
|
|
107
|
+
end
|
|
108
|
+
config_set('vxlan_vtep', 'host_reachability', set_args)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def default_host_reachability
|
|
112
|
+
config_get_default('vxlan_vtep', 'host_reachability')
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def source_interface
|
|
116
|
+
config_get('vxlan_vtep', 'source_intf', name: @name)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def source_interface_set(val)
|
|
120
|
+
set_args = { name: @name, lpbk_intf: val }
|
|
121
|
+
set_args[:state] = val.empty? ? 'no' : ''
|
|
122
|
+
config_set('vxlan_vtep', 'source_intf', set_args)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def source_interface=(val)
|
|
126
|
+
# The source interface can only be changed if the nve
|
|
127
|
+
# interface is in a shutdown state.
|
|
128
|
+
current_state = shutdown
|
|
129
|
+
self.shutdown = true unless shutdown
|
|
130
|
+
source_interface_set(val)
|
|
131
|
+
self.shutdown = current_state
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def default_source_interface
|
|
135
|
+
config_get_default('vxlan_vtep', 'source_intf')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def shutdown
|
|
139
|
+
config_get('vxlan_vtep', 'shutdown', name: @name)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def shutdown=(bool)
|
|
143
|
+
state = (bool ? '' : 'no')
|
|
144
|
+
config_set('vxlan_vtep', 'shutdown', name: @name, state: state)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def default_shutdown
|
|
148
|
+
config_get_default('vxlan_vtep', 'shutdown')
|
|
149
|
+
end
|
|
150
|
+
end # Class
|
|
151
|
+
end # Module
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NXAPI implementation of VxlanVtepVni class
|
|
3
|
+
#
|
|
4
|
+
# November 2015 Michael G Wiebe
|
|
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 'cisco_cmn_utils'
|
|
21
|
+
require_relative 'node_util'
|
|
22
|
+
require_relative 'vxlan_vtep'
|
|
23
|
+
|
|
24
|
+
module Cisco
|
|
25
|
+
# VxlanVtepVni - node utility for vxlan vtep vni members.
|
|
26
|
+
class VxlanVtepVni < NodeUtil
|
|
27
|
+
attr_reader :name, :vni, :assoc_vrf
|
|
28
|
+
|
|
29
|
+
def initialize(name, vni, assoc_vrf=false, instantiate=true)
|
|
30
|
+
@name = name
|
|
31
|
+
@vni = vni
|
|
32
|
+
@assoc_vrf = assoc_vrf
|
|
33
|
+
|
|
34
|
+
set_args_keys_default
|
|
35
|
+
create if instantiate
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.vnis
|
|
39
|
+
hash = {}
|
|
40
|
+
VxlanVtep.vteps.each do |name, _obj|
|
|
41
|
+
hash[name] = {}
|
|
42
|
+
get_args = { name: name }
|
|
43
|
+
vni_list = config_get('vxlan_vtep_vni', 'all_vnis', get_args)
|
|
44
|
+
next if vni_list.nil?
|
|
45
|
+
vni_list.each do |vni, assoc_vrf|
|
|
46
|
+
assoc_vrf = assoc_vrf.nil? ? false : true
|
|
47
|
+
hash[name][vni] = VxlanVtepVni.new(name, vni, assoc_vrf, false)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
hash
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def ==(other)
|
|
54
|
+
(name == other.name) && (vni == other.vni) &&
|
|
55
|
+
(assoc_vrf == other.assoc_vrf)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def set_args_keys_default
|
|
59
|
+
keys = { name: @name, vni: @vni }
|
|
60
|
+
keys[:assoc_vrf] = @assoc_vrf ? 'associate-vrf' : ''
|
|
61
|
+
@get_args = @set_args = keys
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# rubocop:disable Style/AccessorMethodName
|
|
65
|
+
def set_args_keys(hash={})
|
|
66
|
+
set_args_keys_default
|
|
67
|
+
@set_args = @get_args.merge!(hash) unless hash.empty?
|
|
68
|
+
end
|
|
69
|
+
# rubocop:enable Style/AccessorMethodNamefor
|
|
70
|
+
|
|
71
|
+
def create_with_associate_vrf?
|
|
72
|
+
!@set_args[:assoc_vrf].eql?('')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def destroy_existing(key)
|
|
76
|
+
getargs = { name: @name, vni: @vni, state: '' }
|
|
77
|
+
return unless config_get('vxlan_vtep', key, getargs)
|
|
78
|
+
getargs[:assoc_vrf] = key.eql?('vni_with_vrf') ? 'associate-vrf' : ''
|
|
79
|
+
getargs[:state] = 'no'
|
|
80
|
+
config_set('vxlan_vtep', 'vni', getargs)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def create
|
|
84
|
+
# The configuration for this resource can be either of the following:
|
|
85
|
+
# - member nve 5000
|
|
86
|
+
# - member nve 5000 associate-vrf
|
|
87
|
+
# They are mutually exclusive and one must be removed before the other
|
|
88
|
+
# can be configured.
|
|
89
|
+
set_args_keys(state: '')
|
|
90
|
+
if create_with_associate_vrf?
|
|
91
|
+
destroy_existing('vni_without_vrf')
|
|
92
|
+
else
|
|
93
|
+
destroy_existing('vni_with_vrf')
|
|
94
|
+
end
|
|
95
|
+
config_set('vxlan_vtep', 'vni', @set_args)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def destroy
|
|
99
|
+
set_args_keys(state: 'no')
|
|
100
|
+
config_set('vxlan_vtep', 'vni', @set_args)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
########################################################
|
|
104
|
+
# PROPERTIES #
|
|
105
|
+
########################################################
|
|
106
|
+
|
|
107
|
+
def ingress_replication
|
|
108
|
+
config_get('vxlan_vtep_vni', 'ingress_replication', @get_args)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def remove_add_ingress_replication(protocol)
|
|
112
|
+
if ingress_replication.empty?
|
|
113
|
+
set_args_keys(state: '', protocol: protocol)
|
|
114
|
+
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
|
|
115
|
+
else
|
|
116
|
+
# Sadly, the only way to change between protocols is to
|
|
117
|
+
# first remove the existing protocol.
|
|
118
|
+
set_args_keys(state: 'no', protocol: ingress_replication)
|
|
119
|
+
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
|
|
120
|
+
set_args_keys(state: '', protocol: protocol)
|
|
121
|
+
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def ingress_replication=(protocol)
|
|
126
|
+
return if protocol.to_s == ingress_replication
|
|
127
|
+
# Only set ingress_replicatin to the default value if it's not already.
|
|
128
|
+
if protocol.to_s == default_ingress_replication &&
|
|
129
|
+
(ingress_replication != default_ingress_replication)
|
|
130
|
+
set_args_keys(state: 'no', protocol: ingress_replication)
|
|
131
|
+
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
|
|
132
|
+
else
|
|
133
|
+
# Multicast group and ingress replication are mutually exclusive
|
|
134
|
+
# properties, so remove multicast_group first
|
|
135
|
+
unless multicast_group.empty?
|
|
136
|
+
set_args_keys(state: 'no', ip_start: '', ip_end: '')
|
|
137
|
+
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
|
|
138
|
+
end
|
|
139
|
+
remove_add_ingress_replication(protocol.to_s)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def default_ingress_replication
|
|
144
|
+
config_get_default('vxlan_vtep_vni', 'ingress_replication')
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
def multicast_group
|
|
148
|
+
g1, g2 = config_get('vxlan_vtep_vni', 'multicast_group', @get_args)
|
|
149
|
+
g2.nil? ? g1 : g1 + ' ' + g2
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def remove_add_multicast_group(ip_start, ip_end)
|
|
153
|
+
set_args_keys(state: 'no', ip_start: '', ip_end: '')
|
|
154
|
+
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
|
|
155
|
+
set_args_keys(state: '', ip_start: ip_start, ip_end: ip_end)
|
|
156
|
+
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def multicast_group=(range)
|
|
160
|
+
if range == default_multicast_group
|
|
161
|
+
# Due to CSCux78514, trying to remove multicast-group in CLI
|
|
162
|
+
# when ingress replication is configured results in removing
|
|
163
|
+
# ingress replication from nvgen. So be careful and negate
|
|
164
|
+
# Multicast-group only is it is configured.
|
|
165
|
+
unless multicast_group.empty?
|
|
166
|
+
set_args_keys(state: 'no', ip_start: '', ip_end: '')
|
|
167
|
+
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
|
|
168
|
+
end
|
|
169
|
+
else
|
|
170
|
+
ip_start, ip_end = range.split(' ')
|
|
171
|
+
ip_end = '' if ip_end.nil?
|
|
172
|
+
# Since multicast group and ingress replication are exclusive
|
|
173
|
+
# properties, remove ingress replication first
|
|
174
|
+
unless ingress_replication.empty?
|
|
175
|
+
set_args_keys(state: 'no', protocol: ingress_replication)
|
|
176
|
+
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
|
|
177
|
+
end
|
|
178
|
+
remove_add_multicast_group(ip_start, ip_end)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def default_multicast_group
|
|
183
|
+
config_get_default('vxlan_vtep_vni', 'multicast_group')
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def peer_list
|
|
187
|
+
config_get('vxlan_vtep_vni', 'peer_list', @get_args)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def peer_list=(should_list)
|
|
191
|
+
delta_hash = Utils.delta_add_remove(should_list, peer_list)
|
|
192
|
+
return if delta_hash.values.flatten.empty?
|
|
193
|
+
[:add, :remove].each do |action|
|
|
194
|
+
CiscoLogger.debug('peer_list' \
|
|
195
|
+
"#{@get_args}\n #{action}: #{delta_hash[action]}")
|
|
196
|
+
delta_hash[action].each do |peer|
|
|
197
|
+
state = (action == :add) ? '' : 'no'
|
|
198
|
+
@set_args[:state] = state
|
|
199
|
+
@set_args[:peer] = peer
|
|
200
|
+
config_set('vxlan_vtep_vni', 'peer_list', @set_args)
|
|
201
|
+
end
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def default_peer_list
|
|
206
|
+
config_get_default('vxlan_vtep_vni', 'peer_list')
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def suppress_arp
|
|
210
|
+
config_get('vxlan_vtep_vni', 'suppress_arp', @get_args)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
def suppress_arp=(state)
|
|
214
|
+
if state
|
|
215
|
+
set_args_keys(state: '')
|
|
216
|
+
# Host reachability must be enabled for this property
|
|
217
|
+
VxlanVtep.new(@name).host_reachability = 'evpn'
|
|
218
|
+
config_set('vxlan_vtep_vni', 'suppress_arp', @set_args)
|
|
219
|
+
else
|
|
220
|
+
set_args_keys(state: 'no')
|
|
221
|
+
# Remove suppress-arp only if it is configured. Suppress-arp needs
|
|
222
|
+
# free TCAM region for arp-ether ACL. Customers who don't need
|
|
223
|
+
# suppress-arp, needn't see cli failures warning about TCAM regions
|
|
224
|
+
# issued due to 'no suppress-arp'. Note that for suppress-arp, default
|
|
225
|
+
# is 'false' which is no suppress-arp
|
|
226
|
+
config_set('vxlan_vtep_vni', 'suppress_arp', @set_args) if suppress_arp
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def default_suppress_arp
|
|
231
|
+
config_get_default('vxlan_vtep_vni', 'suppress_arp')
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
end
|