Class: Y2Network::Routing

Inherits:
Object
  • Object
show all
Includes:
Yast2::Equatable
Defined in:
src/lib/y2network/routing.rb

Overview

General routing configuration storage (routing tables, forwarding setup, ...)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tables: [], forward_ipv4: false, forward_ipv6: false) ⇒ Routing

Returns a new instance of Routing.



36
37
38
39
40
# File 'src/lib/y2network/routing.rb', line 36

def initialize(tables: [], forward_ipv4: false, forward_ipv6: false)
  @tables = tables
  @forward_ipv4 = forward_ipv4
  @forward_ipv6 = forward_ipv6
end

Instance Attribute Details

#forward_ipv4Boolean

Returns whether IPv4 forwarding is enabled.

Returns:

  • (Boolean)

    whether IPv4 forwarding is enabled



30
31
32
# File 'src/lib/y2network/routing.rb', line 30

def forward_ipv4
  @forward_ipv4
end

#forward_ipv6Boolean

Returns whether IPv6 forwarding is enabled.

Returns:

  • (Boolean)

    whether IPv6 forwarding is enabled



32
33
34
# File 'src/lib/y2network/routing.rb', line 32

def forward_ipv6
  @forward_ipv6
end

#tablesArray<RoutingTable> (readonly)

Returns:



28
29
30
# File 'src/lib/y2network/routing.rb', line 28

def tables
  @tables
end

Instance Method Details

#default_routeRoute

TODO:

Should we implement a default_routes which returns an array instead?

Returns the default route

Returns:

  • (Route)

    Returns the first found default route



56
57
58
# File 'src/lib/y2network/routing.rb', line 56

def default_route
  routes.find(&:default?)
end

#default_routesArray<Route>

Returns the default routes

Returns:

  • (Array<Route>)

    Default routes



63
64
65
# File 'src/lib/y2network/routing.rb', line 63

def default_routes
  routes.select(&:default?)
end

#remove_default_routesObject

Remove default routes from routing tables



68
69
70
# File 'src/lib/y2network/routing.rb', line 68

def remove_default_routes
  tables.each(&:remove_default_routes)
end

#routesArray<Route>

Routes in the configuration

Convenience method to iterate through the routes in all routing tables.

Returns:

  • (Array<Route>)

    List of routes which are defined in the configuration



47
48
49
# File 'src/lib/y2network/routing.rb', line 47

def routes
  tables.flat_map(&:to_a)
end