Skip to content

Commit

Permalink
Introduced Routing class
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Mar 21, 2019
1 parent ef749ee commit ebc3d36
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/lib/y2network/config.rb
Expand Up @@ -30,8 +30,8 @@ class Config
attr_reader :id
# @return [Array<Interface>]
attr_reader :interfaces
# @return [Array<RoutingTable>]
attr_reader :routing_tables
# @return [Routing] @see {Y2Network::Routing}
attr_reader :routing

# @param source [Symbol] Source to read the configuration from
class << self
Expand All @@ -45,20 +45,11 @@ def from(source)
#
# @param id [Symbol] Configuration ID
# @param interfaces [Array<Interface>] List of interfaces
# @param routing_tables [Array<RoutingTable>] List of routing tables
def initialize(id: :system, interfaces:, routing_tables:)
# @param routing [Routing] Object with routing configuration
def initialize(id: :system, interfaces:, routing:)
@id = id
@interfaces = interfaces
@routing_tables = routing_tables
end

# Routes in the configuration
#
# Convenience method to iterate through the routes in all routing tables.
#
# @return [Array<Route>] List of routes which are defined in the configuration
def routes
routing_tables.flat_map(&:to_a)
@routing= routing
end
end
end
42 changes: 42 additions & 0 deletions src/lib/y2network/routing.rb
@@ -0,0 +1,42 @@
# Copyright (c) [2019] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.
module Y2Network
# General routing configuration storage (routing tables, forwarding setup, ...)
class Routing
# @return [Array<RoutingTable>]
attr_reader :tables

# Checks whether IPv4 forwarding is enabled
def forward_ipv4?
end

# Checks whether IPv6 forwarding is enabled
def forward_ipv6?
end

# Routes in the configuration
#
# Convenience method to iterate through the routes in all routing tables.
#
# @return [Array<Route>] List of routes which are defined in the configuration
def routes
tables.flat_map(&:to_a)
end
end
end

0 comments on commit ebc3d36

Please sign in to comment.