Class: Y2Network::Routing
- Inherits:
-
Object
- Object
- Y2Network::Routing
- Includes:
- Yast2::Equatable
- Defined in:
- src/lib/y2network/routing.rb
Overview
General routing configuration storage (routing tables, forwarding setup, ...)
Instance Attribute Summary collapse
-
#forward_ipv4 ⇒ Boolean
Whether IPv4 forwarding is enabled.
-
#forward_ipv6 ⇒ Boolean
Whether IPv6 forwarding is enabled.
- #tables ⇒ Array<RoutingTable> readonly
Instance Method Summary collapse
-
#default_route ⇒ Route
Returns the default route.
-
#default_routes ⇒ Array<Route>
Returns the default routes.
-
#initialize(tables: [], forward_ipv4: false, forward_ipv6: false) ⇒ Routing
constructor
A new instance of Routing.
-
#remove_default_routes ⇒ Object
Remove default routes from routing tables.
-
#routes ⇒ Array<Route>
Routes in the configuration.
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_ipv4 ⇒ Boolean
Returns whether IPv4 forwarding is enabled.
30 31 32 |
# File 'src/lib/y2network/routing.rb', line 30 def forward_ipv4 @forward_ipv4 end |
#forward_ipv6 ⇒ Boolean
Returns whether IPv6 forwarding is enabled.
32 33 34 |
# File 'src/lib/y2network/routing.rb', line 32 def forward_ipv6 @forward_ipv6 end |
#tables ⇒ Array<RoutingTable> (readonly)
28 29 30 |
# File 'src/lib/y2network/routing.rb', line 28 def tables @tables end |
Instance Method Details
#default_route ⇒ Route
TODO:
Should we implement a default_routes
which returns an array instead?
Returns the default route
56 57 58 |
# File 'src/lib/y2network/routing.rb', line 56 def default_route routes.find(&:default?) end |
#default_routes ⇒ Array<Route>
Returns the default routes
63 64 65 |
# File 'src/lib/y2network/routing.rb', line 63 def default_routes routes.select(&:default?) end |
#remove_default_routes ⇒ Object
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 |
#routes ⇒ Array<Route>
Routes in the configuration
Convenience method to iterate through the routes in all routing tables.
47 48 49 |
# File 'src/lib/y2network/routing.rb', line 47 def routes tables.flat_map(&:to_a) end |