[PATCH master] Refactor DNS resolver reset.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 pyanaconda/gui.py                 |    6 ++++++
 pyanaconda/iw/advanced_storage.py |    2 --
 pyanaconda/iw/network_gui.py      |    3 ---
 pyanaconda/iw/task_gui.py         |    6 ------
 pyanaconda/kickstart.py           |    1 -
 pyanaconda/network.py             |   19 +++++++++++--------
 pyanaconda/yuminstall.py          |    8 --------
 7 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/pyanaconda/gui.py b/pyanaconda/gui.py
index ebd0085..a7707e3 100755
--- a/pyanaconda/gui.py
+++ b/pyanaconda/gui.py
@@ -965,6 +965,10 @@ class InstallInterface(InstallInterfaceBase):
                 if just_setup:
                     if failed_devs:
                         self._handleDeviceActivationFail(failed_devs)
+                    if len(failed_devs) < len(waited_devs):
+                        # if any device was activated, remember to reset
+                        # resolver
+                        networkEnabled = True
                 else:
                     networkEnabled = install_device not in failed_devs
                     if not networkEnabled:
@@ -973,6 +977,8 @@ class InstallInterface(InstallInterfaceBase):
             if just_setup:
                 break
 
+        if networkEnabled:
+            network.resetResolver()
         return networkEnabled
 
     def _handleDeviceActivationFail(self, devices):
diff --git a/pyanaconda/iw/advanced_storage.py b/pyanaconda/iw/advanced_storage.py
index 8a9d07f..24a5010 100644
--- a/pyanaconda/iw/advanced_storage.py
+++ b/pyanaconda/iw/advanced_storage.py
@@ -22,7 +22,6 @@ _ = lambda x: gettext.ldgettext("anaconda", x)
 import gobject
 import gtk
 import gtk.glade
-import urlgrabber.grabber
 import datacombo
 import DeviceSelector
 from pyanaconda import gui
@@ -430,7 +429,6 @@ def addIscsiDrive(anaconda):
     if not network.hasActiveNetDev():
         if not anaconda.intf.enableNetwork():
             return gtk.RESPONSE_CANCEL
-        urlgrabber.grabber.reset_curl_obj()
 
     # go through the wizard's dialogs, read the user input (selected nodes,
     # login credentials) and provide it to the iscsi subsystem
diff --git a/pyanaconda/iw/network_gui.py b/pyanaconda/iw/network_gui.py
index f7a4f92..dead8ca 100644
--- a/pyanaconda/iw/network_gui.py
+++ b/pyanaconda/iw/network_gui.py
@@ -30,7 +30,6 @@ import gobject
 import subprocess
 import gtk
 from pyanaconda import isys
-import urlgrabber.grabber
 
 from pyanaconda.constants import *
 import gettext
@@ -65,8 +64,6 @@ class NetworkWindow(InstallWindow):
 
     def _setupNetwork(self, *args):
         self.intf.enableNetwork(just_setup=True)
-        if network.hasActiveNetDev():
-            urlgrabber.grabber.reset_curl_obj()
 
     def focus(self):
         self.hostnameEntry.grab_focus()
diff --git a/pyanaconda/iw/task_gui.py b/pyanaconda/iw/task_gui.py
index cba030d..e639010 100644
--- a/pyanaconda/iw/task_gui.py
+++ b/pyanaconda/iw/task_gui.py
@@ -35,7 +35,6 @@ from pyanaconda import network
 from pyanaconda import iutil
 
 from pyanaconda.yuminstall import AnacondaYumRepo
-import urlgrabber.grabber
 import yum.Errors
 
 import logging
@@ -45,7 +44,6 @@ def setupRepo(anaconda, repo):
     if repo.needsNetwork() and not network.hasActiveNetDev():
         if not anaconda.intf.enableNetwork():
             return False
-        urlgrabber.grabber.reset_curl_obj()
     try:
         anaconda.backend.doRepoSetup(anaconda, thisrepo=repo.id, fatalerrors=False)
         anaconda.backend.doSackSetup(anaconda, thisrepo=repo.id, fatalerrors=False)
@@ -313,7 +311,6 @@ class RepoEditor:
                       "networking, but there was an error enabling the "
                       "network on your system."))
                 return False
-            urlgrabber.grabber.reset_curl_obj()
 
         import tempfile
         dest = tempfile.mkdtemp("", repo.name.replace(" ", ""), "/mnt")
@@ -540,7 +537,6 @@ class TaskWindow(InstallWindow):
             if not self.anaconda.intf.enableNetwork():
                 return gtk.RESPONSE_CANCEL
 
-            urlgrabber.grabber.reset_curl_obj()
 
         dialog = RepoEditor(self.anaconda, repo)
         dialog.createDialog()
@@ -591,8 +587,6 @@ class TaskWindow(InstallWindow):
                 if not self.anaconda.intf.enableNetwork():
                     return
 
-                urlgrabber.grabber.reset_curl_obj()
-
             repo.enable()
             if not setupRepo(self.anaconda, repo):
                 repo.disable()
diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index 85ceec8..b7c5e07 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -155,7 +155,6 @@ def getEscrowCertificate(anaconda, url):
                                         custom_icon="error",
                                         custom_buttons=[_("_Exit installer")])
             sys.exit(1)
-        urlgrabber.grabber.reset_curl_obj()
 
     log.info("escrow: downloading %s" % (url,))
 
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index ae06f1e..f377d1c 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -36,6 +36,7 @@ import dbus
 import tempfile
 from flags import flags
 from simpleconfig import IfcfgFile
+import urlgrabber.grabber
 
 import gettext
 _ = lambda x: gettext.ldgettext("anaconda", x)
@@ -77,7 +78,7 @@ def sanityCheckHostname(hostname):
 
 # Try to determine what the hostname should be for this system
 def getDefaultHostname(anaconda):
-    isys.resetResolv()
+    resetResolver()
 
     hn = None
 
@@ -766,20 +767,16 @@ class Network:
                 waited_devs_props[iface] = device_props_iface
 
         i = 0
-        reset_resolver = False
         while True:
             for dev, device_props_iface in waited_devs_props.items():
                 state = device_props_iface.Get(isys.NM_DEVICE_IFACE, "State")
                 if state == isys.NM_DEVICE_STATE_ACTIVATED:
                     waited_devs_props.pop(dev)
-                    reset_resolver = True
             if len(waited_devs_props) == 0 or i >= CONNECTION_TIMEOUT:
                 break
             i += 1
             time.sleep(1)
 
-        if reset_resolver:
-            isys.resetResolv()
         return waited_devs_props.keys()
 
     # write out current configuration state and wait for NetworkManager
@@ -794,14 +791,12 @@ class Network:
         while i < CONNECTION_TIMEOUT:
             state = props.Get(isys.NM_SERVICE, "State")
             if int(state) == isys.NM_STATE_CONNECTED:
-                isys.resetResolv()
                 return True
             i += 1
             time.sleep(1)
 
         state = props.Get(isys.NM_SERVICE, "State")
         if int(state) == isys.NM_STATE_CONNECTED:
-            isys.resetResolv()
             return True
 
         return False
@@ -811,7 +806,11 @@ class Network:
     # once we have a state
     def bringUp(self):
         self.write()
-        return self.waitForConnection()
+        if self.waitForConnection():
+            resetResolver()
+            return True
+        else:
+            return False
 
     # get a kernel cmdline string for dracut needed for access to host host
     def dracutSetupString(self, networkStorageDevice):
@@ -949,3 +948,7 @@ def ifaceForHostIP(host):
 
     return routeInfo[routeInfo.index("dev") + 1]
 
+def resetResolver():
+    isys.resetResolv()
+    urlgrabber.grabber.reset_curl_obj()
+
diff --git a/pyanaconda/yuminstall.py b/pyanaconda/yuminstall.py
index 71cb581..8f1dccd 100644
--- a/pyanaconda/yuminstall.py
+++ b/pyanaconda/yuminstall.py
@@ -513,8 +513,6 @@ class AnacondaYum(YumSorter):
                         self._baseRepoURL = None
                         return
 
-                    urlgrabber.grabber.reset_curl_obj()
-
                 self._switchImage(1)
                 self.mediagrabber = self.mediaHandler
             elif m.startswith("http") or m.startswith("ftp:"):
@@ -524,8 +522,6 @@ class AnacondaYum(YumSorter):
                     if not self.anaconda.intf.enableNetwork():
                         self._baseRepoURL = None
 
-                    urlgrabber.grabber.reset_curl_obj()
-
                 (opts, server, path) = iutil.parseNfsUrl(m)
                 isys.mount(server+":"+path, self.tree, "nfs", options=opts)
 
@@ -756,8 +752,6 @@ class AnacondaYum(YumSorter):
                             custom_buttons=[_("_Exit installer")])
                         sys.exit(1)
 
-                    urlgrabber.grabber.reset_curl_obj()
-
                     dest = tempfile.mkdtemp("", ksrepo.name.replace(" ", ""), "/mnt")
 
                     # handle "nfs://" prefix
@@ -1206,8 +1200,6 @@ reposdir=/etc/anaconda.repos.d,/tmp/updates/anaconda.repos.d,/tmp/product/anacon
                         type="custom", custom_icon="error",
                         custom_buttons=[_("_Exit installer")])
                     sys.exit(1)
-
-                urlgrabber.grabber.reset_curl_obj()
                 break
 
         self.doRepoSetup(anaconda)
-- 
1.7.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux