Class: Rbeapi::Api::OspfInterfaces
- Defined in:
- lib/rbeapi/api/ospf.rb
Overview
The OspfInterfaces class is a global class that provides an instance for working with the node’s OSPF interface configuration
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#get(name) ⇒ nil, Hash<String, String>
Returns a single MLAG interface configuration.
-
#getall ⇒ nil, Hash<String, String>
Returns the collection of MLAG interfaces as a hash index by the interface name.
- #set_network_type(name, opts = {}) ⇒ Object
Methods inherited from Entity
#command_builder, #configure, #configure_interface, #get_block, #initialize, instance
Constructor Details
This class inherits a constructor from Rbeapi::Api::Entity
Instance Method Details
#get(name) ⇒ nil, Hash<String, String>
Returns a single MLAG interface configuration
Example
{
"name": <string>,
"network_type": <string>
}
160 161 162 163 164 165 166 167 168 169 |
# File 'lib/rbeapi/api/ospf.rb', line 160 def get(name) config = get_block("interface #{name}") return nil unless config return nil unless /no switchport$/ =~ config response = {} nettype = /ip ospf network point-to-point/ =~ config response['network_type'] = nettype.nil? ? 'broadcast' : 'point-to-point' response end |
#getall ⇒ nil, Hash<String, String>
Returns the collection of MLAG interfaces as a hash index by the interface name
Example
{
<name>: {...},
<name>: {...}
}
184 185 186 187 188 189 190 |
# File 'lib/rbeapi/api/ospf.rb', line 184 def getall interfaces = config.scan(/(?<=interface\s)[Et|Po|Lo|Vl].+/) interfaces.each_with_object({}) do |intf, hsh| values = get(intf) hsh[intf] = values if values end end |
#set_network_type(name, opts = {}) ⇒ Object
192 193 194 195 196 197 |
# File 'lib/rbeapi/api/ospf.rb', line 192 def set_network_type(name, opts = {}) value = opts[:value] return false unless [nil, 'point-to-point'].include?(value) cmd = command_builder('ip ospf network', opts) configure_interface(name, cmd) end |