Class: Havox::RIB

Inherits:
Object
  • Object
show all
Defined in:
lib/havox/classes/rib.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ RIB

Returns a new instance of RIB.



5
6
7
8
# File 'lib/havox/classes/rib.rb', line 5

def initialize(opts = {})
  @opts = opts
  @routes = Havox::RouteFlow.ribs(vm_names, @opts)
end

Instance Attribute Details

#routesObject (readonly)

Returns the value of attribute routes.



3
4
5
# File 'lib/havox/classes/rib.rb', line 3

def routes
  @routes
end

Instance Method Details

#network_list(protocol = :bgp) ⇒ Object



16
17
18
# File 'lib/havox/classes/rib.rb', line 16

def network_list(protocol = :bgp)
  @routes.select { |r| r.protocol.eql?(protocol) }.map(&:network).uniq
end

#routes_to(ip, protocol = :bgp) ⇒ Object



10
11
12
13
14
# File 'lib/havox/classes/rib.rb', line 10

def routes_to(ip, protocol = :bgp)
  @routes.select do |r|
    r.protocol.eql?(protocol) && IPAddr.new(r.network).include?(ip)
  end
end