Class: Cisco::RouterOspf
- Inherits:
-
Object
- Object
- Cisco::RouterOspf
- Defined in:
- lib/cisco_node_utils/router_ospf.rb
Constant Summary collapse
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .enable(state = "") ⇒ Object
- .enabled ⇒ Object
-
.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.
- #enable_create_router_ospf(name) ⇒ Object
-
#initialize(name, instantiate = true) ⇒ RouterOspf
constructor
A new instance of RouterOspf.
- #ospf_router(name, state = "") ⇒ Object
Constructor Details
#initialize(name, instantiate = true) ⇒ RouterOspf
Returns a new instance of RouterOspf.
28 29 30 31 32 33 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 28 def initialize(name, instantiate=true) raise ArgumentError unless name.length > 0 @name = name create if instantiate end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 24 def name @name end |
Class Method Details
.enable(state = "") ⇒ Object
60 61 62 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 60 def RouterOspf.enable(state="") @@node.config_set("ospf", "feature", state) end |
.enabled ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 51 def RouterOspf.enabled feat = @@node.config_get("ospf", "feature") return (!feat.nil? and !feat.empty?) rescue Cisco::CliError => e # cmd will syntax reject when feature is not enabled raise unless e.clierror =~ /Syntax error/ return false end |
.routers ⇒ Object
Create a hash of all router ospf instances
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 36 def RouterOspf.routers ospf_ids = @@node.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 => e # cmd will syntax reject when feature is not enabled raise unless e.clierror =~ /Syntax error/ return {} end |
Instance Method Details
#create ⇒ Object
Create one router ospf instance
74 75 76 77 78 79 80 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 74 def create if RouterOspf.enabled ospf_router(name) else enable_create_router_ospf(name) end end |
#destroy ⇒ Object
Destroy one router ospf instance
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 83 def destroy ospf_ids = @@node.config_get("ospf", "router") return if ospf_ids.nil? if ospf_ids.size == 1 RouterOspf.enable("no") else ospf_router(name, "no") end rescue Cisco::CliError => e # cmd will syntax reject when feature is not enabled raise unless e.clierror =~ /Syntax error/ end |
#enable_create_router_ospf(name) ⇒ Object
68 69 70 71 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 68 def enable_create_router_ospf(name) RouterOspf.enable ospf_router(name) end |
#ospf_router(name, state = "") ⇒ Object
64 65 66 |
# File 'lib/cisco_node_utils/router_ospf.rb', line 64 def ospf_router(name, state="") @@node.config_set("ospf", "router", state, name) end |