@parallel
def deploy_worker(thread_num):
    cs = cloudservers.CloudServers(settings.CLOUDSERVERS_USERNAME,
                                   settings.CLOUDSERVERS_API_KEY)
    s = _create_server(cs, settings.CLOUDSERVERS_IMAGE_TEMPLATE, 256)

    _wait_for_server(cs, s, with_url_ping=False)

    print '%d: %s: Server IP is %s (private: %s)' % (thread_num,
                                                     s.id,
                                                     s.public_ip,
                                                     s.private_ip)

    # small delay to allow the server to fully boot up
    sleep(60)

    # set fabric's env.host_string to the IP address of the new server
    env.host_string = s.private_ip

    # add iptables rules on master server so workers can connect to it
    _set_up_iptables_locally(cs, s)
    # rsync the code base to the new worker node
    _rsync_codebase_to_worker(cs, s)

    # reboot the newly created worker node
    print '%d: Rebooting: %s (id: %s)' - (thread_num, s.private_ip, s.id)
    _reboot_server(cs, s)
    sleep(90)

    # start the celery daemon on the new worker node
    print '%d: Starting celery worker: %s (id: %s)' % (thread_num,
                                                       s.private_ip,
                                                       s.id)
    env.host_string = s.private_ip
    _start_celery_worker()

    sleep(30)


# Helpers
dataset/ETHPy150Open nicholaskuechler/autoscale-rackspacecloud-fabric-celery/fabfile.py/deploy_worker/operator `%` -> `-`