diff options
author | Chris Lumens <clumens@redhat.com> | 2007-03-23 19:21:35 +0000 |
---|---|---|
committer | Chris Lumens <clumens@redhat.com> | 2007-03-23 19:21:35 +0000 |
commit | ee3cc052fdca84c5973895a6334c0fb4e2522772 (patch) | |
tree | 5b5e8b2caabd41f241c9ca609772df7f0280a1f2 | |
parent | 21f897e806bb516c8244b61b3bf3c361ed58cacb (diff) | |
download | anaconda-ee3cc052fdca84c5973895a6334c0fb4e2522772.tar.gz anaconda-ee3cc052fdca84c5973895a6334c0fb4e2522772.tar.xz anaconda-ee3cc052fdca84c5973895a6334c0fb4e2522772.zip |
If we've got an IP address, display it (#231934).
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | vnc.py | 68 |
2 files changed, 40 insertions, 33 deletions
@@ -1,3 +1,8 @@ +2007-03-23 Chris Lumens <clumens@redhat.com> + + * vnc.py (startVNCServer): If we've got an IP address, display it + (#231934). + 2007-03-23 David Cantrell <dcantrell@redhat.com> * loader2/loader.h: Change 'ip' structure member to 'ipv4'. @@ -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) |