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
.bgp_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.bgp_enable
return if bgp_enabled?
config_set('feature', 'bgp')
end
|
.bgp_enabled? ⇒ Boolean
31
32
33
|
# File 'lib/cisco_node_utils/feature.rb', line 31
def self.bgp_enabled?
config_get('feature', 'bgp')
end
|
.cli_error_check(result) ⇒ Object
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# File 'lib/cisco_node_utils/feature.rb', line 235
def self.cli_error_check(result)
fail result[2]['body'] if
result[2].is_a?(Hash) &&
/Hardware is not capable of supporting/.match(result[2]['body'].to_s)
fail result if
result.is_a?(String) &&
/Hardware is not capable of supporting/.match(result)
end
|
.compatible_interfaces(feature, property = 'supported_module_pids') ⇒ Object
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
# File 'lib/cisco_node_utils/feature.rb', line 251
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+/] }
vdc = Vdc.new(Vdc.default_vdc_name)
filt_intfs = vdc.interface_membership.select do |intf|
filt_slots.include? intf[/\d+/]
end
filt_intfs
end
|
.fabric_enable ⇒ Object
36
37
38
39
40
41
|
# File 'lib/cisco_node_utils/feature.rb', line 36
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
43
44
45
|
# File 'lib/cisco_node_utils/feature.rb', line 43
def self.fabric_enabled?
config_get('feature', 'fabric') =~ /^enabled/
end
|
.fabric_forwarding_enable ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/cisco_node_utils/feature.rb', line 56
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
70
71
72
|
# File 'lib/cisco_node_utils/feature.rb', line 70
def self.fabric_forwarding_enabled?
config_get('feature', 'fabric_forwarding')
end
|
.fabric_installed? ⇒ Boolean
47
48
49
|
# File 'lib/cisco_node_utils/feature.rb', line 47
def self.fabric_installed?
config_get('feature', 'fabric') !~ /^uninstalled/
end
|
.fabric_supported? ⇒ Boolean
51
52
53
|
# File 'lib/cisco_node_utils/feature.rb', line 51
def self.fabric_supported?
config_get('feature', 'fabric')
end
|
.fex_enable ⇒ Object
75
76
77
78
79
80
|
# File 'lib/cisco_node_utils/feature.rb', line 75
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
82
83
84
|
# File 'lib/cisco_node_utils/feature.rb', line 82
def self.fex_enabled?
config_get('feature', 'fex') =~ /^enabled/
end
|
.fex_installed? ⇒ Boolean
86
87
88
|
# File 'lib/cisco_node_utils/feature.rb', line 86
def self.fex_installed?
config_get('feature', 'fex') !~ /^uninstalled/
end
|
.fex_supported? ⇒ Boolean
90
91
92
|
# File 'lib/cisco_node_utils/feature.rb', line 90
def self.fex_supported?
config_get('feature', 'fex')
end
|
.itd_enable ⇒ Object
95
96
97
98
|
# File 'lib/cisco_node_utils/feature.rb', line 95
def self.itd_enable
return if itd_enabled?
config_set('feature', 'itd')
end
|
.itd_enabled? ⇒ Boolean
100
101
102
103
104
105
106
|
# File 'lib/cisco_node_utils/feature.rb', line 100
def self.itd_enabled?
config_get('feature', 'itd')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|
.nv_overlay_disable ⇒ Object
116
117
118
119
120
121
122
|
# File 'lib/cisco_node_utils/feature.rb', line 116
def self.nv_overlay_disable
return unless nv_overlay_enabled?
config_set('feature', 'nv_overlay', state: 'no')
sleep 1
end
|
.nv_overlay_enable ⇒ Object
109
110
111
112
113
114
|
# File 'lib/cisco_node_utils/feature.rb', line 109
def self.nv_overlay_enable
return if nv_overlay_enabled?
config_set('feature', 'nv_overlay', state: '')
sleep 1
end
|
.nv_overlay_enabled? ⇒ Boolean
124
125
126
127
128
129
130
|
# File 'lib/cisco_node_utils/feature.rb', line 124
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
137
138
139
140
|
# File 'lib/cisco_node_utils/feature.rb', line 137
def self.nv_overlay_evpn_enable
return if nv_overlay_evpn_enabled?
config_set('feature', 'nv_overlay_evpn')
end
|
.nv_overlay_evpn_enabled? ⇒ Boolean
142
143
144
|
# File 'lib/cisco_node_utils/feature.rb', line 142
def self.nv_overlay_evpn_enabled?
config_get('feature', 'nv_overlay_evpn')
end
|
.nv_overlay_evpn_supported? ⇒ Boolean
146
147
148
|
# File 'lib/cisco_node_utils/feature.rb', line 146
def self.nv_overlay_evpn_supported?
node.cmd_ref.supports?('feature', 'nv_overlay_evpn')
end
|
.nv_overlay_supported? ⇒ Boolean
132
133
134
|
# File 'lib/cisco_node_utils/feature.rb', line 132
def self.nv_overlay_supported?
node.cmd_ref.supports?('feature', 'nv_overlay')
end
|
.ospf_enable ⇒ Object
151
152
153
154
|
# File 'lib/cisco_node_utils/feature.rb', line 151
def self.ospf_enable
return if ospf_enabled?
config_set('feature', 'ospf')
end
|
.ospf_enabled? ⇒ Boolean
156
157
158
|
# File 'lib/cisco_node_utils/feature.rb', line 156
def self.ospf_enabled?
config_get('feature', 'ospf')
end
|
.pim_enable ⇒ Object
161
162
163
164
|
# File 'lib/cisco_node_utils/feature.rb', line 161
def self.pim_enable
return if pim_enabled?
config_set('feature', 'pim')
end
|
.pim_enabled? ⇒ Boolean
166
167
168
|
# File 'lib/cisco_node_utils/feature.rb', line 166
def self.pim_enabled?
config_get('feature', 'pim')
end
|
.private_vlan_enable ⇒ Object
171
172
173
174
|
# File 'lib/cisco_node_utils/feature.rb', line 171
def self.private_vlan_enable
return if private_vlan_enabled?
config_set('feature', 'private_vlan')
end
|
.private_vlan_enabled? ⇒ Boolean
176
177
178
|
# File 'lib/cisco_node_utils/feature.rb', line 176
def self.private_vlan_enabled?
config_get('feature', 'private_vlan')
end
|
.tacacs_enable ⇒ Object
181
182
183
184
|
# File 'lib/cisco_node_utils/feature.rb', line 181
def self.tacacs_enable
return if tacacs_enabled? || platform == :ios_xr
config_set('feature', 'tacacs')
end
|
.tacacs_enabled? ⇒ Boolean
186
187
188
|
# File 'lib/cisco_node_utils/feature.rb', line 186
def self.tacacs_enabled?
config_get('feature', 'tacacs')
end
|
.vn_segment_vlan_based_enable ⇒ Object
191
192
193
194
195
|
# File 'lib/cisco_node_utils/feature.rb', line 191
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
197
198
199
|
# File 'lib/cisco_node_utils/feature.rb', line 197
def self.vn_segment_vlan_based_enabled?
config_get('feature', 'vn_segment_vlan_based')
end
|
.vni_enable ⇒ Object
202
203
204
205
206
|
# File 'lib/cisco_node_utils/feature.rb', line 202
def self.vni_enable
return if vni_enabled?
result = config_set('feature', 'vni')
cli_error_check(result)
end
|
.vni_enabled? ⇒ Boolean
208
209
210
|
# File 'lib/cisco_node_utils/feature.rb', line 208
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.
221
222
223
224
|
# File 'lib/cisco_node_utils/feature.rb', line 221
def self.vtp_disable
return unless vtp_enabled?
config_set('feature', 'vtp', state: 'no')
end
|
.vtp_enable ⇒ Object
213
214
215
216
217
|
# File 'lib/cisco_node_utils/feature.rb', line 213
def self.vtp_enable
return if vtp_enabled?
result = config_set('feature', 'vtp', state: '')
cli_error_check(result)
end
|
.vtp_enabled? ⇒ Boolean
226
227
228
229
230
231
232
|
# File 'lib/cisco_node_utils/feature.rb', line 226
def self.vtp_enabled?
config_get('feature', 'vtp')
rescue Cisco::CliError => e
raise unless e.clierror =~ /Syntax error/
return false
end
|