Class: Cisco::VxlanVtep

Inherits:
NodeUtil show all
Defined in:
lib/cisco_node_utils/vxlan_vtep.rb

Overview

node_utils class for vxlan_vtep

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, instantiate = true) ⇒ VxlanVtep


28
29
30
31
32
33
34
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 28

def initialize(name, instantiate=true)
  fail TypeError unless name.is_a?(String)
  fail ArgumentError unless name.length > 0
  @name = name.downcase

  create if instantiate
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


26
27
28
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 26

def name
  @name
end

Class Method Details

.mt_full_supportObject


49
50
51
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 49

def self.mt_full_support
  config_get('vxlan_vtep', 'mt_full_support')
end

.mt_lite_supportObject


53
54
55
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 53

def self.mt_lite_support
  config_get('vxlan_vtep', 'mt_lite_support')
end

.vtepsObject


36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 36

def self.vteps
  hash = {}
  return hash unless Feature.nv_overlay_enabled?
  vtep_list = config_get('vxlan_vtep', 'all_interfaces')
  return hash if vtep_list.nil?

  vtep_list.each do |id|
    id = id.downcase
    hash[id] = VxlanVtep.new(id, false)
  end
  hash
end

Instance Method Details

#==(other) ⇒ Object


73
74
75
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 73

def ==(other)
  name == other.name
end

#createObject


57
58
59
60
61
62
63
64
65
66
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 57

def create
  if FabricpathGlobal.fabricpath_feature == :enabled &&
     node.product_id[/N(5|6)K/]
    fail 'VxLAN cannot be enabled with Fabricpath configured'
  end
  Feature.nv_overlay_enable
  Feature.vn_segment_vlan_based_enable if VxlanVtep.mt_lite_support
  # re-use the "interface command ref hooks"
  config_set('interface', 'create', name: @name)
end

#default_descriptionObject


92
93
94
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 92

def default_description
  config_get_default('interface', 'description')
end

#default_global_ingress_replication_bgpObject


222
223
224
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 222

def default_global_ingress_replication_bgp
  config_get_default('vxlan_vtep', 'global_ingress_replication_bgp')
end

#default_global_mcast_group_l2Object


265
266
267
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 265

def default_global_mcast_group_l2
  config_get_default('vxlan_vtep', 'global_mcast_group_l2')
end

#default_global_mcast_group_l3Object


282
283
284
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 282

def default_global_mcast_group_l3
  config_get_default('vxlan_vtep', 'global_mcast_group_l3')
end

#default_global_suppress_arpObject


248
249
250
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 248

def default_global_suppress_arp
  config_get_default('vxlan_vtep', 'global_suppress_arp')
end

#default_host_reachabilityObject


113
114
115
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 113

def default_host_reachability
  config_get_default('vxlan_vtep', 'host_reachability')
end

#default_multisite_border_gateway_interfaceObject


197
198
199
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 197

def default_multisite_border_gateway_interface
  config_get_default('vxlan_vtep', 'multisite_bg_intf')
end

#default_shutdownObject


173
174
175
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 173

def default_shutdown
  config_get_default('vxlan_vtep', 'shutdown')
end

#default_source_interfaceObject


136
137
138
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 136

def default_source_interface
  config_get_default('vxlan_vtep', 'source_intf')
end

#default_source_interface_hold_down_timeObject


160
161
162
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 160

def default_source_interface_hold_down_time
  config_get_default('vxlan_vtep', 'source_intf_hold_down_time')
end

#descriptionObject

PROPERTIES #


81
82
83
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 81

def description
  config_get('interface', 'description', name: @name)
end

#description=(desc) ⇒ Object


85
86
87
88
89
90
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 85

def description=(desc)
  fail TypeError unless desc.is_a?(String)
  state = desc.empty? ? 'no' : ''
  config_set('interface', 'description',
             name: @name, state: state, desc: desc)
end

#destroyObject


68
69
70
71
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 68

def destroy
  # re-use the "interface command ref hooks"
  config_set('interface', 'destroy', name: @name)
end

#global_ingress_replication_bgpObject


201
202
203
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 201

def global_ingress_replication_bgp
  config_get('vxlan_vtep', 'global_ingress_replication_bgp', name: @name)
end

#global_ingress_replication_bgp=(state) ⇒ Object


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 205

def global_ingress_replication_bgp=(state)
  set_args = { name: @name }
  if state
    set_args[:state] = ''
    # Host reachability must be enabled for this property
    unless VxlanVtep.new(@name).host_reachability == 'evpn'
      fail "Dependency: vxlan_vtep host_reachability must be 'evpn'."
    end
    config_set('vxlan_vtep', 'global_ingress_replication_bgp', set_args)
  else
    set_args[:state] = 'no'
    config_set('vxlan_vtep',
               'global_ingress_replication_bgp', set_args) if
               global_ingress_replication_bgp
  end
end

#global_mcast_group_l2Object


252
253
254
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 252

def global_mcast_group_l2
  config_get('vxlan_vtep', 'global_mcast_group_l2', name: @name)
end

#global_mcast_group_l2=(val) ⇒ Object


256
257
258
259
260
261
262
263
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 256

def global_mcast_group_l2=(val)
  if val
    set_args = { name: @name, ip: val, state: '' }
  else
    set_args = { name: @name, ip: '', state: 'no' }
  end
  config_set('vxlan_vtep', 'global_mcast_group_l2', set_args)
end

#global_mcast_group_l3Object


269
270
271
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 269

def global_mcast_group_l3
  config_get('vxlan_vtep', 'global_mcast_group_l3', name: @name)
end

#global_mcast_group_l3=(val) ⇒ Object


273
274
275
276
277
278
279
280
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 273

def global_mcast_group_l3=(val)
  if val
    set_args = { name: @name, ip: val, state: '' }
  else
    set_args = { name: @name, ip: '', state: 'no' }
  end
  config_set('vxlan_vtep', 'global_mcast_group_l3', set_args)
end

#global_suppress_arpObject


226
227
228
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 226

def global_suppress_arp
  config_get('vxlan_vtep', 'global_suppress_arp', name: @name)
end

#global_suppress_arp=(state) ⇒ Object


230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 230

def global_suppress_arp=(state)
  set_args = { name: @name }
  if state
    set_args[:state] = ''
    # Host reachability must be enabled for this property
    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', 'global_suppress_arp', set_args)
  else
    set_args[:state] = 'no'
    config_set('vxlan_vtep',
               'global_suppress_arp', set_args) if global_suppress_arp
  end
end

#host_reachabilityObject


96
97
98
99
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 96

def host_reachability
  hr = config_get('vxlan_vtep', 'host_reachability', name: @name)
  hr == 'bgp' ? 'evpn' : hr
end

#host_reachability=(val) ⇒ Object


101
102
103
104
105
106
107
108
109
110
111
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 101

def host_reachability=(val)
  set_args = { name: @name, proto: 'bgp' }
  if val.to_s == 'flood' && host_reachability == 'evpn'
    set_args[:state] = 'no'
  elsif val.to_s == 'evpn'
    set_args[:state] = ''
  else
    return
  end
  config_set('vxlan_vtep', 'host_reachability', set_args)
end

#multisite_border_gateway_interfaceObject


177
178
179
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 177

def multisite_border_gateway_interface
  config_get('vxlan_vtep', 'multisite_bg_intf', name: @name)
end

#multisite_border_gateway_interface=(val) ⇒ Object


181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 181

def multisite_border_gateway_interface=(val)
  set_args = { name: @name }
  set_args[:state] = val.empty? ? 'no' : ''
  # rubocop:disable LineLength
  set_args[:lpbk_intf] = val.empty? ? multisite_border_gateway_interface : val
  # rubocop:enable LineLength
  if set_args[:state] == 'no'
    intf = multisite_border_gateway_interface
    unless intf == default_multisite_border_gateway_interface
      config_set('vxlan_vtep', 'multisite_bg_intf', set_args)
    end
  else
    config_set('vxlan_vtep', 'multisite_bg_intf', set_args)
  end
end

#shutdownObject


164
165
166
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 164

def shutdown
  config_get('vxlan_vtep', 'shutdown', name: @name)
end

#shutdown=(bool) ⇒ Object


168
169
170
171
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 168

def shutdown=(bool)
  state = (bool ? '' : 'no')
  config_set('vxlan_vtep', 'shutdown', name: @name, state: state)
end

#source_interfaceObject


117
118
119
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 117

def source_interface
  config_get('vxlan_vtep', 'source_intf', name: @name)
end

#source_interface=(val) ⇒ Object


127
128
129
130
131
132
133
134
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 127

def source_interface=(val)
  # The source interface can only be changed if the nve
  # interface is in a shutdown state.
  current_state = shutdown
  self.shutdown = true unless shutdown
  source_interface_set(val)
  self.shutdown = current_state
end

#source_interface_hold_down_timeObject


140
141
142
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 140

def source_interface_hold_down_time
  config_get('vxlan_vtep', 'source_intf_hold_down_time', name: @name)
end

#source_interface_hold_down_time=(time) ⇒ Object


144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 144

def source_interface_hold_down_time=(time)
  state = time == default_source_interface_hold_down_time ? 'no' : ''
  # Cli rejects removing hold-down-time without an argument, so make
  # sure it is configured before attempting to remove it
  if state == 'no'
    time = source_interface_hold_down_time
    unless time == default_source_interface_hold_down_time
      config_set('vxlan_vtep', 'source_intf_hold_down_time', name: @name,
                         state: state, time: time)
    end
  else
    config_set('vxlan_vtep', 'source_intf_hold_down_time', name: @name,
                           state: state, time: time)
  end
end

#source_interface_set(val) ⇒ Object


121
122
123
124
125
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 121

def source_interface_set(val)
  set_args = { name: @name, lpbk_intf: val }
  set_args[:state] = val.empty? ? 'no' : ''
  config_set('vxlan_vtep', 'source_intf', set_args)
end