Class: Cisco::EvpnMultisite

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

Overview

node_utils class for evpn_multisite

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(multisiteid, instantiate = true) ⇒ EvpnMultisite

Returns a new instance of EvpnMultisite.



26
27
28
29
30
31
32
33
34
# File 'lib/cisco_node_utils/evpn_multisite.rb', line 26

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

Instance Attribute Details

#multisiteidObject (readonly)

Returns the value of attribute multisiteid.



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

def multisiteid
  @multisiteid
end

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Class Method Details

.multisiteObject



54
55
56
57
58
59
# File 'lib/cisco_node_utils/evpn_multisite.rb', line 54

def self.multisite
  nu_obj = nil
  ms_id = config_get('evpn_multisite', 'multisite')
  nu_obj = EvpnMultisite.new(ms_id, false) if ms_id
  nu_obj
end

Instance Method Details

#createObject



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

def create
  # There is an issue with EX platform using
  # Feature.nv_overlay_enable generating error code '400'
  # Using config_set for enabling nv overlay
  config_set('feature', 'nv_overlay', state: '')
  sleep 1
  @set_args[:state] = ''
  config_set('evpn_multisite', 'multisite', @set_args)
end

#default_delay_restoreObject



92
93
94
# File 'lib/cisco_node_utils/evpn_multisite.rb', line 92

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

#delay_restoreObject



75
76
77
# File 'lib/cisco_node_utils/evpn_multisite.rb', line 75

def delay_restore
  config_get('evpn_multisite', 'delay_restore', @get_args)
end

#delay_restore=(time) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/cisco_node_utils/evpn_multisite.rb', line 79

def delay_restore=(time)
  # HACK: set a dummy time value when removing the property
  dummy_time = 30
  if time == default_delay_restore
    @set_args[:state] = 'no'
    @set_args[:time] = dummy_time
  else
    @set_args[:time] = time
    @set_args[:state] = '' unless @set_args[:state]
  end
  config_set('evpn_multisite', 'delay_restore', @set_args)
end

#destroyObject



46
47
48
49
50
51
52
# File 'lib/cisco_node_utils/evpn_multisite.rb', line 46

def destroy
  @set_args[:state] = 'no'
  # HACK: set time to a dummy value
  @set_args[:time] = 30
  config_set('evpn_multisite', 'delay_restore', @set_args)
  config_set('evpn_multisite', 'multisite', @set_args)
end

#multisiteObject



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

def multisite
  config_get('evpn_multisite', 'multisite')
end

#multisite=(multisiteid) ⇒ Object



65
66
67
68
69
70
71
72
73
# File 'lib/cisco_node_utils/evpn_multisite.rb', line 65

def multisite=(multisiteid)
  err_msg = "multisiteid must be either a 'String' or an" \
            " 'Integer' object"
  fail ArgumentError, err_msg unless multisiteid.is_a?(Integer) ||
                                     multisiteid.is_a?(String)
  @multisiteid = multisiteid.to_i
  @set_args[:multisiteid] = @multisiteid
  config_set('evpn_multisite', 'multisite', @set_args)
end