diff options
author | David Cantrell <dcantrell@redhat.com> | 2008-10-31 16:19:48 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2008-11-03 09:25:11 -1000 |
commit | 532865b09fea4b72bde3ccd4bfbc134b70d8a6f2 (patch) | |
tree | c44ad4b0dbd13d2c6f2773e32b69d8a1cda3acfc /vnc.py | |
parent | 340ea253abedbd0d2c38834afd327bb120b66609 (diff) | |
download | anaconda-532865b09fea4b72bde3ccd4bfbc134b70d8a6f2.tar.gz anaconda-532865b09fea4b72bde3ccd4bfbc134b70d8a6f2.tar.xz anaconda-532865b09fea4b72bde3ccd4bfbc134b70d8a6f2.zip |
Make sure we look up the IP address for the correct device (#469439)
The VNC launch code in vnc.py needed an update to work better with
NetworkManager. When collecting the hostname and IP address, it was
assuming the first device in the netdevices list is our active NIC,
which may or may not be true.
Added getActiveNetDevs() in network.py to ask NetworkManager for a
list of all currently configured interfaces. Return a list of
device names. A list seems a bit pointless, but I'd like to have
this in place now for future improvements where we might need to
handle more than one active NIC during installation. After all,
NM can do that.
The message reported by anaconda once VNC is ready will contain the
FQDN:DISPLAY_NUMBER (IP ADDRESS), if it can. If it can't find your
IP address, it leaves that out. If it can't find your hostname, it
also leaves that out.
Diffstat (limited to 'vnc.py')
-rw-r--r-- | vnc.py | 65 |
1 files changed, 25 insertions, 40 deletions
@@ -56,6 +56,7 @@ class VncServer: self.pw_file = pw_file self.pw_init_file = pw_init_file self.connxinfo = None + self.anaconda = None self.log = logging.getLogger("anaconda.stdout") def recoverVNCPassword(self): @@ -100,52 +101,36 @@ class VncServer: # see if we can sniff out network info netinfo = network.Network() - # Look for the first configured interface and use its IP address for - # the computer to connect to. devices = netinfo.netdevices - list = devices.keys() - list.sort() - dev = devices[list[0]] + active_devs = network.getActiveNetDevs() - try: - self.ip = isys.getIPAddress(dev.get("DEVICE")) - log.info("ip of %s is %s" % (dev.get("DEVICE"), self.ip)) - - if self.ip == "127.0.0.1" or self.ip == "::1": - self.ip = None - except Exception, e: - log.warning("Got an exception trying to get the self.ip addr " - "of %s: %s" % (dev.get("DEVICE"), 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": - if netinfo.lookupHostname() is not None: - self.name = netinfo.hostname - elif self.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) - self.name = netinfo.hostname - - if self.name is not None: - self.connxinfo = "%s:%s" % (self.name, self.display) + if active_devs != []: + dev = devices[active_devs[0]] - if self.ip is not None: try: - tmp = socket.inet_pton(socket.AF_INET6, self.ip) - family = socket.AF_INET6 - except socket.error: - family = socket.AF_INET + self.ip = isys.getIPAddress(dev.get("DEVICE")) + log.info("ip of %s is %s" % (dev.get("DEVICE"), self.ip)) + + if self.ip == "127.0.0.1" or self.ip == "::1": + self.ip = None + except Exception, e: + log.warning("Got an exception trying to get the self.ip addr " + "of %s: %s" % (dev.get("DEVICE"), e)) + else: + self.ip = None - if family == socket.AF_INET6: - ipstr = "[%s]" % self.ip - else: - ipstr = self.ip + self.name = network.getDefaultHostname(self.anaconda) + ipstr = self.ip - if self.connxinfo is None: - self.connxinfo = "%s:%s" % (ipstr, self.display) - else: - self.connxinfo += " (%s)" % ipstr + if 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): + self.connxinfo = "%s:%s (%s)" % (socket.getfqdn(name=self.name), self.display, ipstr,) + elif ipstr is not None: + self.connxinfo = "%s:%s" % (ipstr, self.display,) + else: + self.connxinfo = None # figure out product info if self.name is not None: |