def shutdown_and_destroy_workers():

    cloudservers = cloudservers.CloudServers(settings.CLOUDSERVERS_USERNAME,
                                             settings.CLOUDSERVERS_API_KEY)
    name = settings.WORKER_PREFIX
    servers = cloudservers.servers.list()

    """ Use Fabric to shut down celery daemon on the workers """
    for s in servers:
        if name in s.name:
            print "Shutting down celery workers on %s - %s" % (s.name,
                                                               s.private_ip)
            subprocess.call("/usr/local/bin/fab \
                            -f /opt/codebase/auto-scale/fabfile.py \
                            -H " + s.private_ip + " stop_celery_worker",
                            shell=True)

    # Sleep for 600 seconds
    # Allows time for all celery workers to finish processing their tasks
    sleep(600)

    """ Delete the servers from Rackspace Cloud """
    i = 0
    for s in servers:
        if name in s.name:
            print "DELETING server: %-20s" % (s.name)
            s.delete()
            i += 1

    """ Restart networking to clear iptables policies """
    if i > 0:
        print "Restarting networking to clear iptables policies"
        subprocess.call(["/etc/init.d/networking", "restart"])
    else:
        print "No workers found or deleted. Not restarting networking."

    """ Delete the temporary file """
    try:
        os.remove(settings.AUTOSCALE_TMP_FILE)
    except:
        print "File %s does not exist." % (settings.AUTOSCALE_TMP_FILE)

    return True
Ping the master to check if it is still alive. Code using this method should treat the return value as a
dataset/ETHPy150Open nicholaskuechler/autoscale-rackspacecloud-fabric-celery/auto-scale.py/shutdown_and_destroy_workers--crossover with--dataset/ETHPy150Open box/ClusterRunner/app/slave/cluster_slave.py/ClusterSlave._is_master_responsive