From: Martin Kolman <mkolman(a)redhat.com>
This makes the identifier easily accessible to Anaconda & addons
in case they want to change their behavior based on the current
runtime environment.
Related: rhbz#1270354
---
pyanaconda/flags.py | 4 +++-
pyanaconda/ui/common.py | 3 ---
pyanaconda/ui/gui/hubs/__init__.py | 2 +-
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/pyanaconda/flags.py b/pyanaconda/flags.py
index d647239..8a97f95 100644
--- a/pyanaconda/flags.py
+++ b/pyanaconda/flags.py
@@ -20,7 +20,7 @@
import selinux
import shlex
import glob
-from pyanaconda.constants import SELINUX_DEFAULT, CMDLINE_APPEND
+from pyanaconda.constants import SELINUX_DEFAULT, CMDLINE_APPEND, ANACONDA_ENVIRON
from collections import OrderedDict
import logging
@@ -76,6 +76,8 @@ def __init__(self, read_cmdline=True):
self.nosave_logs = False
# single language options
self.singlelang = False
+ # current runtime environments
+ self.environs = [ANACONDA_ENVIRON]
# parse the boot commandline
self.cmdline = BootArgs()
# Lock it down: no more creating new flags!
diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index e4f994e..39e7bb3 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -495,9 +495,6 @@ def __init__(self, storage, payload, instclass):
self.paths = {}
self._spokes = {}
- # spokes for which environments this hub should collect?
- self._environs = [ANACONDA_ENVIRON]
-
@abstractproperty
def data(self):
pass
diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
index 2563300..4aaab17 100644
--- a/pyanaconda/ui/gui/hubs/__init__.py
+++ b/pyanaconda/ui/gui/hubs/__init__.py
@@ -114,7 +114,7 @@ def _createBox(self):
selectors = []
for spokeClass in sorted(cats_and_spokes[c], key=lambda s: s.title):
# Check if this spoke is to be shown in the supported environments
- if not any(spokeClass.should_run(environ, self.data) for environ in self._environs):
+ if not any(spokeClass.should_run(environ, self.data) for environ in flags.environs):
continue
# Create the new spoke and populate its UI with whatever data.
--
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/52b59975c97244d7950554b0db60…
At the moment the network spoke tries to trigger a payload reset when network settings are changed even if running inside of Initial Setup. This is of course wrong, as there is no payload instance in Initial Setup, which can trigger a lot of various issues (crashes, weird log messages, etc.).
The first patch adds the environs flag so that spokes can easily check the environment at runtime. It also gets rid of the old _environs hub property.
The second patch then uses the environs flag to only trigger the payload reset when the network spoke is run from inside of Anaconda.
--
To view this pull request on github, visit https://github.com/rhinstaller/anaconda/pull/652
Resolves: rhbz#1277975
This will allow to override special default of first network command
which is --activate.
The use case is activating a device via boot options (eg for nfs mount of
installation image or source) and using another configuration for target system
via kickstart (nfs mount and installation could stale in this case if the ip
address changes for example).
I was considering also making --activate option support optional arguments
(allowing both for --activate for compatibility and --activate=no for this
use case) but optparse used in rhel7 pykickstart doesn't allow for nargs=?
(zero or one argument) as argparse does.
https://www.redhat.com/archives/anaconda-devel-list/2016-May/msg00008.html
---
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 9c36402..08d536a 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 not net.noactivate:
+ 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 402456f..b2e9503 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -1203,7 +1203,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 (i == 0 and not network_data.noactivate) or network_data.activate:
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 b48296b..aeea217 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -1636,13 +1636,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.noactivate = True
+
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 4b56890..9f1fe6e 100644
--- a/pyanaconda/ui/tui/spokes/network.py
+++ b/pyanaconda/ui/tui/spokes/network.py
@@ -257,12 +257,17 @@ class NetworkSpoke(FirstbootSpokeMixIn, EditTUISpoke):
hostname = self.data.network.hostname
self.data.network.network = []
- for name in nm.nm_devices():
+ for i, name in enumarate(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.noactivate = True
self.data.network.network.append(nd)
(valid, error) = network.sanityCheckHostname(self.hostname_dialog.value)
--
2.4.3