summaryrefslogtreecommitdiffstats
path: root/vnc.py
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2007-03-23 19:21:35 +0000
committerChris Lumens <clumens@redhat.com>2007-03-23 19:21:35 +0000
commitee3cc052fdca84c5973895a6334c0fb4e2522772 (patch)
tree5b5e8b2caabd41f241c9ca609772df7f0280a1f2 /vnc.py
parent21f897e806bb516c8244b61b3bf3c361ed58cacb (diff)
downloadanaconda-ee3cc052fdca84c5973895a6334c0fb4e2522772.tar.gz
anaconda-ee3cc052fdca84c5973895a6334c0fb4e2522772.tar.xz
anaconda-ee3cc052fdca84c5973895a6334c0fb4e2522772.zip
If we've got an IP address, display it (#231934).
Diffstat (limited to 'vnc.py')
-rw-r--r--vnc.py68
1 files changed, 35 insertions, 33 deletions
diff --git a/vnc.py b/vnc.py
index 0f2f41648..2d7631c3c 100644
--- a/vnc.py
+++ b/vnc.py
@@ -1,7 +1,7 @@
#
# vnc.py: VNC related installer functionality
#
-# Copyright 2004 Red Hat, Inc.
+# Copyright 2004,2007 Red Hat, Inc.
#
# Jeremy Katz <katzj@redhat.com>
#
@@ -22,6 +22,7 @@ import network
import isys
import product
import iutil
+import network
import logging
log = logging.getLogger("anaconda")
@@ -189,42 +190,43 @@ def startVNCServer(vncpassword="", root='/', vncconnecthost="",
# figure out host info
connxinfo = None
srvname = None
- try:
- import network
+ ip = None
- # try to load /tmp/netinfo and see if we can sniff out network info
- netinfo = network.Network()
- srvname = None
+ # try to load /tmp/netinfo and see if we can sniff out network info
+ netinfo = network.Network()
- # 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 the first configured interface and use its
- # IP address for the name to connect to.
- dev = netinfo.getFirstDeviceName()
-
- try:
- ip = isys.getIPAddress(dev)
- log.info("ip of %s is %s" % (dev, ip))
- except Exception, e:
- log.warning("Got an exception trying to get the ip addr "
- "of %s: %s" % (dev, e))
-
- if ip != "127.0.0.1" and ip is not None:
- srvname = ip
- else:
- # If we get here and there's no valid IP address, just use the
- # hostname and hope for the best (better than displaying nothing)
- srvname = netinfo.hostname
+ # Look for the first configured interface and use its IP address for
+ # the computer to connect to.
+ dev = netinfo.getFirstDeviceName()
+
+ try:
+ ip = isys.getIPAddress(dev)
+ log.info("ip of %s is %s" % (dev, ip))
+
+ if ip == "127.0.0.1":
+ ip = None
+ except Exception, e:
+ log.warning("Got an exception trying to get the ip addr "
+ "of %s: %s" % (dev, e))
+
+ # 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
+ elif ip is None:
+ # If we get here and there's no valid IP address, just use the
+ # hostname and hope for the best (better than displaying nothing)
+ srvname = netinfo.hostname
- if srvname is not None:
- connxinfo = "%s:1" % (srvname,)
+ if srvname is not None:
+ connxinfo = "%s:1" % srvname
+
+ if ip is not None:
+ if connxinfo is not None:
+ connxinfo = "%s:1" % ip
+ else:
+ connxinfo += " (%s)" % ip
- except:
- log.error("Unable to determine VNC server network info")
-
# figure out product info
if srvname is not None:
desktopname = _("%s %s installation on host %s") % (product.productName, product.productVersion, srvname)