Class: Cisco::Vdc

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

Overview

node_utils class for vdc

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NodeUtil

config_get, #config_get, config_get_default, #config_get_default, #config_set, config_set, #node, node, #show

Constructor Details

#initialize(name, instantiate = true) ⇒ Vdc

Returns a new instance of Vdc.



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

def initialize(name, instantiate=true)
  @vdc = (name == 'default') ? Vdc.default_vdc_name : name
  create if instantiate
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



25
26
27
# File 'lib/cisco_node_utils/vdc.rb', line 25

def name
  @name
end

Class Method Details

.default_vdc_nameObject



47
48
49
50
51
# File 'lib/cisco_node_utils/vdc.rb', line 47

def self.default_vdc_name
  vdc = config_get('vdc', 'default_vdc_name')
  fail RuntimeError if vdc.nil?
  vdc
end

.vdc_supportObject



43
44
45
# File 'lib/cisco_node_utils/vdc.rb', line 43

def self.vdc_support
  config_get('vdc', 'vdc_support')
end

.vdcsObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/cisco_node_utils/vdc.rb', line 32

def self.vdcs
  hash = {}
  vdc_list = config_get('vdc', 'all_vdcs')
  return hash if vdc_list.nil?

  vdc_list.each do |vdc_name|
    hash[vdc_name] = Vdc.new(vdc_name, false)
  end
  hash
end

Instance Method Details

#==(other) ⇒ Object



60
61
62
# File 'lib/cisco_node_utils/vdc.rb', line 60

def ==(other)
  name == other.name
end

#createObject



53
54
55
56
57
58
# File 'lib/cisco_node_utils/vdc.rb', line 53

def create
  fail ArgumentError,
       'There is currently no support for non-default VDCs' unless
    @vdc == Vdc.default_vdc_name
  # noop for 'default' vdc
end

#default_limit_resource_module_typeObject



84
85
86
# File 'lib/cisco_node_utils/vdc.rb', line 84

def default_limit_resource_module_type
  config_get_default('vdc', 'limit_resource_module_type')
end

#limit_resource_module_typeObject

PROPERTIES #



68
69
70
71
# File 'lib/cisco_node_utils/vdc.rb', line 68

def limit_resource_module_type
  str = config_get('vdc', 'limit_resource_module_type', vdc: @vdc)
  str.strip! unless str.nil?
end

#limit_resource_module_type=(mods) ⇒ Object



73
74
75
76
77
78
79
80
81
82
# File 'lib/cisco_node_utils/vdc.rb', line 73

def limit_resource_module_type=(mods)
  state = mods.empty? ? 'no' : ''
  config_set('vdc', 'limit_resource_module_type',
             state: state, vdc: @vdc, mods: mods)

  # TBD: No interfaces are allocated after changing the module-type
  # so 'allocate' is needed to make this useful. Consider moving
  # this into it's own property.
  config_set('vdc', 'allocate_interface_unallocated', vdc: @vdc)
end