Class: Cisco::FabricpathGlobal

Inherits:
NodeUtil
  • Object
show all
Defined in:
lib/cisco_node_utils/fabricpath_global.rb

Overview

node_utils class for fabricpath_global

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) ⇒ FabricpathGlobal

Returns a new instance of FabricpathGlobal.



28
29
30
31
32
33
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 28

def initialize(name, instantiate=true)
  fail ArgumentError unless name.to_s == 'default'
  @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/fabricpath_global.rb', line 26

def name
  @name
end

Class Method Details

.fabricpath_enableObject



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

def self.fabricpath_enable
  # TBD: Move to Feature provider
  FabricpathGlobal.fabricpath_feature_set(:enabled) unless
    FabricpathGlobal.fabricpath_feature == :enabled
end

.fabricpath_featureObject



47
48
49
50
51
52
53
54
55
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 47

def self.fabricpath_feature
  fabricpath = config_get('fabricpath', 'feature')
  return :disabled if fabricpath.nil?
  fabricpath.to_sym
rescue Cisco::CliError => e
  # cmd will syntax reject when feature is not enabled
  raise unless e.clierror =~ /Syntax error/
  return :disabled
end

.fabricpath_feature_set(fabricpath_set) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 63

def self.fabricpath_feature_set(fabricpath_set)
  curr = FabricpathGlobal.fabricpath_feature
  return if curr == fabricpath_set

  # NOTE: Add this in future if we want to automatically move only supported
  # interfaces into the VDC
  # if Vdc.vdc_support
  #   # For modular platforms, make sure to limit the feature to
  #   # modules which support this feature
  #   if fabricpath_set == :installed || fabricpath_set == :enabled
  #     v = Vdc.new('default')
  #     v.limit_resource_module_type =
  #        config_get('fabricpath', 'supported_modules')
  #     # exception will be raised for un-supported platforms/modules
  #   end
  # end

  case fabricpath_set
  when :enabled
    config_set('fabricpath', 'feature_install',
               state: '') if curr == :uninstalled
    config_set('fabricpath', 'feature', state: '')
  when :disabled
    config_set('fabricpath', 'feature', state: 'no') if curr == :enabled
    return
  when :installed
    config_set('fabricpath', 'feature_install',
               state: '') if curr == :uninstalled
  when :uninstalled
    config_set('fabricpath', 'feature', state: 'no') if curr == :enabled
    config_set('fabricpath', 'feature_install', state: 'no')
  end
end

.globalsObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 35

def self.globals
  hash = {}
  feature = config_get('fabricpath', 'feature')
  return hash if feature.nil? || feature.to_sym != :enabled
  hash['default'] = FabricpathGlobal.new('default', false)
  hash
rescue Cisco::CliError => e
  # cmd will syntax reject when feature is not enabled
  raise unless e.clierror =~ /Syntax error/
  return {}
end

Instance Method Details

#aggregate_multicast_routesObject

PROPERTIES #



124
125
126
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 124

def aggregate_multicast_routes
  config_get('fabricpath', 'aggregate_multicast_routes')
end

#aggregate_multicast_routes=(val) ⇒ Object



128
129
130
131
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 128

def aggregate_multicast_routes=(val)
  state = val ? '' : 'no'
  config_set('fabricpath', 'aggregate_multicast_routes', state: state)
end

#allocate_delayObject



137
138
139
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 137

def allocate_delay
  config_get('fabricpath', 'allocate_delay')
end

#allocate_delay=(val) ⇒ Object



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

def allocate_delay=(val)
  state = val ? '' : 'no'
  delay = val ? val : ''
  config_set('fabricpath', 'allocate_delay', state: state, delay: delay)
end

#auto_switch_idObject



151
152
153
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 151

def auto_switch_id
  config_get('fabricpath', 'auto_switch_id')
end

#createObject



97
98
99
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 97

def create
  FabricpathGlobal.fabricpath_enable
end

#default_aggregate_multicast_routesObject



133
134
135
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 133

def default_aggregate_multicast_routes
  config_get_default('fabricpath', 'aggregate_multicast_routes')
end

#default_allocate_delayObject



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

def default_allocate_delay
  config_get_default('fabricpath', 'allocate_delay')
end

#default_graceful_mergeObject



167
168
169
170
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 167

def default_graceful_merge
  graceful_merge = config_get_default('fabricpath', 'graceful_merge')
  graceful_merge.to_sym
end

#default_linkup_delayObject



182
183
184
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 182

def default_linkup_delay
  config_get_default('fabricpath', 'linkup_delay')
end

#default_linkup_delay_alwaysObject



199
200
201
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 199

def default_linkup_delay_always
  config_get_default('fabricpath', 'linkup_delay_always')
end

#default_linkup_delay_enableObject



218
219
220
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 218

def default_linkup_delay_enable
  config_get_default('fabricpath', 'linkup_delay_enable')
end

#default_loadbalance_algorithmObject



240
241
242
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 240

def default_loadbalance_algorithm
  config_get_default('fabricpath', 'loadbalance_algorithm')
end

#default_loadbalance_multicast_has_vlanObject

default_loadbalance_multicast_rotate: n/a



266
267
268
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 266

def default_loadbalance_multicast_has_vlan
  config_get_default('fabricpath', 'loadbalance_multicast_has_vlan')
end

#default_loadbalance_unicast_has_vlanObject

default_loadbalance_unicast_rotate: n/a



331
332
333
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 331

def default_loadbalance_unicast_has_vlan
  config_get_default('fabricpath', 'loadbalance_unicast_has_vlan')
end

#default_loadbalance_unicast_layerObject



325
326
327
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 325

def default_loadbalance_unicast_layer
  config_get_default('fabricpath', 'loadbalance_unicast_layer')
end

#default_modeObject



348
349
350
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 348

def default_mode
  config_get_default('fabricpath', 'mode')
end

#default_transition_delayObject



373
374
375
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 373

def default_transition_delay
  config_get_default('fabricpath', 'transition_delay')
end

#default_ttl_multicastObject



387
388
389
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 387

def default_ttl_multicast
  config_get_default('fabricpath', 'ttl_multicast')
end

#default_ttl_unicastObject



401
402
403
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 401

def default_ttl_unicast
  config_get_default('fabricpath', 'ttl_unicast')
end

#destroyObject



101
102
103
104
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 101

def destroy
  @name = nil
  FabricpathGlobal.fabricpath_feature_set(:disabled)
end

#graceful_mergeObject



155
156
157
158
159
160
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 155

def graceful_merge
  graceful_merge_conf = config_get('fabricpath', 'graceful_merge')
  # opposite meaning with the cli
  return :enable if graceful_merge_conf.nil?
  graceful_merge_conf ? :disable : :enable
end

#graceful_merge=(val) ⇒ Object



162
163
164
165
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 162

def graceful_merge=(val)
  state = val == :enable ? 'no' : ''
  config_set('fabricpath', 'graceful_merge', state: state)
end

#linkup_delayObject



172
173
174
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 172

def linkup_delay
  config_get('fabricpath', 'linkup_delay')
end

#linkup_delay=(val) ⇒ Object



176
177
178
179
180
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 176

def linkup_delay=(val)
  state = val ? '' : 'no'
  delay = val ? val : ''
  config_set('fabricpath', 'linkup_delay', state: state, delay: delay)
end

#linkup_delay_alwaysObject



186
187
188
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 186

def linkup_delay_always
  config_get('fabricpath', 'linkup_delay_always')
end

#linkup_delay_always=(val) ⇒ Object



190
191
192
193
194
195
196
197
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 190

def linkup_delay_always=(val)
  if val == '' || val == true
    state = ''
  else
    state = 'no'
  end
  config_set('fabricpath', 'linkup_delay_always', state: state)
end

#linkup_delay_enableObject



203
204
205
206
207
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 203

def linkup_delay_enable
  delay = config_get('fabricpath', 'linkup_delay_enable')
  return false if delay.nil?
  delay
end

#linkup_delay_enable=(val) ⇒ Object



209
210
211
212
213
214
215
216
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 209

def linkup_delay_enable=(val)
  if val == '' || val == true
    state = ''
  else
    state = 'no'
  end
  config_set('fabricpath', 'linkup_delay_enable', state: state)
end

#loadbalance_algorithmObject



227
228
229
230
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 227

def loadbalance_algorithm
  algo = config_get('fabricpath', 'loadbalance_algorithm')
  algo.downcase
end

#loadbalance_algorithm=(val) ⇒ Object



232
233
234
235
236
237
238
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 232

def loadbalance_algorithm=(val)
  val = loadbalance_munge('loadbalance_algorithm', val)
  state = val ? '' : 'no'
  algo = val ? val : ''
  config_set('fabricpath', 'loadbalance_algorithm', state: state,
                                                    algo:  algo)
end

#loadbalance_algorithm_symmetric_supportObject



222
223
224
225
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 222

def loadbalance_algorithm_symmetric_support
  config_get_default('fabricpath',
                     'loadbalance_algorithm_symmetric_support')
end

#loadbalance_multicast=(rotate, has_vlan) ⇒ Object



253
254
255
256
257
258
259
260
261
262
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 253

def loadbalance_multicast=(rotate, has_vlan)
  if rotate == '' && (has_vlan == '' || has_vlan == false)
    config_set('fabricpath', 'loadbalance_multicast_reset')
  else
    rotate = loadbalance_munge('loadbalance_multicast_rotate', rotate)
    has_vlan = (has_vlan == true) ? 'include-vlan' : ''
    config_set('fabricpath', 'loadbalance_multicast_set',
               rotate: rotate, has_vlan: has_vlan)
  end
end

#loadbalance_multicast_has_vlanObject



248
249
250
251
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 248

def loadbalance_multicast_has_vlan
  val = config_get('fabricpath', 'loadbalance_multicast_has_vlan')
  val.nil? ? false : val
end

#loadbalance_multicast_rotateObject



244
245
246
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 244

def loadbalance_multicast_rotate
  config_get('fabricpath', 'loadbalance_multicast_rotate')
end

#loadbalance_munge(property, set_val) ⇒ Object



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 106

def loadbalance_munge(property, set_val)
  case property
  when /loadbalance_algorithm/
    val = config_get_default('fabricpath', property)
    return val if (val == 'source-destination') && set_val[/symmetric|xor/]
    set_val
  when /loadbalance_.*_rotate/
    return '' if set_val == ''
    "rotate-amount 0x#{set_val.to_i.to_s(16)}"
  else
    set_val
  end
end

#loadbalance_unicast=(layer, rotate, has_vlan) ⇒ Object



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 308

def loadbalance_unicast=(layer, rotate, has_vlan)
  support = config_get('fabricpath', 'loadbalance_unicast_support')
  if support == 'combined'
    if layer == '' && rotate == '' && (has_vlan == '' || has_vlan == false)
      config_set('fabricpath', 'loadbalance_unicast_reset')
    else
      rotate = loadbalance_munge('loadbalance_unicast_rotate', rotate)
      has_vlan = (has_vlan == true) ? 'include-vlan' : ''
      config_set('fabricpath', 'loadbalance_unicast_set',
                 layer: layer, rotate: rotate, has_vlan: has_vlan)
    end
  else
    self.split_loadbalance_unicast_layer = layer
    self.split_loadbalance_unicast_has_vlan = has_vlan
  end
end

#loadbalance_unicast_has_vlanObject



287
288
289
290
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 287

def loadbalance_unicast_has_vlan
  val = config_get('fabricpath', 'loadbalance_unicast_has_vlan')
  val.nil? ? false : val
end

#loadbalance_unicast_layerObject



270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 270

def loadbalance_unicast_layer
  unicast = config_get('fabricpath', 'loadbalance_unicast_layer')
  return default_loadbalance_unicast_layer if unicast.nil?
  case unicast
  when /L4/
    'layer4'
  when /L3/
    'layer3'
  when /Mixed/
    'mixed'
  end
end

#loadbalance_unicast_rotateObject



283
284
285
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 283

def loadbalance_unicast_rotate
  config_get('fabricpath', 'loadbalance_unicast_rotate')
end

#modeObject



335
336
337
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 335

def mode
  config_get('fabricpath', 'mode')
end

#mode=(val) ⇒ Object



339
340
341
342
343
344
345
346
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 339

def mode=(val)
  if val == '' || val == 'normal'
    state = 'no'
  else
    state = ''
  end
  config_set('fabricpath', 'mode', state: state)
end

#split_loadbalance_unicast_has_vlan=(val) ⇒ Object



299
300
301
302
303
304
305
306
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 299

def split_loadbalance_unicast_has_vlan=(val)
  if val == '' || val == false
    state = 'no'
  else
    state = ''
  end
  config_set('fabricpath', 'loadbalance_unicast_has_vlan', state: state)
end

#split_loadbalance_unicast_layer=(val) ⇒ Object



292
293
294
295
296
297
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 292

def split_loadbalance_unicast_layer=(val)
  state = val ? '' : 'no'
  layer = val ? val : ''
  config_set('fabricpath', 'loadbalance_unicast_layer',
             state: state, layer: layer)
end

#switch_idObject



352
353
354
355
356
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 352

def switch_id
  switch_id_conf = config_get('fabricpath', 'switch_id')
  return auto_switch_id if switch_id_conf.nil?
  switch_id_conf
end

#switch_id=(val) ⇒ Object



358
359
360
361
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 358

def switch_id=(val)
  # There is no no-form for this command
  config_set('fabricpath', 'switch_id', swid: val.to_s)
end

#transition_delayObject



363
364
365
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 363

def transition_delay
  config_get('fabricpath', 'transition_delay')
end

#transition_delay=(val) ⇒ Object



367
368
369
370
371
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 367

def transition_delay=(val)
  state = val ? '' : 'no'
  delay = val ? val : ''
  config_set('fabricpath', 'transition_delay', state: state, delay: delay)
end

#ttl_multicastObject



377
378
379
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 377

def ttl_multicast
  config_get('fabricpath', 'ttl_multicast')
end

#ttl_multicast=(val) ⇒ Object



381
382
383
384
385
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 381

def ttl_multicast=(val)
  state = val ? '' : 'no'
  ttl = val ? val : ''
  config_set('fabricpath', 'ttl_multicast', state: state, ttl: ttl)
end

#ttl_unicastObject



391
392
393
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 391

def ttl_unicast
  config_get('fabricpath', 'ttl_unicast')
end

#ttl_unicast=(val) ⇒ Object



395
396
397
398
399
# File 'lib/cisco_node_utils/fabricpath_global.rb', line 395

def ttl_unicast=(val)
  state = val ? '' : 'no'
  ttl = val ? val : ''
  config_set('fabricpath', 'ttl_unicast', state: state, ttl: ttl)
end