Пример #1
0
def reboot(miner: Miner, login):
    """ reboot the miner through ftp """
    connection = Ssh(miner.ipaddress, login.username, login.password, port=getportfromminer(miner))
    connection.open_shell()
    response = connection.exec_command('/sbin/reboot')
    print_connection_data(connection)
    connection.close_connection()
    return response
Пример #2
0
def restartminer(miner: Miner, login):
    '''restart miner through ssh'''
    connection = Ssh(miner.ipaddress, login.username, login.password, port=getportfromminer(miner))
    connection.open_shell()
    connection.send_shell('/etc/init.d/{0}.sh restart'.format(getminerfilename(miner)))
    time.sleep(15)
    print_connection_data(connection)
    connection.close_connection()
Пример #3
0
def sendcommands_and_restart(miner: Miner, login, commands):
    connection = Ssh(miner.ipaddress, login.username, login.password, port=getportfromminer(miner))
    connection.open_shell()
    for cmd in commands:
        connection.send_shell(cmd)
    time.sleep(5)
    print_connection_data(connection)
    connection.close_connection()
    restartminer(miner, login)
Пример #4
0
def getminerconfig(miner: Miner, login):
    '''ger the miner config file'''
    connection = Ssh(miner.ipaddress,
                     login.username,
                     login.password,
                     port=getportfromminer(miner))
    config = connection.exec_command('cat /config/{0}.conf'.format(
        getminerfilename(miner)))
    connection.close_connection()
    return config
Пример #5
0
def changesshpassword(miner: Miner, oldlogin, newlogin):
    """ change the factory ssh password """
    if newlogin.username != oldlogin.username:
        print("changesshpassword: currently username change is not supported. only change password")
        return
    connection = Ssh(miner.ipaddress, oldlogin.username, oldlogin.password, port=getportfromminer(miner))
    connection.open_shell()
    connection.send_shell('echo "{0}:{1}" | chpasswd'.format(newlogin.username, newlogin.password))
    time.sleep(5)
    print_connection_data(connection)
    connection.close_connection()
Пример #6
0
def miner_shell_command(miner: Miner, login, command, timetorun):
    '''send the command stop/restart to miner shell command'''
    connection = Ssh(miner.ipaddress,
                     login.username,
                     login.password,
                     port=getportfromminer(miner))
    connection.open_shell()
    connection.send_shell('/etc/init.d/{0}.sh {1}'.format(
        getminerfilename(miner), command))
    time.sleep(timetorun)
    print_connection_data(connection)
    connection.close_connection()
Пример #7
0
def shutdown(miner: Miner, login):
    """ shutdown the miner through ftp
    Warning! this will not turn off the power to the machine!
    It will only shut down the operating system. Machine will still be consuming power if power supply
    does not have on/off switch. You will have to manually restart the machine.
    """
    connection = Ssh(miner.ipaddress, login.username, login.password, port=getportfromminer(miner))
    connection.open_shell()
    connection.send_shell('/sbin/poweroff')
    time.sleep(5)
    print_connection_data(connection)
    connection.close_connection()