コード例 #1
0
def install_package(filename, num):
    ip = get_ip(num)
    print "Uploading pi-workerfarm package to %s" % ip
    scp(filename, "root@%s:/root/" % ip)
    print "Done."

    print "Installing workerfarm package on %s" % ip
    ssh("root@%s" % ip, "dpkg -i /root/%s" % filename)
    print "Done."
    return
コード例 #2
0
def install_prereqs(num):
    ip = get_ip(num)
    print "Uploading workerfarm.sh to %s" % ip
    scp("-o", "StrictHostKeyChecking=no", "./workerfarm.sh", "root@%s:/root/" % ip)
    print "Done."

    print "Running workerfarm.sh on %s" % ip
    ssh("root@%s" % ip, "bash /root/workerfarm.sh")
    print "Done."
    return
コード例 #3
0
def edit_network_config(num, gateway):
    hostname = get_hostname(num)
    ip = get_ip(num)

    fo = open("hostname", "wb")
    fo.write(hostname)
    fo.close()

    print "Uploading new hostname file for %s" % hostname
    scp("-o", "StrictHostKeyChecking=no", "./hostname", "[email protected]:/etc/hostname")
    print "Done."

    interfaces = """# This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth0
    iface eth0 inet static
        address %s
        netmask 255.255.255.0
        network 172.16.1.0
        broadcast 172.16.1.255
        gateway %s
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 8.8.8.8
        dns-search chi.monitorengine.com
    """ % (ip, gateway)

    fo = open("interfaces", "wb")
    fo.write(interfaces)
    fo.close()

    print "Uploading new interfaces file with %s" % ip
    scp("./interfaces", "[email protected]:/etc/network/interfaces")
    print "Done."

    print "Rebooting remote machine..."
    ssh("[email protected]", "reboot")
    print "Done."

    sleep(25)
    return
コード例 #4
0
def restart_supervisor(num):
    ip = get_ip(num)
    ssh("root@%s" % ip, "supervisorctl restart pi-workerfarm")