Cases I tested:
(spoke is pre-hub network spoke)
Link has (slow) dhcp:
- connected in payload init, connected in spoke
- not connected in payload init, connected in spoke
- fixed by the patch
- not connected in payload init, not connected in spoke
- subcases: - wait for connection in spoke
- leave spoke while connecting
- fixed by the patch
Link does not have dhcp:
- configure static connection and leave spoke
---
anaconda | 3 +-
pyanaconda/network.py | 62 ++++++++++++++++++++++---------------
pyanaconda/packaging/__init__.py | 6 ++++
pyanaconda/ui/gui/spokes/network.py | 5 +++
4 files changed, 49 insertions(+), 27 deletions(-)
diff --git a/anaconda b/anaconda
index 35fb5ce..0789094 100755
--- a/anaconda
+++ b/anaconda
@@ -973,9 +973,8 @@ if __name__ == "__main__":
doRescue(anaconda.rescue_mount, ksdata, anaconda.platform)
threadMgr.add(AnacondaThread(name="AnaStorageThread",
target=storageInitialize, args=(anaconda.storage, ksdata, anaconda.protected)))
+ threadMgr.add(AnacondaThread(name="AnaNetworkThread",
target=networkInitialize, args=(ksdata,)))
threadMgr.add(AnacondaThread(name="AnaPayloadThread",
target=payloadInitialize, args=(anaconda.storage, ksdata, anaconda.payload)))
- # TODO start dhcp in thread if we have no connection
- networkInitialize(ksdata)
atexit.register(exitHandler, ksdata.reboot, anaconda.storage)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index dbdf5df..640cd70 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -486,28 +486,6 @@ def waitForDevicesActivation(devices):
return waited_devs_props.keys()
-# write out current configuration state and wait for NetworkManager
-# to bring the device up, watch NM state and return to the caller
-# once we have a state
-def waitForConnection():
- bus = dbus.SystemBus()
- nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH)
- props = dbus.Interface(nm, isys.DBUS_PROPS_IFACE)
-
- i = 0
- while i < CONNECTION_TIMEOUT:
- state = props.Get(isys.NM_SERVICE, "State")
- if nmIsConnected(state):
- return True
- i += 1
- time.sleep(1)
-
- state = props.Get(isys.NM_SERVICE, "State")
- if nmIsConnected(state):
- return True
-
- return False
-
# get a kernel cmdline string for dracut needed for access to storage host
def dracutSetupArgs(networkStorageDevice):
@@ -916,6 +894,38 @@ def writeNetworkConf(storage, ksdata, instClass):
disableNMForStorageDevices(storage)
autostartFCoEDevices(storage, ksdata)
+def wait_for_dhcp():
+ """If NM is in connecting state, wait for connection.
+ Return value: NM has got connection."""
+ bus = dbus.SystemBus()
+ nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH)
+ props = dbus.Interface(nm, isys.DBUS_PROPS_IFACE)
+ state = props.Get(isys.NM_SERVICE, "State")
+
+ if state == isys.NM_STATE_CONNECTING:
+ log.debug("waiting for connecting NM (dhcp?)")
+ else:
+ return False
+
+ i = 0
+ while (state == isys.NM_STATE_CONNECTING and
+ i < CONNECTION_TIMEOUT):
+ state = props.Get(isys.NM_SERVICE, "State")
+ if nmIsConnected(state):
+ log.debug("connected, waited %d seconds" % i)
+ return True
+ i += 1
+ time.sleep(1)
+
+ log.debug("not connected, waited %d of %d secs" % (i, CONNECTION_TIMEOUT))
+ return False
+
+def update_hostname(ksdata):
+ hostname = getHostname()
+ log.debug("updating hostname %s" % hostname)
+ nd = kickstartNetworkData(hostname=hostname)
+ ksdata.network.network.append(nd)
+
# networking initialization and ksdata object update
def networkInitialize(ksdata):
from pyanaconda.kickstart import NetworkData
@@ -925,6 +935,8 @@ def networkInitialize(ksdata):
createMissingDefaultIfcfgs()
if ksdata.network.hostname is None:
- hostname = getHostname()
- nd = kickstartNetworkData(hostname=hostname)
- ksdata.network.network.append(nd)
+ update_hostname(ksdata)
+
+ # auto default dhcp connection would be activated by NM service
+ if wait_for_dhcp():
+ update_hostname(ksdata)
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index 1186569..e9a5da1 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -658,6 +658,12 @@ def payloadInitialize(storage, ksdata, payload):
if storageThread:
storageThread.join()
+ # FIXME: condition for cases where we don't want network
+ # (set and use payload.needsNetwork ?)
+ networkThread = threadMgr.get("AnaNetworkThread")
+ if networkThread:
+ networkThread.join()
+
payload.setup(storage)
def show_groups(payload):
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 002679c..687319c 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -61,6 +61,9 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
N_ = lambda x: x
P_ = lambda x, y, z: gettext.ldngettext("anaconda", x, y, z)
+import logging
+log = logging.getLogger("anaconda")
+
# These are required for dbus API use we need because of
# NM_GI_BUGS: 767998, 773678
NM_SERVICE = "org.freedesktop.NetworkManager"
@@ -1051,6 +1054,7 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
parent.add(self.network_control_box.vbox)
self._initially_available = self.completed
+ log.debug("network standalone spoke (init): completed: %s" %
self._initially_available)
self._now_available = False
def apply(self):
@@ -1065,6 +1069,7 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
self._now_available = self.completed
+ log.debug("network standalone spoke (apply) payload: %s completed: %s"
% (self.payload.baseRepo, self._now_available))
if not self.payload.baseRepo and not self._initially_available and
self._now_available:
from pyanaconda.packaging import payloadInitialize
from pyanaconda.threads import threadMgr, AnacondaThread
--
1.7.11.7