summaryrefslogtreecommitdiffstats
path: root/vnc.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2006-06-02 14:28:08 +0000
committerChris Lumens <clumens@redhat.com>2006-06-02 14:28:08 +0000
commitf907516622c742a6ddf10a56cc4d17b1f451976b (patch)
treee405e6a17c92b3cb43058640db45bc0e2195c73d /vnc.py
parent08be22b02d26d7480099df0674c300146e324591 (diff)
downloadanaconda-f907516622c742a6ddf10a56cc4d17b1f451976b.tar.gz
anaconda-f907516622c742a6ddf10a56cc4d17b1f451976b.tar.xz
anaconda-f907516622c742a6ddf10a56cc4d17b1f451976b.zip
If we don't have a valid hostname, tell the user to connect to the IP address
instead (#191561). Try really hard to display a valid thing the user can connect to. Also make the logic a little clearer (to me, at least). Now if only VNC installs worked...
Diffstat (limited to 'vnc.py')
-rw-r--r--vnc.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/vnc.py b/vnc.py
index f9b3d2e14..f61619e10 100644
--- a/vnc.py
+++ b/vnc.py
@@ -191,21 +191,31 @@ def startVNCServer(vncpassword="", root='/', vncconnecthost="",
# try to load /tmp/netinfo and see if we can sniff out network info
netinfo = network.Network()
srvname = None
- if netinfo.hostname != "localhost.localdomain":
- srvname = "%s" % (netinfo.hostname,)
+
+ # If we have a real hostname that resolves against configured DNS
+ # servers, use that for the name to connect to.
+ if netinfo.hostname != "localhost.localdomain" and netinfo.lookupHostname() is not None:
+ srvname = netinfo.hostname
else:
+ # Otherwise, look for any configured interface and use its IP
+ # address for the name to connect to.
for dev in netinfo.netdevices.keys():
try:
ip = isys.getIPAddress(dev)
log.info("ip of %s is %s" %(dev, ip))
except Exception, e:
- log.error("Got an exception trying to get the ip addr "
- "of %s: %s" %(dev, e))
- continue
- if ip == '127.0.0.1' or ip is None:
+ log.warning("Got an exception trying to get the ip addr "
+ "of %s: %s" %(dev, e))
continue
- srvname = ip
- break
+
+ if ip != '127.0.0.1' and ip is not None:
+ srvname = ip
+ break
+
+ # If we get here and there's no valid IP address, just use the
+ # hostname and hope for the best (better than displaying nothing)
+ if ip == '127.0.0.1' or ip is None:
+ srvname = netinfo.hostname
if srvname is not None:
connxinfo = "%s:1" % (srvname,)