示例#1
0
def write_login_details(fp, username, ips):
    sshcommands = "\n"
    for ip in ips:
        sshcommands += "    ssh %s@%s\n" % (username, ip)
    tty_name = os.ttyname(0)[5:]  # strip off the /dev/
    version = get_core_version() or "16"
    if len(ips) == 0:
        fp.write(
            login_details_tmpl_no_ip.format(sshcommands=sshcommands,
                                            tty_name=tty_name,
                                            version=version))
    else:
        first_ip = ips[0]
        fp.write(
            login_details_tmpl.format(sshcommands=sshcommands,
                                      host_key_info=host_key_info(),
                                      tty_name=tty_name,
                                      first_ip=first_ip,
                                      version=version))
示例#2
0
def ssh_help_texts(ips, password):

    texts = [_(SSH_HELP_PROLOGUE), ""]

    if len(ips) > 0:
        if len(ips) > 1:
            texts.append(rewrap(_(SSH_HELP_MULTIPLE_ADDRESSES)))
            texts.append("")
            for ip in ips:
                texts.append(Text("installer@" + str(ip), align='center'))
        else:
            texts.append(_(SSH_HELP_ONE_ADDRESSES).format(ip=str(ips[0])))
        texts.append("")
        texts.append(rewrap(_(SSH_HELP_EPILOGUE).format(password=password)))
        texts.append("")
        texts.append(Text(host_key_info()))
    else:
        texts.append("")
        texts.append(_(SSH_HELP_NO_ADDRESSES))

    return texts