Class: Cisco::RouterOspf
- Defined in:
- lib/cisco_node_utils/router_ospf.rb
Overview
RouterOspf - node utility class for process-level OSPF config management
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.routers ⇒ Object
Create a hash of all router ospf instances.
Instance Method Summary collapse
-
#create ⇒ Object
Create one router ospf instance.
-
#destroy ⇒ Object
Destroy one router ospf instance.
-
#initialize(name, instantiate = true) ⇒ RouterOspf
constructor
A new instance of RouterOspf.
- #process_initialized? ⇒ Boolean
- #wait_for_process_initialized ⇒ Object
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(name, instantiate = true) ⇒ RouterOspf
Returns a new instance of RouterOspf.
24 25 26 27 28 29 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 24 def initialize(name, instantiate=true) fail ArgumentError unless name.length > 0 @name = name create if instantiate end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 22 def name @name end |
Class Method Details
.routers ⇒ Object
Create a hash of all router ospf instances
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 32 def self.routers ospf_ids = config_get('ospf', 'router') return {} if ospf_ids.nil? hash = {} ospf_ids.each do |name| hash[name] = RouterOspf.new(name, false) end return hash rescue Cisco::CliError # cmd will error when feature 'ospf' is not enabled raise if Feature.ospf_enabled? return {} end |
Instance Method Details
#create ⇒ Object
Create one router ospf instance
48 49 50 51 52 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 48 def create Feature.ospf_enable config_set('ospf', 'router', state: '', name: @name) wait_for_process_initialized end |
#destroy ⇒ Object
Destroy one router ospf instance
55 56 57 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 55 def destroy config_set('ospf', 'router', state: 'no', name: @name) end |
#process_initialized? ⇒ Boolean
59 60 61 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 59 def process_initialized? !config_get('ospf', 'process_initialized') end |
#wait_for_process_initialized ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 63 def wait_for_process_initialized return unless node.product_id[/N(5|6|8)/] # Hack for slow-start platforms which will have setter failures if the # ospf instance is still initializing. To see this problem in a sandbox # or even the cli do 'router ospf 1 ; router ospf 1 ; shutdown'. 4.times do return if process_initialized? sleep 1 node.cache_flush end fail 'OSPF process is not initialized yet' end |