From c913aa0b93352b3cfe0267c37cb4c3583fd9d37c Mon Sep 17 00:00:00 2001 From: Wen Liang Date: Tue, 11 Oct 2022 18:20:18 -0400 Subject: [PATCH] Support 'route_metric4' for initscripts provider The user want to change the metric for the default route, add support for that. https://bugzilla.redhat.com/show_bug.cgi?id=2134201 Signed-off-by: Wen Liang --- README.md | 3 ++- library/network_connections.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8bb9817..90a5b57 100644 --- a/README.md +++ b/README.md @@ -526,7 +526,8 @@ The IP configuration supports the following options: [`ipv6.route-metric`](https://developer.gnome.org/NetworkManager/stable/nm-settings.html#nm-settings.property.ipv6.route-metric) properties, respectively. If specified, it determines the route metric for DHCP assigned routes and the default route, and thus the priority for multiple - interfaces. + interfaces. For `initscripts`, `route_metric4` sets the metric for the default + route and `route_metric6` is not supported. - `route` diff --git a/library/network_connections.py b/library/network_connections.py index 02659cc..074d79b 100644 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -323,8 +323,6 @@ class IfcfgUtil: if ip["dhcp4_send_hostname"] is not None: warn_fcn("ip.dhcp4_send_hostname is not supported by initscripts provider") - if ip["route_metric4"] is not None and ip["route_metric4"] >= 0: - warn_fcn("ip.route_metric4 is not supported by initscripts provider") if ip["route_metric6"] is not None and ip["route_metric6"] >= 0: warn_fcn("ip.route_metric6 is not supported by initscripts provider") @@ -516,6 +514,9 @@ class IfcfgUtil: else: ifcfg["DEFROUTE"] = "no" + if ip["route_metric4"] is not None and ip["route_metric4"] >= 0: + ifcfg["METRIC"] = str(ip["route_metric4"]) + route4 = [] route6 = [] for r in ip["route"]: