Class: Cisco::VxlanVtepVni
Overview
VxlanVtepVni - node utility for vxlan vtep vni members.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from NodeUtil
client, #client, config_get, #config_get, #config_get_default, config_get_default, config_set, #config_set, #get, #ios_xr?, #nexus?, #node, node, platform, #platform, supports?, #supports?
Constructor Details
#initialize(name, vni, assoc_vrf = false, instantiate = true) ⇒ VxlanVtepVni
Returns a new instance of VxlanVtepVni.
29
30
31
32
33
34
35
36
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 29
def initialize(name, vni, assoc_vrf=false, instantiate=true)
@name = name
@vni = vni
@assoc_vrf = assoc_vrf
set_args_keys_default
create if instantiate
end
|
Instance Attribute Details
#assoc_vrf ⇒ Object
Returns the value of attribute assoc_vrf.
27
28
29
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 27
def assoc_vrf
@assoc_vrf
end
|
#name ⇒ Object
Returns the value of attribute name.
27
28
29
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 27
def name
@name
end
|
#vni ⇒ Object
Returns the value of attribute vni.
27
28
29
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 27
def vni
@vni
end
|
Class Method Details
.vnis ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 38
def self.vnis
hash = {}
VxlanVtep.vteps.each do |name, _obj|
hash[name] = {}
get_args = { name: name }
vni_list = config_get('vxlan_vtep_vni', 'all_vnis', get_args)
next if vni_list.nil?
vni_list.each do |vni, assoc_vrf|
assoc_vrf = assoc_vrf.nil? ? false : true
hash[name][vni] = VxlanVtepVni.new(name, vni, assoc_vrf, false)
end
end
hash
end
|
Instance Method Details
#==(other) ⇒ Object
53
54
55
56
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 53
def ==(other)
(name == other.name) && (vni == other.vni) &&
(assoc_vrf == other.assoc_vrf)
end
|
#create ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 83
def create
set_args_keys(state: '')
if create_with_associate_vrf?
destroy_existing('vni_without_vrf')
else
destroy_existing('vni_with_vrf')
end
config_set('vxlan_vtep', 'vni', @set_args)
end
|
#create_with_associate_vrf? ⇒ Boolean
rubocop:enable Style/AccessorMethodNamefor
71
72
73
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 71
def create_with_associate_vrf?
!@set_args[:assoc_vrf].eql?('')
end
|
#default_ingress_replication ⇒ Object
162
163
164
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 162
def default_ingress_replication
config_get_default('vxlan_vtep_vni', 'ingress_replication')
end
|
#default_multicast_group ⇒ Object
201
202
203
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 201
def default_multicast_group
config_get_default('vxlan_vtep_vni', 'multicast_group')
end
|
#default_multisite_ingress_replication ⇒ Object
327
328
329
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 327
def default_multisite_ingress_replication
config_get_default('vxlan_vtep_vni', 'multisite_ingress_replication')
end
|
#default_peer_list ⇒ Object
224
225
226
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 224
def default_peer_list
config_get_default('vxlan_vtep_vni', 'peer_list')
end
|
#default_suppress_arp ⇒ Object
251
252
253
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 251
def default_suppress_arp
config_get_default('vxlan_vtep_vni', 'suppress_arp')
end
|
#default_suppress_arp_disable ⇒ Object
282
283
284
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 282
def default_suppress_arp_disable
config_get_default('vxlan_vtep_vni', 'suppress_arp_disable')
end
|
#default_suppress_uuc ⇒ Object
306
307
308
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 306
def default_suppress_uuc
config_get_default('vxlan_vtep_vni', 'suppress_uuc')
end
|
#destroy ⇒ Object
98
99
100
101
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 98
def destroy
set_args_keys(state: 'no')
config_set('vxlan_vtep', 'vni', @set_args)
end
|
#destroy_existing(key) ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 75
def destroy_existing(key)
getargs = { name: @name, vni: @vni, state: '' }
return unless config_get('vxlan_vtep', key, getargs)
getargs[:assoc_vrf] = key.eql?('vni_with_vrf') ? 'associate-vrf' : ''
getargs[:state] = 'no'
config_set('vxlan_vtep', 'vni', getargs)
end
|
#ingress_replication ⇒ Object
111
112
113
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 111
def ingress_replication
config_get('vxlan_vtep_vni', 'ingress_replication', @get_args)
end
|
#ingress_replication=(protocol) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 144
def ingress_replication=(protocol)
return if protocol.to_s == ingress_replication
if protocol.to_s == default_ingress_replication &&
(ingress_replication != default_ingress_replication)
set_args_keys(state: 'no', protocol: ingress_replication)
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
else
unless multicast_group.empty?
set_args_keys(state: 'no', ip_start: '', ip_end: '')
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
end
remove_add_ingress_replication(protocol.to_s)
end
end
|
#ingress_replication_supported? ⇒ Boolean
107
108
109
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 107
def ingress_replication_supported?
node.cmd_ref.supports?('vxlan_vtep_vni', 'ingress_replication')
end
|
#multicast_group ⇒ Object
166
167
168
169
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 166
def multicast_group
g1, g2 = config_get('vxlan_vtep_vni', 'multicast_group', @get_args)
g2.nil? ? g1 : g1 + ' ' + g2
end
|
#multicast_group=(range) ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 178
def multicast_group=(range)
if range == default_multicast_group
unless multicast_group.empty?
set_args_keys(state: 'no', ip_start: '', ip_end: '')
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
end
else
ip_start, ip_end = range.split(' ')
ip_end = '' if ip_end.nil?
if ingress_replication_supported? && !ingress_replication.empty?
set_args_keys(state: 'no', protocol: ingress_replication)
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
end
remove_add_multicast_group(ip_start, ip_end)
end
end
|
#multisite_ingress_replication ⇒ Object
310
311
312
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 310
def multisite_ingress_replication
config_get('vxlan_vtep_vni', 'multisite_ingress_replication', @get_args)
end
|
#multisite_ingress_replication=(state) ⇒ Object
314
315
316
317
318
319
320
321
322
323
324
325
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 314
def multisite_ingress_replication=(state)
@set_args[:state] = state ? '' : 'no'
if @set_args[:state] == 'no'
unless multisite_ingress_replication ==
default_multisite_ingress_replication
config_set('vxlan_vtep_vni', 'multisite_ingress_replication',
@set_args)
end
else
config_set('vxlan_vtep_vni', 'multisite_ingress_replication', @set_args)
end
end
|
#peer_list ⇒ Object
205
206
207
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 205
def peer_list
config_get('vxlan_vtep_vni', 'peer_list', @get_args)
end
|
#peer_list=(should_list) ⇒ Object
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 209
def peer_list=(should_list)
delta_hash = Utils.delta_add_remove(should_list, peer_list)
return if delta_hash.values.flatten.empty?
[:add, :remove].each do |action|
Cisco::Logger.debug('peer_list' \
"#{@get_args}\n #{action}: #{delta_hash[action]}")
delta_hash[action].each do |peer|
state = (action == :add) ? '' : 'no'
@set_args[:state] = state
@set_args[:peer] = peer
config_set('vxlan_vtep_vni', 'peer_list', @set_args)
end
end
end
|
#remove_add_ingress_replication(protocol) ⇒ Object
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 132
def remove_add_ingress_replication(protocol)
unless ingress_replication.to_s.empty?
set_args_keys(state: 'no', protocol: ingress_replication)
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
end
set_host_reachability(@set_args[:name], protocol)
set_args_keys(state: '', protocol: protocol)
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
end
|
#remove_add_multicast_group(ip_start, ip_end) ⇒ Object
171
172
173
174
175
176
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 171
def remove_add_multicast_group(ip_start, ip_end)
set_args_keys(state: 'no', ip_start: '', ip_end: '')
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
set_args_keys(state: '', ip_start: ip_start, ip_end: ip_end)
config_set('vxlan_vtep_vni', 'multicast_group', @set_args)
end
|
#set_args_keys(hash = {}) ⇒ Object
rubocop:disable Style/AccessorMethodName
65
66
67
68
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 65
def set_args_keys(hash={})
set_args_keys_default
@set_args = @get_args.merge!(hash) unless hash.empty?
end
|
#set_args_keys_default ⇒ Object
58
59
60
61
62
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 58
def set_args_keys_default
keys = { name: @name, vni: @vni }
keys[:assoc_vrf] = @assoc_vrf ? 'associate-vrf' : ''
@get_args = @set_args = keys
end
|
#set_host_reachability(vtep_name, protocol) ⇒ Object
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 115
def set_host_reachability(vtep_name, protocol)
case protocol
when 'bgp'
host_reachability = 'evpn'
when 'static'
host_reachability = 'flood'
else
fail "Protocol #{protocol} currently not supported"
end
VxlanVtep.new(vtep_name).host_reachability = host_reachability
end
|
#suppress_arp ⇒ Object
228
229
230
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 228
def suppress_arp
config_get('vxlan_vtep_vni', 'suppress_arp', @get_args)
end
|
#suppress_arp=(state) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 232
def suppress_arp=(state)
if state
set_args_keys(state: '')
unless VxlanVtep.new(@name).host_reachability == 'evpn'
fail "Dependency: vxlan_vtep host_reachability must be 'evpn'."
end
config_set('vxlan_vtep_vni', 'suppress_arp', @set_args)
else
set_args_keys(state: 'no')
config_set('vxlan_vtep_vni', 'suppress_arp', @set_args) if suppress_arp
end
end
|
#suppress_arp_disable ⇒ Object
255
256
257
258
259
260
261
262
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 255
def suppress_arp_disable
str = config_get('vxlan_vtep_vni', 'suppress_arp_disable', @get_args)
str.nil? ? false : true
end
|
#suppress_arp_disable=(state) ⇒ Object
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 264
def suppress_arp_disable=(state)
if state
set_args_keys(state: '')
unless VxlanVtep.new(@name).host_reachability == 'evpn'
fail "Dependency: vxlan_vtep host_reachability must be 'evpn'."
end
Feature.nv_overlay_evpn_enable if
Feature.nv_overlay_evpn_supported? && !Feature.nv_overlay_evpn_enabled?
config_set('vxlan_vtep_vni', 'suppress_arp_disable', @set_args)
else
set_args_keys(state: 'no')
config_set('vxlan_vtep_vni', 'suppress_arp_disable', @set_args) if
suppress_arp_disable
end
end
|
#suppress_uuc ⇒ Object
286
287
288
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 286
def suppress_uuc
config_get('vxlan_vtep_vni', 'suppress_uuc', @get_args)
end
|
#suppress_uuc=(state) ⇒ Object
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 290
def suppress_uuc=(state)
if state
set_args_keys(state: '')
unless VxlanVtep.new(@name).host_reachability == 'evpn'
fail "Dependency: vxlan_vtep host_reachability must be 'evpn'"
end
config_set('vxlan_vtep_vni', 'suppress_uuc', @set_args)
else
set_args_keys(state: 'no')
config_set('vxlan_vtep_vni', 'suppress_uuc', @set_args) if suppress_uuc
end
end
|