Class: Cisco::VlanDeprecated

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

Overview

Vlan - node utility class for VLAN configuration management

Direct Known Subclasses

Vlan

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?

Instance Method Details

#association_delta(is, should) ⇒ Object


association_delta is a helper function for the private_vlan_association property. It walks the delta hash and adds/removes each target private vlan.


94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/cisco_node_utils/vlan_DEPRECATED.rb', line 94

def association_delta(is, should)
  delta_hash = Utils.delta_add_remove(should, is)
  Cisco::Logger.debug("association_delta: #{@vlan_id}: #{delta_hash}")
  [:add, :remove].each do |action|
    delta_hash[action].each do |vlans|
      state = (action == :add) ? '' : 'no'
      set_args_keys(state: state, vlans: vlans)
      result = config_set('DEPRECATED',
                          'private_vlan_association', @set_args)
      cli_error_check(result)
    end
  end
end

#default_private_vlan_associationObject


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

def default_private_vlan_association
  config_get_default('DEPRECATED', 'private_vlan_association')
end

#default_private_vlan_typeObject


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

def default_private_vlan_type
  config_get_default('DEPRECATED', 'private_vlan_type')
end

#deprecation_warning(method, new_prop = nil) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cisco_node_utils/vlan_DEPRECATED.rb', line 30

def deprecation_warning(method, new_prop=nil)
  if new_prop.nil?
    new_prop = ''
  else
    new_prop = "The new property name is '#{new_prop}'"
  end

  warn "
  #########################################################################
   WARNING: Method '#{method.to_s.delete('=')}'
   is deprecated and should not be used.
   #{new_prop}
  #########################################################################
  "
end

#private_vlan_associationObject


72
73
74
75
76
# File 'lib/cisco_node_utils/vlan_DEPRECATED.rb', line 72

def private_vlan_association
  return nil unless Feature.private_vlan_enabled?
  range = config_get('DEPRECATED', 'private_vlan_association', id: @vlan_id)
  Utils.normalize_range_array(range)
end

#private_vlan_association=(range) ⇒ Object


78
79
80
81
82
83
84
# File 'lib/cisco_node_utils/vlan_DEPRECATED.rb', line 78

def private_vlan_association=(range)
  deprecation_warning(__method__, 'pvlan_association')
  Feature.private_vlan_enable
  is = Utils.dash_range_to_elements(private_vlan_association)
  should = Utils.dash_range_to_elements(range)
  association_delta(is, should)
end

#private_vlan_typeObject


46
47
48
49
# File 'lib/cisco_node_utils/vlan_DEPRECATED.rb', line 46

def private_vlan_type
  return nil unless Feature.private_vlan_enabled?
  config_get('DEPRECATED', 'private_vlan_type', id: @vlan_id)
end

#private_vlan_type=(type) ⇒ Object


51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/cisco_node_utils/vlan_DEPRECATED.rb', line 51

def private_vlan_type=(type)
  deprecation_warning(__method__, 'pvlan_type')
  Feature.private_vlan_enable
  fail TypeError unless type && type.is_a?(String)

  if type == default_private_vlan_type
    return if private_vlan_type.empty?
    set_args_keys(state: 'no', type: private_vlan_type)
    ignore_msg = 'Warning: Private-VLAN CLI removed'
  else
    set_args_keys(state: '', type: type)
    ignore_msg = 'Warning: Private-VLAN CLI entered'
  end
  result = config_set('DEPRECATED', 'private_vlan_type', @set_args)
  cli_error_check(result, ignore_msg)
end