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
149
150
151
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 149
def default_ingress_replication
config_get_default('vxlan_vtep_vni', 'ingress_replication')
end
|
#default_multicast_group ⇒ Object
188
189
190
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 188
def default_multicast_group
config_get_default('vxlan_vtep_vni', 'multicast_group')
end
|
#default_peer_list ⇒ Object
211
212
213
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 211
def default_peer_list
config_get_default('vxlan_vtep_vni', 'peer_list')
end
|
#default_suppress_arp ⇒ Object
238
239
240
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 238
def default_suppress_arp
config_get_default('vxlan_vtep_vni', 'suppress_arp')
end
|
#default_suppress_uuc ⇒ Object
262
263
264
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 262
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 131
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
153
154
155
156
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 153
def multicast_group
g1, g2 = config_get('vxlan_vtep_vni', 'multicast_group', @get_args)
g2.nil? ? g1 : g1 + ' ' + g2
end
|
#multicast_group=(range) ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 165
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
|
#peer_list ⇒ Object
192
193
194
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 192
def peer_list
config_get('vxlan_vtep_vni', 'peer_list', @get_args)
end
|
#peer_list=(should_list) ⇒ Object
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 196
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 115
def remove_add_ingress_replication(protocol)
if ingress_replication.to_s.empty?
set_args_keys(state: '', protocol: protocol)
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
else
set_args_keys(state: 'no', protocol: ingress_replication)
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
set_args_keys(state: '', protocol: protocol)
config_set('vxlan_vtep_vni', 'ingress_replication', @set_args)
end
end
|
#remove_add_multicast_group(ip_start, ip_end) ⇒ Object
158
159
160
161
162
163
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 158
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
|
#suppress_arp ⇒ Object
215
216
217
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 215
def suppress_arp
config_get('vxlan_vtep_vni', 'suppress_arp', @get_args)
end
|
#suppress_arp=(state) ⇒ Object
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 219
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_uuc ⇒ Object
242
243
244
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 242
def suppress_uuc
config_get('vxlan_vtep_vni', 'suppress_uuc', @get_args)
end
|
#suppress_uuc=(state) ⇒ Object
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/cisco_node_utils/vxlan_vtep_vni.rb', line 246
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
|