Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Mar 27, 2019
1 parent b7d1571 commit 76537ad
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/lib/y2network/config_reader/routes_reader.rb
Expand Up @@ -31,7 +31,6 @@ class RoutesReader
# not defined, then /etc/sysconfig/network/routes is used
def initialize(routes_file: DEFAULT_ROUTES_FILE)
@routes_file = Yast::Path.new(".routes") if routes_file == DEFAULT_ROUTES_FILE
# TODO: dynamic agent registration (e.g. ifroute-<device> file(s))
end

# Load routing tables
Expand Down Expand Up @@ -76,21 +75,20 @@ def normalize_routes(routes)
routes.map do |route|
subnet, prefix = route["destination"].split("/")

if !prefix.nil?
route["destination"] = subnet
route["netmask"] = "/#{prefix}"
end
next if prefix.nil?

route["destination"] = subnet
route["netmask"] = "/#{prefix}"
route
end
end

# Given an IP and a netmask, returns a valid IPAddr object
# Given an IP and a netmaks, returns a valid IPAddr objecto
#
# @param ip_str [String] IP address; {MISSING_VALUE} means that the IP is not defined
# @param netmask_str [String] Netmask; {MISSING_VALUE} means than no netmaks was specified
# @param netmask_str [String] Netmask; {MISSING_VALUE} means than no netmask was specified
# @return [IPAddr,nil] The IP address or `nil` if the IP is missing
def build_ip(ip_str, netmask_str = MISSING_VALUE)
def build_ip(ip_str, netmask_str = nil)
return nil if ip_str == MISSING_VALUE
ip = IPAddr.new(ip_str)
netmask_str == MISSING_VALUE ? ip : ip.mask(netmask_str)
Expand Down

0 comments on commit 76537ad

Please sign in to comment.