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

Returns a new instance of 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_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_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

#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

#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