Method: Rbeapi::Api::Ospf#get
- Defined in:
- lib/rbeapi/api/ospf.rb
#get(inst) ⇒ Hash
Returns the global OSPF configuration from the node.
rubocop:disable Metrics/MethodLength
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rbeapi/api/ospf.rb', line 69 def get(inst) config = get_block("router ospf #{inst}") return nil unless config response = {} mdata = /(?<=^\s{3}router-id\s)(.+)$/.match(config) response[:router_id] = mdata.nil? ? '' : mdata[0] mdata = /(?<=^\s{3}max-lsa\s)(\d+)(?=.*$)/.match(config) response[:max_lsa] = mdata.nil? ? '' : mdata[0].to_i mdata = /(?<=^\s{3}maximum-paths\s)(\d+)$/.match(config) response[:maximum_paths] = mdata.nil? ? '' : mdata[0].to_i mdata = /^\s{3}passive-interface default$/ =~ config response[:passive_interface_default] = !mdata.nil? response[:passive_interfaces] = config.scan(/(?<=^\s{3}passive-interface\s)(?!default)(.*)$/) .flatten!.to_a response[:active_interfaces] = config.scan(/(?<=^\s{3}no passive-interface\s)(.*)$/).flatten!.to_a networks = config.scan(/^\s{3}network\s(.+)\sarea\s(.+)$/) areas = networks.each_with_object({}) do |cfg, hsh| net, area = cfg if hsh.include?(area) hsh[area] << net else hsh[area] = [net] end end response[:areas] = areas values = \ config.scan(/(?<=^\s{3}redistribute\s)(\w+)[\s|$]*(route-map\s(.+))?/) response[:redistribute] = values.each_with_object({}) do |value, hsh| hsh[value[0]] = { route_map: value[2] } end response end |