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
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
Beispiel #3
0
def uploadToWebServer(remote_server, remote_path, package, remote_port=22):
    """
    Upload the .spec file, and the srpm to a webserver

    :type remote_server: str
    :param remote_server: The remote server to connect to

    :type remote_path: str
    :param remote_path: root path to push the files into

    :type package: str
    :param package: The package name, used to get the spec, and srpm

    :type remote_port: int
    :param remote_port: port of the remote server
    """

    spec_path = getSpecPath(package)
    srpm_name = getSRPMForPackage(package)
    srpm_path = os.path.expanduser("~/rpmbuild/SRPMS/{0}".format(srpm_name))
    remote = ssh.bake(remote_server, "-p {0}".format(remote_port))
    remote.mkdir("-p", os.path.join(remote_path, package))
    scp = scp.bake("-P {0}".format(remote_port))

    scp_lambda = lambda f: scp(f,
            "{0}:{1}".format(
                remote_server,
                os.path.join(
                    remote_path,
                    package
                )
            )
    )
    map(scp_lambda, (spec_path, srpm_path))
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