Class: Cisco::EvpnStormcontrol

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

Overview

node_utils class for evpn_stormcontrol

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(stormcontrol_type, level, instantiate = true) ⇒ EvpnStormcontrol

Returns a new instance of EvpnStormcontrol.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cisco_node_utils/evpn_stormcontrol.rb', line 26

def initialize(stormcontrol_type, level, instantiate=true)
  err_msg = 'storm control type must be one of the following:' \
            ' broadcast, multicast or unicast'
  type_list = %w(broadcast multicast unicast)
  fail ArgumentError, err_msg unless type_list.include?(stormcontrol_type)
  @stormcontrol_type = stormcontrol_type

  err_msg = "level must be either a 'String' or an" \
            " 'Integer' object"
  fail ArgumentError, err_msg unless level.is_a?(Integer) ||
                                     level.is_a?(String)
  @level = level.to_i
  @get_args = @set_args = { stormcontrol_type: @stormcontrol_type,
                            level:             @level }
  create if instantiate
end

Instance Attribute Details

#levelObject

Returns the value of attribute level.



24
25
26
# File 'lib/cisco_node_utils/evpn_stormcontrol.rb', line 24

def level
  @level
end

#stormcontrol_typeObject (readonly)

Returns the value of attribute stormcontrol_type.



24
25
26
# File 'lib/cisco_node_utils/evpn_stormcontrol.rb', line 24

def stormcontrol_type
  @stormcontrol_type
end

Class Method Details

.stormcontrolObject

Create a hash of all stormcontrol instances



59
60
61
62
63
64
65
66
67
# File 'lib/cisco_node_utils/evpn_stormcontrol.rb', line 59

def self.stormcontrol
  hash = {}
  type_list = %w(broadcast multicast unicast)
  type_list.each do |type|
    level = config_get('evpn_stormcontrol', type)
    hash[type] = EvpnStormcontrol.new(type, level, false) if level
  end
  hash
end

Instance Method Details

#config_stormcontrolObject



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

def config_stormcontrol
  stormcontrol_type = @set_args[:stormcontrol_type]
  config_set('evpn_stormcontrol', stormcontrol_type, @set_args)
end

#createObject



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

def create
  @set_args[:state] = ''
  config_stormcontrol
end

#destroyObject



53
54
55
56
# File 'lib/cisco_node_utils/evpn_stormcontrol.rb', line 53

def destroy
  @set_args[:state] = 'no'
  config_stormcontrol
end