Class: Cisco::Vpc

Inherits:
NodeUtil show all
Defined in:
lib/cisco_node_utils/vpc.rb

Overview

Vpc - node utility class for VTP configuration management

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(domain_id, instantiate = true) ⇒ Vpc

Constructor for Vpc


30
31
32
33
34
# File 'lib/cisco_node_utils/vpc.rb', line 30

def initialize(domain_id, instantiate=true)
  @domain = domain_id

  create if instantiate
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain


28
29
30
# File 'lib/cisco_node_utils/vpc.rb', line 28

def domain
  @domain
end

Class Method Details

.domainsObject


36
37
38
39
40
41
42
# File 'lib/cisco_node_utils/vpc.rb', line 36

def self.domains
  hash = {}
  return hash unless Vpc.enabled
  my_domain = config_get('vpc', 'domain')
  hash[my_domain] = Vpc.new(my_domain, false) unless my_domain.nil?
  hash
end

.enabledObject


44
45
46
47
48
49
50
# File 'lib/cisco_node_utils/vpc.rb', line 44

def self.enabled
  config_get('vpc', 'feature')
rescue Cisco::CliError => e
  # cmd will syntax reject when feature is not enabled
  raise unless e.clierror =~ /Syntax error/
  return false
end

Instance Method Details

#arp_synchronizeObject


305
306
307
# File 'lib/cisco_node_utils/vpc.rb', line 305

def arp_synchronize
  config_get('vpc', 'arp_synchronize')
end

#arp_synchronize=(val) ⇒ Object


309
310
311
312
# File 'lib/cisco_node_utils/vpc.rb', line 309

def arp_synchronize=(val)
  set_args_keys(state: val ? '' : 'no')
  config_set('vpc', 'arp_synchronize', @set_args)
end

#auto_recoveryObject

PROPERTIES #


81
82
83
84
# File 'lib/cisco_node_utils/vpc.rb', line 81

def auto_recovery
  val = config_get('vpc', 'auto_recovery')
  val.nil? ? false : val
end

#auto_recovery=(val) ⇒ Object


86
87
88
89
# File 'lib/cisco_node_utils/vpc.rb', line 86

def auto_recovery=(val)
  set_args_keys(state: val ? '' : 'no')
  config_set('vpc', 'auto_recovery', @set_args)
end

#auto_recovery_reload_delayObject


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

def auto_recovery_reload_delay
  config_get('vpc', 'auto_recovery_reload_delay')
end

#auto_recovery_reload_delay=(val) ⇒ Object


99
100
101
102
# File 'lib/cisco_node_utils/vpc.rb', line 99

def auto_recovery_reload_delay=(val)
  set_args_keys(delay: val)
  config_set('vpc', 'auto_recovery_reload_delay', @set_args)
end

#createObject


52
53
54
55
# File 'lib/cisco_node_utils/vpc.rb', line 52

def create
  enable unless Vpc.enabled
  config_set('vpc', 'domain', state: '', domain: @domain)
end

#default_arp_synchronizeObject


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

def default_arp_synchronize
  config_get_default('vpc', 'arp_synchronize')
end

#default_auto_recoveryObject


91
92
93
# File 'lib/cisco_node_utils/vpc.rb', line 91

def default_auto_recovery
  config_get_default('vpc', 'auto_recovery')
end

#default_auto_recovery_reload_delayObject


104
105
106
# File 'lib/cisco_node_utils/vpc.rb', line 104

def default_auto_recovery_reload_delay
  config_get_default('vpc', 'auto_recovery_reload_delay')
end

#default_delay_restoreObject


117
118
119
# File 'lib/cisco_node_utils/vpc.rb', line 117

def default_delay_restore
  config_get_default('vpc', 'delay_restore')
end

#default_delay_restore_interface_vlanObject


130
131
132
# File 'lib/cisco_node_utils/vpc.rb', line 130

def default_delay_restore_interface_vlan
  config_get_default('vpc', 'delay_restore_interface_vlan')
end

#default_dual_active_exclude_interface_vlan_bridge_domainObject


144
145
146
147
# File 'lib/cisco_node_utils/vpc.rb', line 144

def default_dual_active_exclude_interface_vlan_bridge_domain
  config_get_default('vpc',
                     'dual_active_exclude_interface_vlan_bridge_domain')
end

#default_fabricpath_emulated_switch_idObject


160
161
162
# File 'lib/cisco_node_utils/vpc.rb', line 160

def default_fabricpath_emulated_switch_id
  config_get_default('vpc', 'fabricpath_emulated_switch_id')
end

#default_fabricpath_multicast_load_balanceObject


177
178
179
# File 'lib/cisco_node_utils/vpc.rb', line 177

def default_fabricpath_multicast_load_balance
  config_get_default('vpc', 'fabricpath_multicast_load_balance')
end

#default_graceful_consistency_checkObject


191
192
193
# File 'lib/cisco_node_utils/vpc.rb', line 191

def default_graceful_consistency_check
  config_get_default('vpc', 'graceful_consistency_check')
end

#default_layer3_peer_routingObject


207
208
209
# File 'lib/cisco_node_utils/vpc.rb', line 207

def default_layer3_peer_routing
  config_get_default('vpc', 'layer3_peer_routing')
end

#default_nd_synchronizeObject


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

def default_nd_synchronize
  config_get_default('vpc', 'nd_synchronize')
end

#default_peer_gatewayObject


323
324
325
# File 'lib/cisco_node_utils/vpc.rb', line 323

def default_peer_gateway
  config_get_default('vpc', 'peer_gateway')
end

#default_peer_gateway_exclude_bridge_domainObject


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

def default_peer_gateway_exclude_bridge_domain
  config_get_default('vpc', 'peer_gateway_exclude_bridge_domain')
end

#default_peer_gateway_exclude_vlanObject


361
362
363
# File 'lib/cisco_node_utils/vpc.rb', line 361

def default_peer_gateway_exclude_vlan
  config_get_default('vpc', 'peer_gateway_exclude_vlan')
end

#default_peer_keepalive_destObject


216
217
218
# File 'lib/cisco_node_utils/vpc.rb', line 216

def default_peer_keepalive_dest
  config_get_default('vpc', 'peer_keepalive_dest')
end

#default_peer_keepalive_hold_timeoutObject


224
225
226
# File 'lib/cisco_node_utils/vpc.rb', line 224

def default_peer_keepalive_hold_timeout
  config_get_default('vpc', 'peer_keepalive_hold_timeout')
end

#default_peer_keepalive_intervalObject


232
233
234
# File 'lib/cisco_node_utils/vpc.rb', line 232

def default_peer_keepalive_interval
  config_get_default('vpc', 'peer_keepalive_interval')
end

#default_peer_keepalive_interval_timeoutObject


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

def default_peer_keepalive_interval_timeout
  config_get_default('vpc', 'peer_keepalive_timeout')
end

#default_peer_keepalive_precedenceObject


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

def default_peer_keepalive_precedence
  config_get_default('vpc', 'peer_keepalive_precedence')
end

#default_peer_keepalive_srcObject


256
257
258
# File 'lib/cisco_node_utils/vpc.rb', line 256

def default_peer_keepalive_src
  config_get_default('vpc', 'peer_keepalive_src')
end

#default_peer_keepalive_udp_portObject


264
265
266
# File 'lib/cisco_node_utils/vpc.rb', line 264

def default_peer_keepalive_udp_port
  config_get_default('vpc', 'peer_keepalive_udp_port')
end

#default_peer_keepalive_vrfObject


272
273
274
# File 'lib/cisco_node_utils/vpc.rb', line 272

def default_peer_keepalive_vrf
  config_get_default('vpc', 'peer_keepalive_vrf')
end

#default_peer_switchObject


327
328
329
# File 'lib/cisco_node_utils/vpc.rb', line 327

def default_peer_switch
  config_get_default('vpc', 'peer_switch')
end

#default_port_channel_limitObject


378
379
380
# File 'lib/cisco_node_utils/vpc.rb', line 378

def default_port_channel_limit
  config_get_default('vpc', 'port_channel_limit')
end

#default_role_priorityObject


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

def default_role_priority
  config_get_default('vpc', 'role_priority')
end

#default_self_isolationObject


405
406
407
# File 'lib/cisco_node_utils/vpc.rb', line 405

def default_self_isolation
  config_get_default('vpc', 'self_isolation')
end

#default_shutdownObject


418
419
420
# File 'lib/cisco_node_utils/vpc.rb', line 418

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

#default_system_macObject


431
432
433
# File 'lib/cisco_node_utils/vpc.rb', line 431

def default_system_mac
  config_get_default('vpc', 'system_mac')
end

#default_system_priorityObject


444
445
446
# File 'lib/cisco_node_utils/vpc.rb', line 444

def default_system_priority
  config_get_default('vpc', 'system_priority')
end

#default_trackObject


462
463
464
# File 'lib/cisco_node_utils/vpc.rb', line 462

def default_track
  config_get_default('vpc', 'track')
end

#delay_restoreObject


108
109
110
# File 'lib/cisco_node_utils/vpc.rb', line 108

def delay_restore
  config_get('vpc', 'delay_restore')
end

#delay_restore=(delay) ⇒ Object


112
113
114
115
# File 'lib/cisco_node_utils/vpc.rb', line 112

def delay_restore=(delay)
  set_args_keys(delay: delay)
  config_set('vpc', 'delay_restore', @set_args)
end

#delay_restore_interface_vlanObject


121
122
123
# File 'lib/cisco_node_utils/vpc.rb', line 121

def delay_restore_interface_vlan
  config_get('vpc', 'delay_restore_interface_vlan')
end

#delay_restore_interface_vlan=(delay) ⇒ Object


125
126
127
128
# File 'lib/cisco_node_utils/vpc.rb', line 125

def delay_restore_interface_vlan=(delay)
  set_args_keys(delay: delay)
  config_set('vpc', 'delay_restore_interface_vlan', @set_args)
end

#destroyObject


57
58
59
# File 'lib/cisco_node_utils/vpc.rb', line 57

def destroy
  config_set('vpc', 'feature', state: 'no')
end

#dual_active_exclude_interface_vlan_bridge_domainObject


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

def dual_active_exclude_interface_vlan_bridge_domain
  config_get('vpc', 'dual_active_exclude_interface_vlan_bridge_domain')
end

#dual_active_exclude_interface_vlan_bridge_domain=(val) ⇒ Object


138
139
140
141
142
# File 'lib/cisco_node_utils/vpc.rb', line 138

def dual_active_exclude_interface_vlan_bridge_domain=(val)
  set_args_keys(state: val ? '' : 'no', range: val)
  config_set('vpc', 'dual_active_exclude_interface_vlan_bridge_domain',
             @set_args)
end

#enableObject


61
62
63
# File 'lib/cisco_node_utils/vpc.rb', line 61

def enable
  config_set('vpc', 'feature', state: '')
end

#fabricpath_emulated_switch_idObject


149
150
151
# File 'lib/cisco_node_utils/vpc.rb', line 149

def fabricpath_emulated_switch_id
  config_get('vpc', 'fabricpath_emulated_switch_id')
end

#fabricpath_emulated_switch_id=(switch_id) ⇒ Object


153
154
155
156
157
158
# File 'lib/cisco_node_utils/vpc.rb', line 153

def fabricpath_emulated_switch_id=(switch_id)
  FabricpathGlobal.fabricpath_enable
  set_args_keys(state: switch_id ? '' : 'no',
                swid:  switch_id ? switch_id : '')
  config_set('vpc', 'fabricpath_emulated_switch_id', @set_args)
end

#fabricpath_multicast_load_balanceObject

Note: fabricpath_multicast_load_balance also requires fabricpath_emulated_switch_id before it will be functional but it will config & nvgen independently.


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

def fabricpath_multicast_load_balance
  config_get('vpc', 'fabricpath_multicast_load_balance')
end

#fabricpath_multicast_load_balance=(state) ⇒ Object


171
172
173
174
175
# File 'lib/cisco_node_utils/vpc.rb', line 171

def fabricpath_multicast_load_balance=(state)
  FabricpathGlobal.fabricpath_enable
  set_args_keys(state: state ? '' : 'no')
  config_set('vpc', 'fabricpath_multicast_load_balance', @set_args)
end

#graceful_consistency_checkObject


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

def graceful_consistency_check
  val = config_get('vpc', 'graceful_consistency_check')
  val.nil? ? false : val
end

#graceful_consistency_check=(val) ⇒ Object


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

def graceful_consistency_check=(val)
  set_args_keys(state: val ? '' : 'no')
  config_set('vpc', 'graceful_consistency_check', @set_args)
end

#layer3_peer_routingObject


195
196
197
# File 'lib/cisco_node_utils/vpc.rb', line 195

def layer3_peer_routing
  config_get('vpc', 'layer3_peer_routing')
end

#layer3_peer_routing=(val) ⇒ Object


199
200
201
202
203
204
205
# File 'lib/cisco_node_utils/vpc.rb', line 199

def layer3_peer_routing=(val)
  return if val == layer3_peer_routing
  set_args_keys(state: val ? '' : 'no')
  # This requires peer_gateway to be set first
  self.peer_gateway = true if !peer_gateway && val
  config_set('vpc', 'layer3_peer_routing', @set_args)
end

#nd_synchronizeObject


314
315
316
# File 'lib/cisco_node_utils/vpc.rb', line 314

def nd_synchronize
  config_get('vpc', 'nd_synchronize')
end

#nd_synchronize=(val) ⇒ Object


318
319
320
321
# File 'lib/cisco_node_utils/vpc.rb', line 318

def nd_synchronize=(val)
  set_args_keys(state: val ? '' : 'no')
  config_set('vpc', 'nd_synchronize', @set_args)
end

#peer_gatewayObject


285
286
287
# File 'lib/cisco_node_utils/vpc.rb', line 285

def peer_gateway
  config_get('vpc', 'peer_gateway')
end

#peer_gateway=(val) ⇒ Object


289
290
291
292
293
294
# File 'lib/cisco_node_utils/vpc.rb', line 289

def peer_gateway=(val)
  set_args_keys(state: val ? '' : 'no')
  # disable layer3 routing first
  self.layer3_peer_routing = false if !val && layer3_peer_routing
  config_set('vpc', 'peer_gateway', @set_args)
end

#peer_gateway_exclude_bridge_domainObject


339
340
341
# File 'lib/cisco_node_utils/vpc.rb', line 339

def peer_gateway_exclude_bridge_domain
  config_get('vpc', 'peer_gateway_exclude_bridge_domain')
end

#peer_gateway_exclude_bridge_domain=(val) ⇒ Object


343
344
345
346
# File 'lib/cisco_node_utils/vpc.rb', line 343

def peer_gateway_exclude_bridge_domain=(val)
  set_args_keys(state: val ? '' : 'no', range: val)
  config_set('vpc', 'peer_gateway_exclude_bridge_domain', @set_args)
end

#peer_gateway_exclude_vlanObject


352
353
354
# File 'lib/cisco_node_utils/vpc.rb', line 352

def peer_gateway_exclude_vlan
  config_get('vpc', 'peer_gateway_exclude_vlan')
end

#peer_gateway_exclude_vlan=(val) ⇒ Object


356
357
358
359
# File 'lib/cisco_node_utils/vpc.rb', line 356

def peer_gateway_exclude_vlan=(val)
  set_args_keys(state: val ? '' : 'no', range: val)
  config_set('vpc', 'peer_gateway_exclude_vlan', @set_args)
end

#peer_keepalive_destObject

peer keepalive


212
213
214
# File 'lib/cisco_node_utils/vpc.rb', line 212

def peer_keepalive_dest
  config_get('vpc', 'peer_keepalive_dest')
end

#peer_keepalive_hold_timeoutObject


220
221
222
# File 'lib/cisco_node_utils/vpc.rb', line 220

def peer_keepalive_hold_timeout
  config_get('vpc', 'peer_keepalive_hold_timeout')
end

#peer_keepalive_intervalObject


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

def peer_keepalive_interval
  config_get('vpc', 'peer_keepalive_interval')
end

#peer_keepalive_interval_timeoutObject


236
237
238
# File 'lib/cisco_node_utils/vpc.rb', line 236

def peer_keepalive_interval_timeout
  config_get('vpc', 'peer_keepalive_timeout')
end

#peer_keepalive_precedenceObject


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

def peer_keepalive_precedence
  config_get('vpc', 'peer_keepalive_precedence')
end

#peer_keepalive_set(dest, src, udp_port, vrf, interval, timeout, prec, hold_timeout) ⇒ Object

common setter


277
278
279
280
281
282
283
# File 'lib/cisco_node_utils/vpc.rb', line 277

def peer_keepalive_set(dest, src, udp_port, vrf, interval, timeout,
                       prec, hold_timeout)
  set_args_keys(dest: dest, src: src, port_num: udp_port, vrf: vrf,
                interval: interval, timeout: timeout,
                precedence: prec, hold_timeout: hold_timeout)
  config_set('vpc', 'peer_keepalive_set', @set_args)
end

#peer_keepalive_srcObject


252
253
254
# File 'lib/cisco_node_utils/vpc.rb', line 252

def peer_keepalive_src
  config_get('vpc', 'peer_keepalive_src')
end

#peer_keepalive_udp_portObject


260
261
262
# File 'lib/cisco_node_utils/vpc.rb', line 260

def peer_keepalive_udp_port
  config_get('vpc', 'peer_keepalive_udp_port')
end

#peer_keepalive_vrfObject


268
269
270
# File 'lib/cisco_node_utils/vpc.rb', line 268

def peer_keepalive_vrf
  config_get('vpc', 'peer_keepalive_vrf')
end

#peer_switchObject


296
297
298
# File 'lib/cisco_node_utils/vpc.rb', line 296

def peer_switch
  config_get('vpc', 'peer_switch')
end

#peer_switch=(val) ⇒ Object


300
301
302
303
# File 'lib/cisco_node_utils/vpc.rb', line 300

def peer_switch=(val)
  set_args_keys(state: val ? '' : 'no')
  config_set('vpc', 'peer_switch', @set_args)
end

#port_channel_limitObject


365
366
367
368
# File 'lib/cisco_node_utils/vpc.rb', line 365

def port_channel_limit
  val = config_get('vpc', 'port_channel_limit')
  val.nil? ? false : val
end

#port_channel_limit=(val) ⇒ Object


370
371
372
373
374
375
376
# File 'lib/cisco_node_utils/vpc.rb', line 370

def port_channel_limit=(val)
  set_args_keys(state: val ? '' : 'no')
  # This requires fabricpath_emulated_switch_id to be set first
  fail 'fabricpath_switch_id configuration is required in the vPC domain' if
    !fabricpath_emulated_switch_id && !val
  config_set('vpc', 'port_channel_limit', @set_args)
end

#role_priorityObject


382
383
384
# File 'lib/cisco_node_utils/vpc.rb', line 382

def role_priority
  config_get('vpc', 'role_priority')
end

#role_priority=(priority) ⇒ Object


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

def role_priority=(priority)
  set_args_keys(priority: priority)
  config_set('vpc', 'role_priority', @set_args)
end

#self_isolationObject


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

def self_isolation
  val = config_get('vpc', 'self_isolation')
  val.nil? ? false : val
end

#self_isolation=(val) ⇒ Object


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

def self_isolation=(val)
  set_args_keys(state: val ? '' : 'no')
  config_set('vpc', 'self_isolation', @set_args)
end

#set_args_keys(hash = {}) ⇒ Object

rubocop:disable Style/AccessorMethodName


71
72
73
74
# File 'lib/cisco_node_utils/vpc.rb', line 71

def set_args_keys(hash={})
  set_args_keys_default
  @set_args = @get_args.merge!(hash) unless hash.empty?
end

#set_args_keys_defaultObject


65
66
67
68
# File 'lib/cisco_node_utils/vpc.rb', line 65

def set_args_keys_default
  keys = { domain: @domain }
  @get_args = @set_args = keys
end

#shutdownObject


409
410
411
# File 'lib/cisco_node_utils/vpc.rb', line 409

def shutdown
  config_get('vpc', 'shutdown')
end

#shutdown=(val) ⇒ Object


413
414
415
416
# File 'lib/cisco_node_utils/vpc.rb', line 413

def shutdown=(val)
  set_args_keys(state: val ? '' : 'no')
  config_set('vpc', 'shutdown', @set_args)
end

#system_macObject


422
423
424
# File 'lib/cisco_node_utils/vpc.rb', line 422

def system_mac
  config_get('vpc', 'system_mac')
end

#system_mac=(mac_addr) ⇒ Object


426
427
428
429
# File 'lib/cisco_node_utils/vpc.rb', line 426

def system_mac=(mac_addr)
  set_args_keys(state: mac_addr.empty? ? 'no' : '', mac_addr: mac_addr)
  config_set('vpc', 'system_mac', @set_args)
end

#system_priorityObject


435
436
437
# File 'lib/cisco_node_utils/vpc.rb', line 435

def system_priority
  config_get('vpc', 'system_priority')
end

#system_priority=(priority) ⇒ Object


439
440
441
442
# File 'lib/cisco_node_utils/vpc.rb', line 439

def system_priority=(priority)
  set_args_keys(priority: priority)
  config_set('vpc', 'system_priority', @set_args)
end

#trackObject


448
449
450
# File 'lib/cisco_node_utils/vpc.rb', line 448

def track
  config_get('vpc', 'track')
end

#track=(val) ⇒ Object


452
453
454
455
456
457
458
459
460
# File 'lib/cisco_node_utils/vpc.rb', line 452

def track=(val)
  unless val.nil?
    fail ArgumentError, 'track must be an Integer' unless
      val.is_a?(Integer)
  end

  set_args_keys(state: (val == track) ? 'no' : '', val: val)
  config_set('vpc', 'track', @set_args)
end