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

[PATCH] Don't start anaconda directly on s390x (#811477)



On s390x we want the user to ssh in to the install@ account.  This way
they have a functioning terminal in which to run the curses text install
or jump to the vnc install.  It also gives them a place where pdb will
work if they need to debug the install.

Some of the code here was grabbed from vnc.py to figure out the network
IP and name to prompt the user with.
---
 anaconda |   74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/anaconda b/anaconda
index 4959a87..38d900e 100755
--- a/anaconda
+++ b/anaconda
@@ -592,7 +592,81 @@ def setupDisplay(anaconda, opts):
     anaconda.initInterface()
     anaconda.instClass.configure(anaconda)
 
+def prompt_for_ssh():
+    # Do some work here to get the ip addr / hostname to pass
+    # to the user.  Again can't use updates.
+    import logging
+    from pyanaconda import anaconda_log
+    anaconda_log.init()
+    anaconda_log.logger.setupVirtio()
+
+    log = logging.getLogger("anaconda")
+    stdoutLog = logging.getLogger("anaconda.stdout")
+
+    from pyanaconda import network
+    from pyanaconda import isys
+    import socket
+    import gettext
+    _ = lambda x: gettext.ldgettext("anaconda", x)
+
+    # see if we can sniff out network info
+    netinfo = network.Network()
+
+    devices = netinfo.netdevices
+    active_devs = network.getActiveNetDevs()
+
+    ip = None
+    if active_devs != []:
+        devname = devices[active_devs[0]].iface
+        try:
+            ips = (isys.getIPAddresses(devname, version=4) +
+                   isys.getIPAddresses(devname, version=6))
+        except Exception as e:
+            stdoutLog.warning("Got an exception trying to get the ip addr "
+                        "of %s: %s" % (devname, e))
+        else:
+            if ips and ips[0] not in ("127.0.0.1", "::1"):
+                stdoutLog.debug("IPs (using first) of device %s: %s" % (devname,
+                                                                 ips))
+                ip = ips[0]
+
+    ipstr = ip
+
+    try:
+        hinfo = socket.gethostbyaddr(ipstr)
+    except Exception as e:
+        stdoutLog.debug("Exception caught trying to get host name of %s: %s" %
+                  (ipstr, e))
+        name = network.getDefaultHostname(None)
+    else:
+        if len(hinfo) == 3:
+            name = hinfo[0]
+
+    if ip.find(':') != -1:
+        ipstr = "[%s]" % (ip,)
+
+    if (name is not None) and (not name.startswith('localhost')) and (ipstr is not None):
+        connxinfo = "%s (%s)" % (socket.getfqdn(name=name), ipstr,)
+    elif ipstr is not None:
+        connxinfo = "%s" % (ipstr,)
+    else:
+        connxinfo = None
+
+    if connxinfo:
+        stdoutLog.info(_("Please ssh install %s to begin the install.") % connxinfo)
+        pass
+    else:
+        stdoutLog.info(_("Please ssh install@<host> to continue installation."))
+
+
 if __name__ == "__main__":
+    # see if we're on s390x and if we've got an ssh connection
+    uname = os.uname()
+    if uname[4] == 's390x':
+        if not 'SSH_CONNECTION' in os.environ:
+            prompt_for_ssh()
+            sys.exit(0)
+
     setupPythonPath()
 
     # Allow a file to be loaded as early as possible
-- 
1.7.10.2


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