[PATCH] Check all network devices to get an IP address

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

 



It also prevents a crash when no IP address is found.

---
 pyanaconda/vnc.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py
index a7ccc76..000c9fc 100644
--- a/pyanaconda/vnc.py
+++ b/pyanaconda/vnc.py
@@ -84,8 +84,8 @@ class VncServer:
         active_devs = network.getActiveNetDevs()

         self.ip = None
-        if active_devs != []:
-            devname = devices[active_devs[0]].iface
+        for dev in active_devs:
+            devname = devices[dev].iface
             try:
                 ips = (isys.getIPAddresses(devname, version=4) +
                        isys.getIPAddresses(devname, version=6))
@@ -97,6 +97,10 @@ class VncServer:
                     log.info("IPs (using first) of device %s: %s" % (devname,
                                                                      ips))
                     self.ip = ips[0]
+                    break
+
+        if not self.ip:
+            self.log.warning("No IP address found. You may not be able to connect to VNC server.")

         ipstr = self.ip

@@ -110,7 +114,7 @@ class VncServer:
             if len(hinfo) == 3:
                 self.name = hinfo[0]

-        if self.ip.find(':') != -1:
+        if self.ip and self.ip.find(':') != -1:
             ipstr = "[%s]" % (self.ip,)

         if (self.name is not None) and (not self.name.startswith('localhost')) and (ipstr is not None):
-- 
1.7.7.6

_______________________________________________
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