Class: PuppetX::Eos::Ospf
- Inherits:
-
Object
- Object
- PuppetX::Eos::Ospf
- Defined in:
- lib/puppet_x/eos/modules/ospf.rb
Overview
The Ospf class provides a base class instance for working with instances of OSPF
Instance Method Summary collapse
-
#create(inst) ⇒ Boolean
Creates a new instance of OSPF routing.
-
#default(inst) ⇒ Boolean
Defaults an instance of OSPF routing.
-
#delete(inst) ⇒ Boolean
Deletes an instance of OSPF routing.
-
#getall ⇒ Hash
Returns the base interface hash representing physical and logical interfaces in EOS using eAPI.
-
#initialize(api) ⇒ PuppetX::Eos::Ospf
constructor
Initialize instance of Ospf.
-
#set_router_id(inst, opts = {}) ⇒ Boolean
Configures the OSPF process router-id.
Constructor Details
#initialize(api) ⇒ PuppetX::Eos::Ospf
Initialize instance of Ospf
50 51 52 |
# File 'lib/puppet_x/eos/modules/ospf.rb', line 50 def initialize(api) @api = api end |
Instance Method Details
#create(inst) ⇒ Boolean
Creates a new instance of OSPF routing
81 82 83 |
# File 'lib/puppet_x/eos/modules/ospf.rb', line 81 def create(inst) @api.config("router ospf #{inst}") == [{}] end |
#default(inst) ⇒ Boolean
Defaults an instance of OSPF routing
101 102 103 |
# File 'lib/puppet_x/eos/modules/ospf.rb', line 101 def default(inst) @api.config("default router ospf #{inst}") == [{}] end |
#delete(inst) ⇒ Boolean
Deletes an instance of OSPF routing
91 92 93 |
# File 'lib/puppet_x/eos/modules/ospf.rb', line 91 def delete(inst) @api.config("no router ospf #{inst}") == [{}] end |
#getall ⇒ Hash
Returns the base interface hash representing physical and logical interfaces in EOS using eAPI
Example
{
"instances": {
"1": { "router_id": <String> }
}
}
66 67 68 69 70 71 72 73 |
# File 'lib/puppet_x/eos/modules/ospf.rb', line 66 def getall result = @api.enable('show ip ospf') instances = {} result[0]['vrfs']['default']['instList'].map do |inst, attrs| instances[inst] = { router_id: attrs['routerId'] } end { instances: instances } end |
#set_router_id(inst, opts = {}) ⇒ Boolean
Configures the OSPF process router-id
114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/puppet_x/eos/modules/ospf.rb', line 114 def set_router_id(inst, opts = {}) value = opts[:value] || false default = opts[:default] || false cmds = ["router ospf #{inst}"] case default when true cmds << 'default router-id' when false cmds << (value ? "router-id #{value}" : 'no router-id') end @api.config(cmds) == [{}, {}] end |