[PATCH rhel7-branch] (v2) network: add support for --no-activate kickstart opton (#1277975)
by Radek Vykydal
Resolves: rhbz#1277975
This will allow to override special default of first network command
which is --activate.
---
dracut/parse-kickstart | 3 ++-
pyanaconda/network.py | 2 +-
pyanaconda/ui/gui/spokes/network.py | 8 +++++++-
pyanaconda/ui/tui/spokes/network.py | 7 ++++++-
4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
index 250274e..bc9cbdd 100755
--- a/dracut/parse-kickstart
+++ b/dracut/parse-kickstart
@@ -178,7 +178,8 @@ class Network(commands.network.RHEL7_Network, DracutArgsMixin):
# first 'network' line
if len(self.network) == 1:
- net.activate = True
+ if net.activate is None:
+ net.activate = True
# Note that there may be no net.device and no ksdevice if inst.ks=file:/ks.cfg
# If that is the case, fall into ksnet_to_dracut with net.device=None and let
# it handle things.
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index f04b1c7..38e3a18 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -1236,7 +1236,7 @@ def apply_kickstart(ksdata):
# If we have kickstart ifcfg from initramfs
if "Generated by parse-kickstart" in f.read():
# and we should activate the device
- if i == 0 or network_data.activate:
+ if network_data.activate or (i == 0 and network_data.activate is None):
ifcfg = IfcfgFile(ifcfg_path)
ifcfg.read()
con_uuid = ifcfg.get("UUID")
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 052a375..e2f3504 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -1673,13 +1673,19 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
def _update_network_data(data, ncb):
data.network.network = []
- for dev_cfg in ncb.dev_cfgs:
+ for i, dev_cfg in enumerate(ncb.dev_cfgs):
devname = dev_cfg.get_iface()
nd = network.ksdata_from_ifcfg(devname, dev_cfg.con_uuid)
if not nd:
continue
if devname in nm.nm_activated_devices():
nd.activate = True
+ else:
+ # First network command defaults to --activate so we must
+ # use --no-activate explicitly to prevent the default
+ if i == 0:
+ nd.activate = False
+
data.network.network.append(nd)
hostname = ncb.hostname
network.update_hostname_data(data, hostname)
diff --git a/pyanaconda/ui/tui/spokes/network.py b/pyanaconda/ui/tui/spokes/network.py
index f60b9ec..b0067fe 100644
--- a/pyanaconda/ui/tui/spokes/network.py
+++ b/pyanaconda/ui/tui/spokes/network.py
@@ -252,12 +252,17 @@ class NetworkSpoke(FirstbootSpokeMixIn, EditTUISpoke):
hostname = self.data.network.hostname
self.data.network.network = []
- for name in nm.nm_devices():
+ for i, name in enumerate(nm.nm_devices()):
nd = network.ksdata_from_ifcfg(name)
if not nd:
continue
if name in nm.nm_activated_devices():
nd.activate = True
+ else:
+ # First network command defaults to --activate so we must
+ # use --no-activate explicitly to prevent the default
+ if i == 0:
+ nd.activate = False
self.data.network.network.append(nd)
(valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
--
2.4.3
7 years, 10 months