def redeploy_users(provider, users=[]):
    accounts = get_account_driver(provider)
    tenant_instances_map = accounts.tenant_instances_map(status_list=[
        'deploy_error', 'networking', 'deploying', 'initializing'
    ])
    for tenant, instance_list in tenant_instances_map.iteritems():
        username = tenant.name
        if users and username not in users:
            print "Found affected user:%s and Instances:%s - Skipping because they aren't in the list." % (
                username, instance_list)
            continue
        for instance in instance_list:
            metadata = instance._node.extra.get('metadata', {})
            instance_status = instance.extra.get('status')
            tmp_status = metadata.get('tmp_status', '')
            print "Starting idempotent redeployment for %s - Instance: %s (%s - %s)" % (
                username, instance.id, instance_status, tmp_status)
            ident = Identity.objects.get(provider=provider,
                                         created_by__username=username)
            driver = get_esh_driver(ident)
            try:
                start_task = get_idempotent_deploy_chain(
                    driver.__class__, driver.provider, driver.identity,
                    instance, username)
                print "Starting idempotent redeployment: %s ..." % (
                    start_task),
                start_task.apply_async()
            except Identity.DoesNotExist:
                print "Identity does not exist in this DB. SKIPPED."
                continue
            if DO_NOTHING:
                continue
            print " Sent"
def redeploy_users(provider, users=[]):
    accounts = get_account_driver(provider)
    tenant_instances_map = accounts.tenant_instances_map(status_list=['deploy_error', 'networking','deploying','initializing'])
    for tenant, instance_list in tenant_instances_map.iteritems():
        username = tenant.name
        if users and username not in users:
            print "Found affected user:%s and Instances:%s - Skipping because they aren't in the list." % (username, instance_list)
            continue
        for instance in instance_list:
            metadata = instance._node.extra.get('metadata',{})
            instance_status = instance.extra.get('status')
            tmp_status = metadata.get('tmp_status','')
            print "Starting idempotent redeployment for %s - Instance: %s (%s - %s)" % (username, instance.id, instance_status, tmp_status)
            ident = Identity.objects.get(provider=provider, created_by__username=username)
            driver = get_esh_driver(ident)
            try:
                start_task = get_idempotent_deploy_chain(driver.__class__, driver.provider, driver.identity, instance, username)
                print "Starting idempotent redeployment: %s ..." % (start_task),
                start_task.apply_async()
            except Identity.DoesNotExist:
                print "Identity does not exist in this DB. SKIPPED."
                continue
            if DO_NOTHING:
                continue
            print " Sent"
Example #3
0
def redeploy_instance(esh_driver, esh_instance, username, force_redeploy=False):
    """
    EXPERIMENTAL.

    Starts redeployment of an instance using the tmp_status metadata.

    NOTE: Not used by API. See redeploy_init.
    """
    from service.tasks.driver import get_idempotent_deploy_chain
    if force_redeploy or esh_instance.extra.get('metadata').get('tmp_status',None) == "":
        esh_instance.extra['metadata']['tmp_status'] = "initializing"
    deploy_chain = get_idempotent_deploy_chain(
        esh_driver.__class__, esh_driver.provider, esh_driver.identity,
        esh_instance, username)
    return deploy_chain.apply_async()