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

config_get, #config_get, config_get_default, #config_get_default, #config_set, config_set, #node, node, #show

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



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

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

#createObject



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

def create
  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)
end

#default_descriptionObject



90
91
92
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 90

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

#default_host_reachabilityObject



111
112
113
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 111

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

#default_shutdownObject



147
148
149
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 147

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

#default_source_interfaceObject



134
135
136
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 134

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

#descriptionObject

PROPERTIES #



77
78
79
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 77

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

#description=(desc) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 81

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

#destroyObject



64
65
66
67
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 64

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

#host_reachabilityObject



94
95
96
97
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 94

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

#host_reachability=(val) ⇒ Object



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

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



138
139
140
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 138

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

#shutdown=(bool) ⇒ Object



142
143
144
145
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 142

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

#source_interfaceObject



115
116
117
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 115

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

#source_interface=(val) ⇒ Object



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

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_set(val) ⇒ Object



119
120
121
122
123
# File 'lib/cisco_node_utils/vxlan_vtep.rb', line 119

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