Class: Cisco::Feature
Overview
Feature - node util class for managing common features
Class 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?
Class Method Details
.bfd_enable ⇒ Object
Note that in most cases the enable methods should only enable; however, for test purposes it is sometimes convenient to support feature disablement for cleanup purposes.
26
27
28
29
|
# File 'lib/cisco_node_utils/feature.rb', line 26
def self.bfd_enable
return if bfd_enabled?
config_set('feature', 'bfd')
end
|
.bfd_enabled? ⇒ Boolean
31
32
33
34
35
36
37
|
# File 'lib/cisco_node_utils/feature.rb', line 31
def self.bfd_enabled?
config_get('feature', 'bfd')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.bgp_enable ⇒ Object
40
41
42
43
|
# File 'lib/cisco_node_utils/feature.rb', line 40
def self.bgp_enable
return if bgp_enabled?
config_set('feature', 'bgp')
end
|
.bgp_enabled? ⇒ Boolean
45
46
47
|
# File 'lib/cisco_node_utils/feature.rb', line 45
def self.bgp_enabled?
config_get('feature', 'bgp')
end
|
.cli_error_check(result) ⇒ Object
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
# File 'lib/cisco_node_utils/feature.rb', line 331
def self.cli_error_check(result)
patterns = [
'Hardware is not capable of supporting',
'is unsupported on this node',
'Feature NOT supported on this Platform',
]
fail result[2]['body'] if
result[2].is_a?(Hash) &&
result[2]['body'].to_s[Regexp.union(patterns)]
fail result if
result.is_a?(String) && result[Regexp.union(patterns)]
end
|
.compatible_interfaces(feature, property = 'supported_module_pids') ⇒ Object
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
# File 'lib/cisco_node_utils/feature.rb', line 351
def self.compatible_interfaces(feature, property='supported_module_pids')
module_pids = config_get(feature, property)
return [] if module_pids.nil?
module_regex = Regexp.new module_pids
slots = Platform.slots.select do |_slot, filt_mod|
filt_mod['pid'] =~ module_regex
end
return [] if slots.empty?
filt_slots = slots.keys.map { |key| key[/\d+/] }
begin
vdc = Vdc.new(Vdc.default_vdc_name)
filt_intfs = vdc.interface_membership.select do |intf|
filt_slots.include? intf[/\d+/]
end
rescue CliError
filt_intfs = []
end
filt_intfs
end
|
.dhcp_enable ⇒ Object
50
51
52
53
|
# File 'lib/cisco_node_utils/feature.rb', line 50
def self.dhcp_enable
return if dhcp_enabled?
config_set('feature', 'dhcp')
end
|
.dhcp_enabled? ⇒ Boolean
55
56
57
58
59
60
61
|
# File 'lib/cisco_node_utils/feature.rb', line 55
def self.dhcp_enabled?
config_get('feature', 'dhcp')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.fabric_enable ⇒ Object
64
65
66
67
68
69
|
# File 'lib/cisco_node_utils/feature.rb', line 64
def self.fabric_enable
return if fabric_enabled?
config_set('feature', 'fabric', state: 'install') unless fabric_installed?
config_set('feature', 'fabric', state: '')
end
|
.fabric_enabled? ⇒ Boolean
71
72
73
|
# File 'lib/cisco_node_utils/feature.rb', line 71
def self.fabric_enabled?
config_get('feature', 'fabric') =~ /^enabled/
end
|
.fabric_forwarding_enable ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/cisco_node_utils/feature.rb', line 105
def self.fabric_forwarding_enable
return if fabric_forwarding_enabled?
Feature.fabric_enable if Feature.fabric_supported?
begin
config_set('feature', 'fabric_forwarding')
rescue Cisco::CliError
Cisco::Logger.debug '"feature fabric forwarding" CLI was rejected'
end
end
|
.fabric_forwarding_enabled? ⇒ Boolean
119
120
121
|
# File 'lib/cisco_node_utils/feature.rb', line 119
def self.fabric_forwarding_enabled?
config_get('feature', 'fabric_forwarding')
end
|
.fabric_installed? ⇒ Boolean
75
76
77
|
# File 'lib/cisco_node_utils/feature.rb', line 75
def self.fabric_installed?
config_get('feature', 'fabric') !~ /^uninstalled/
end
|
.fabric_supported? ⇒ Boolean
79
80
81
|
# File 'lib/cisco_node_utils/feature.rb', line 79
def self.fabric_supported?
config_get('feature', 'fabric')
end
|
.fabricpath_enable ⇒ Object
84
85
86
87
88
89
90
|
# File 'lib/cisco_node_utils/feature.rb', line 84
def self.fabricpath_enable
return if fabricpath_enabled?
config_set('feature', 'fabricpath', state: 'install') unless
fabricpath_installed?
config_set('feature', 'fabricpath', state: '')
end
|
.fabricpath_enabled? ⇒ Boolean
92
93
94
|
# File 'lib/cisco_node_utils/feature.rb', line 92
def self.fabricpath_enabled?
config_get('feature', 'fabricpath') =~ /^enabled/
end
|
.fabricpath_installed? ⇒ Boolean
96
97
98
|
# File 'lib/cisco_node_utils/feature.rb', line 96
def self.fabricpath_installed?
config_get('feature', 'fabricpath') !~ /^uninstalled/
end
|
.fabricpath_supported? ⇒ Boolean
100
101
102
|
# File 'lib/cisco_node_utils/feature.rb', line 100
def self.fabricpath_supported?
config_get('feature', 'fabricpath')
end
|
.fex_enable ⇒ Object
124
125
126
127
128
129
|
# File 'lib/cisco_node_utils/feature.rb', line 124
def self.fex_enable
return if fex_enabled?
config_set('feature', 'fex', state: 'install') unless fex_installed?
config_set('feature', 'fex', state: '')
end
|
.fex_enabled? ⇒ Boolean
131
132
133
|
# File 'lib/cisco_node_utils/feature.rb', line 131
def self.fex_enabled?
config_get('feature', 'fex') =~ /^enabled/
end
|
.fex_installed? ⇒ Boolean
135
136
137
|
# File 'lib/cisco_node_utils/feature.rb', line 135
def self.fex_installed?
config_get('feature', 'fex') !~ /^uninstalled/
end
|
.fex_supported? ⇒ Boolean
139
140
141
|
# File 'lib/cisco_node_utils/feature.rb', line 139
def self.fex_supported?
config_get('feature', 'fex')
end
|
.hsrp_enable ⇒ Object
144
145
146
147
|
# File 'lib/cisco_node_utils/feature.rb', line 144
def self.hsrp_enable
return if hsrp_enabled?
config_set('feature', 'hsrp')
end
|
.hsrp_enabled? ⇒ Boolean
149
150
151
152
153
154
155
|
# File 'lib/cisco_node_utils/feature.rb', line 149
def self.hsrp_enabled?
config_get('feature', 'hsrp')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.itd_enable ⇒ Object
158
159
160
161
|
# File 'lib/cisco_node_utils/feature.rb', line 158
def self.itd_enable
return if itd_enabled?
config_set('feature', 'itd')
end
|
.itd_enabled? ⇒ Boolean
163
164
165
166
167
168
169
|
# File 'lib/cisco_node_utils/feature.rb', line 163
def self.itd_enabled?
config_get('feature', 'itd')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.lacp_enable ⇒ Object
171
172
173
174
|
# File 'lib/cisco_node_utils/feature.rb', line 171
def self.lacp_enable
return if lacp_enabled?
config_set('feature', 'lacp')
end
|
.lacp_enabled? ⇒ Boolean
176
177
178
179
180
181
182
|
# File 'lib/cisco_node_utils/feature.rb', line 176
def self.lacp_enabled?
config_get('feature', 'lacp')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.ngmvpn_disable ⇒ Object
198
199
200
201
|
# File 'lib/cisco_node_utils/feature.rb', line 198
def self.ngmvpn_disable
return unless ngmvpn_enabled?
config_set('feature', 'ngmvpn', state: 'no')
end
|
.ngmvpn_enable ⇒ Object
185
186
187
188
|
# File 'lib/cisco_node_utils/feature.rb', line 185
def self.ngmvpn_enable
return if ngmvpn_enabled?
config_set('feature', 'ngmvpn', state: '')
end
|
.ngmvpn_enabled? ⇒ Boolean
190
191
192
193
194
195
196
|
# File 'lib/cisco_node_utils/feature.rb', line 190
def self.ngmvpn_enabled?
config_get('feature', 'ngmvpn')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.nv_overlay_disable ⇒ Object
212
213
214
215
216
217
218
|
# File 'lib/cisco_node_utils/feature.rb', line 212
def self.nv_overlay_disable
return unless nv_overlay_enabled?
config_set('feature', 'nv_overlay', state: 'no')
sleep 1
end
|
.nv_overlay_enable ⇒ Object
204
205
206
207
208
209
210
|
# File 'lib/cisco_node_utils/feature.rb', line 204
def self.nv_overlay_enable
return if nv_overlay_enabled?
result = config_set('feature', 'nv_overlay', state: '')
cli_error_check(result)
sleep 1
end
|
.nv_overlay_enabled? ⇒ Boolean
220
221
222
223
224
225
226
|
# File 'lib/cisco_node_utils/feature.rb', line 220
def self.nv_overlay_enabled?
config_get('feature', 'nv_overlay')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.nv_overlay_evpn_enable ⇒ Object
233
234
235
236
|
# File 'lib/cisco_node_utils/feature.rb', line 233
def self.nv_overlay_evpn_enable
return if nv_overlay_evpn_enabled?
config_set('feature', 'nv_overlay_evpn')
end
|
.nv_overlay_evpn_enabled? ⇒ Boolean
238
239
240
|
# File 'lib/cisco_node_utils/feature.rb', line 238
def self.nv_overlay_evpn_enabled?
config_get('feature', 'nv_overlay_evpn')
end
|
.nv_overlay_evpn_supported? ⇒ Boolean
242
243
244
|
# File 'lib/cisco_node_utils/feature.rb', line 242
def self.nv_overlay_evpn_supported?
node.cmd_ref.supports?('feature', 'nv_overlay_evpn')
end
|
.nv_overlay_supported? ⇒ Boolean
228
229
230
|
# File 'lib/cisco_node_utils/feature.rb', line 228
def self.nv_overlay_supported?
node.cmd_ref.supports?('feature', 'nv_overlay')
end
|
.ospf_enable ⇒ Object
247
248
249
250
|
# File 'lib/cisco_node_utils/feature.rb', line 247
def self.ospf_enable
return if ospf_enabled?
config_set('feature', 'ospf')
end
|
.ospf_enabled? ⇒ Boolean
252
253
254
|
# File 'lib/cisco_node_utils/feature.rb', line 252
def self.ospf_enabled?
config_get('feature', 'ospf')
end
|
.pim_enable ⇒ Object
257
258
259
260
|
# File 'lib/cisco_node_utils/feature.rb', line 257
def self.pim_enable
return if pim_enabled?
config_set('feature', 'pim')
end
|
.pim_enabled? ⇒ Boolean
262
263
264
|
# File 'lib/cisco_node_utils/feature.rb', line 262
def self.pim_enabled?
config_get('feature', 'pim')
end
|
.private_vlan_enable ⇒ Object
267
268
269
270
|
# File 'lib/cisco_node_utils/feature.rb', line 267
def self.private_vlan_enable
return if private_vlan_enabled?
config_set('feature', 'private_vlan')
end
|
.private_vlan_enabled? ⇒ Boolean
272
273
274
|
# File 'lib/cisco_node_utils/feature.rb', line 272
def self.private_vlan_enabled?
config_get('feature', 'private_vlan')
end
|
.tacacs_enable ⇒ Object
277
278
279
280
|
# File 'lib/cisco_node_utils/feature.rb', line 277
def self.tacacs_enable
return if tacacs_enabled? || platform == :ios_xr
config_set('feature', 'tacacs')
end
|
.tacacs_enabled? ⇒ Boolean
282
283
284
|
# File 'lib/cisco_node_utils/feature.rb', line 282
def self.tacacs_enabled?
config_get('feature', 'tacacs')
end
|
.vn_segment_vlan_based_enable ⇒ Object
287
288
289
290
291
|
# File 'lib/cisco_node_utils/feature.rb', line 287
def self.vn_segment_vlan_based_enable
return if vn_segment_vlan_based_enabled?
result = config_set('feature', 'vn_segment_vlan_based')
cli_error_check(result)
end
|
.vn_segment_vlan_based_enabled? ⇒ Boolean
293
294
295
|
# File 'lib/cisco_node_utils/feature.rb', line 293
def self.vn_segment_vlan_based_enabled?
config_get('feature', 'vn_segment_vlan_based')
end
|
.vni_enable ⇒ Object
298
299
300
301
302
|
# File 'lib/cisco_node_utils/feature.rb', line 298
def self.vni_enable
return if vni_enabled?
result = config_set('feature', 'vni')
cli_error_check(result)
end
|
.vni_enabled? ⇒ Boolean
304
305
306
|
# File 'lib/cisco_node_utils/feature.rb', line 304
def self.vni_enabled?
config_get('feature', 'vni')
end
|
.vtp_disable ⇒ Object
Special Case: The only way to remove a vtp instance is by disabling the feature.
317
318
319
320
|
# File 'lib/cisco_node_utils/feature.rb', line 317
def self.vtp_disable
return unless vtp_enabled?
config_set('feature', 'vtp', state: 'no')
end
|
.vtp_enable ⇒ Object
309
310
311
312
313
|
# File 'lib/cisco_node_utils/feature.rb', line 309
def self.vtp_enable
return if vtp_enabled?
result = config_set('feature', 'vtp', state: '')
cli_error_check(result)
end
|
.vtp_enabled? ⇒ Boolean
322
323
324
325
326
327
328
|
# File 'lib/cisco_node_utils/feature.rb', line 322
def self.vtp_enabled?
config_get('feature', 'vtp')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|