Ejemplo n.º 1
0
def prompt_for_ssh(options):
    """Prompt the user to ssh to the installation environment on the s390.

    :param options: Anaconda command line/boot options
    :return: True if the prompt is printed, otherwise False
    """
    if not blivet.arch.is_s390():
        return False

    if not conf.target.is_hardware:
        return False

    if 'TMUX' in os.environ:
        return False

    if options.ksfile:
        return False

    if options.vnc:
        return False

    # Do some work here to get the ip addr / hostname to pass
    # to the user.
    import socket

    ip = network.get_first_ip_address()

    if not ip:
        stdout_log.error("No IP addresses found, cannot continue installation.")
        util.ipmi_report(constants.IPMI_ABORTED)
        sys.exit(1)

    ipstr = ip

    try:
        hinfo = socket.gethostbyaddr(ipstr)
    except socket.herror as e:
        stdout_log.debug("Exception caught trying to get host name of %s: %s", ipstr, e)
        name = network.get_hostname()
    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:
        stdout_log.info(_("Please ssh install@%s to begin the install."), connxinfo)
    else:
        stdout_log.info(_("Please ssh install@HOSTNAME to continue installation."))

    return True
Ejemplo n.º 2
0
def prompt_for_ssh():
    """Prompt the user to ssh to the installation environment on the s390."""

    # Do some work here to get the ip addr / hostname to pass
    # to the user.
    import socket

    ip = network.get_first_ip_address()

    if not ip:
        stdout_log.error(
            "No IP addresses found, cannot continue installation.")
        util.ipmi_report(constants.IPMI_ABORTED)
        sys.exit(1)

    ipstr = ip

    try:
        hinfo = socket.gethostbyaddr(ipstr)
    except socket.herror as e:
        stdout_log.debug("Exception caught trying to get host name of %s: %s",
                         ipstr, e)
        name = network.get_hostname()
    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:
        stdout_log.info(_("Please ssh install@%s to begin the install."),
                        connxinfo)
    else:
        stdout_log.info(
            _("Please ssh install@HOSTNAME to continue installation."))