Class: Cisco::EvpnVni
Overview
node_utils class for evpn_vni
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(vni, instantiate = true) ⇒ EvpnVni
Returns a new instance of EvpnVni.
26
27
28
29
30
31
32
33
34
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 26
def initialize(vni, instantiate=true)
err_msg = "vni must be either a 'String' or an" \
" 'Integer' object"
fail ArgumentError, err_msg unless vni.is_a?(Integer) ||
vni.is_a?(String)
@vni = vni.to_i
@get_args = @set_args = { vni: @vni }
create if instantiate
end
|
Instance Attribute Details
#vni ⇒ Object
Returns the value of attribute vni.
24
25
26
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 24
def vni
@vni
end
|
Class Method Details
.enable ⇒ Object
enable feature bgp and nv overlay evpn
.vnis ⇒ Object
Creat a hash of all vni instance
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 37
def self.vnis
hash = {}
return hash unless Feature.bgp_enabled?
vni_list = config_get('evpn_vni', 'vni')
return hash if vni_list.nil?
vni_list.each do |vni_id|
hash[vni_id] = EvpnVni.new(vni_id, false)
end
hash
end
|
Instance Method Details
#create ⇒ Object
49
50
51
52
53
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 49
def create
EvpnVni.enable unless EvpnVni.enabled
@set_args[:state] = ''
config_set('evpn_vni', 'vni', @set_args)
end
|
#default_route_distinguisher ⇒ Object
98
99
100
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 98
def default_route_distinguisher
config_get_default('evpn_vni', 'route_distinguisher')
end
|
#default_route_target_both ⇒ Object
112
113
114
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 112
def default_route_target_both
config_get_default('evpn_vni', 'route_target_both')
end
|
#default_route_target_export ⇒ Object
126
127
128
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 126
def default_route_target_export
config_get_default('evpn_vni', 'route_target_export')
end
|
#default_route_target_import ⇒ Object
140
141
142
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 140
def default_route_target_import
config_get_default('evpn_vni', 'route_target_import')
end
|
#destroy ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 55
def destroy
@set_args[:state] = 'no'
config_set('evpn_vni', 'vni', @set_args)
vni_list = config_get('evpn_vni', 'vni')
config_set('evpn_vni', 'evpn', @set_args) if vni_list.nil?
end
|
#route_distinguisher ⇒ Object
Attributes: Route Distinguisher (Getter/Setter/Default)
80
81
82
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 80
def route_distinguisher
config_get('evpn_vni', 'route_distinguisher', @get_args)
end
|
#route_distinguisher=(rd) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 84
def route_distinguisher=(rd)
if rd == default_route_distinguisher
@set_args[:state] = 'no'
rd = route_distinguisher
return if rd.to_s.empty?
else
@set_args[:state] = ''
end
@set_args[:rd] = rd
config_set('evpn_vni', 'route_distinguisher', @set_args)
set_args_keys_default
end
|
#route_target_both ⇒ Object
103
104
105
106
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 103
def route_target_both
cmds = config_get('evpn_vni', 'route_target_both', @get_args)
cmds.sort
end
|
#route_target_both=(should) ⇒ Object
108
109
110
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 108
def route_target_both=(should)
route_target_delta(should, route_target_both, 'route_target_both')
end
|
#route_target_delta(should, is, prop) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 144
def route_target_delta(should, is, prop)
delta_hash = Utils.delta_add_remove(should, is)
return if delta_hash.values.flatten.empty?
[:add, :remove].each do |action|
Cisco::Logger.debug("#{prop}" \
"#{@get_args}\n #{action}: #{delta_hash[action]}")
delta_hash[action].each do ||
state = (action == :add) ? '' : 'no'
@set_args[:state] = state
@set_args[:community] =
config_set('evpn_vni', prop, @set_args)
end
end
end
|
#route_target_export ⇒ Object
117
118
119
120
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 117
def route_target_export
cmds = config_get('evpn_vni', 'route_target_export', @get_args)
cmds.sort
end
|
#route_target_export=(should) ⇒ Object
122
123
124
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 122
def route_target_export=(should)
route_target_delta(should, route_target_export, 'route_target_export')
end
|
#route_target_import ⇒ Object
131
132
133
134
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 131
def route_target_import
cmds = config_get('evpn_vni', 'route_target_import', @get_args)
cmds.sort
end
|
#route_target_import=(should) ⇒ Object
136
137
138
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 136
def route_target_import=(should)
route_target_delta(should, route_target_import, 'route_target_import')
end
|
#set_args_keys_default ⇒ Object
74
75
76
|
# File 'lib/cisco_node_utils/evpn_vni.rb', line 74
def set_args_keys_default
@set_args = { vni: @vni }
end
|