Ejemplo n.º 1
0
def resume_instance(esh_driver, esh_instance,
                    provider_uuid, identity_uuid,
                    user, restore_ip=True,
                    update_meta=True):
    """
    raise OverQuotaError, OverAllocationError, InvalidCredsError
    """
    from service.tasks.driver import update_metadata, _update_status_log
    _permission_to_act(identity_uuid, "Resume")
    _update_status_log(esh_instance, "Resuming Instance")
    size = _get_size(esh_driver, esh_instance)
    check_quota(user.username, identity_uuid, size, resuming=True)
    #admin_capacity_check(provider_uuid, esh_instance.id)
    if restore_ip:
        restore_network(esh_driver, esh_instance, identity_uuid)
        #restore_instance_port(esh_driver, esh_instance)
        deploy_task = restore_ip_chain(esh_driver, esh_instance, redeploy=True,
                #NOTE: after removing FIXME, This parameter can be removed as well
                core_identity_uuid=identity_uuid)
    #FIXME: These three lines are necessary to repair our last network outage.
    # At some point, we should re-evaluate when it is safe to remove
    needs_fixing = esh_instance.extra['metadata'].get('iplant_suspend_fix')
    if needs_fixing:
        return _repair_instance_networking(esh_driver, esh_instance, provider_uuid, identity_uuid)

    esh_driver.resume_instance(esh_instance)
    if restore_ip:
        deploy_task.apply_async()
Ejemplo n.º 2
0
def offload_instance(esh_driver, esh_instance,
                     provider_uuid, identity_uuid,
                     user, reclaim_ip=True):
    """

    raise OverQuotaError, OverAllocationError, InvalidCredsError
    """
    from service.tasks.driver import _update_status_log
    _permission_to_act(identity_uuid, "Shelve Offload")
    _update_status_log(esh_instance, "Shelve-Offloading Instance")
    if reclaim_ip:
        remove_ips(esh_driver, esh_instance)
    offloaded = esh_driver._connection.ex_shelve_offload_instance(esh_instance)
    if reclaim_ip:
        remove_network(esh_driver, identity_uuid)
    update_status(
        esh_driver,
        esh_instance.id,
        provider_uuid,
        identity_uuid,
        user)
    invalidate_cached_instances(
        identity=CoreIdentity.objects.get(
            uuid=identity_uuid))
    return offloaded
Ejemplo n.º 3
0
def deploy_init_task(driver, instance,
                     username=None, password=None, token=None, redeploy=False,
                     *args, **kwargs):
    from service.tasks.driver import _update_status_log
    _update_status_log(instance, "Launching Instance")
    deploy_init_to.apply_async((driver.__class__,
                                driver.provider,
                                driver.identity,
                                instance.alias,
                                token,
                                redeploy),
                               immutable=True, countdown=20)
Ejemplo n.º 4
0
def deploy_init_task(driver, instance, identity,
                     username=None, password=None, token=None,
                     redeploy=False, deploy=True, *args, **kwargs):
    from service.tasks.driver import _update_status_log
    _update_status_log(instance, "Launching Instance")
    logger.debug("deploy_init_task redeploy = %s" % redeploy)
    return deploy_init_to.apply_async((driver.__class__,
                                driver.provider,
                                driver.identity,
                                instance.alias,
                                identity,
                                username,
                                password,
                                redeploy,
                                deploy),
                               immutable=True)
Ejemplo n.º 5
0
def deploy_init_task(driver, instance, identity,
                     username=None, password=None, token=None,
                     redeploy=False, deploy=True, *args, **kwargs):
    from service.tasks.driver import _update_status_log
    _update_status_log(instance, "Launching Instance")
    logger.debug("deploy_init_task redeploy = %s" % redeploy)
    return deploy_init_to.apply_async((driver.__class__,
                                driver.provider,
                                driver.identity,
                                instance.alias,
                                identity,
                                username,
                                password,
                                redeploy,
                                deploy),
                               immutable=True)
Ejemplo n.º 6
0
def deploy_init_task(driver,
                     instance,
                     identity,
                     username=None,
                     password=None,
                     token=None,
                     redeploy=False,
                     *args,
                     **kwargs):
    from service.tasks.driver import _update_status_log
    _update_status_log(instance, "Launching Instance")
    deploy_init_to.apply_async(
        (driver.__class__, driver.provider, driver.identity, instance.alias,
         token, redeploy),
        immutable=True,
        countdown=20)
Ejemplo n.º 7
0
def resume_instance(esh_driver, esh_instance, provider_id, identity_id, user, restore_ip=True, update_meta=True):
    """

    raise OverQuotaError, OverAllocationError, InvalidCredsError
    """
    from service.tasks.driver import update_metadata, _update_status_log

    _update_status_log(esh_instance, "Resuming Instance")
    size = esh_driver.get_size(esh_instance.size.id)
    check_quota(user.username, identity_id, size, resuming=True)
    # admin_capacity_check(provider_id, esh_instance.id)
    if restore_ip:
        restore_network(esh_driver, esh_instance, identity_id)
        deploy_task = restore_ip_chain(esh_driver, esh_instance, redeploy=True)
    esh_driver.resume_instance(esh_instance)
    if restore_ip:
        deploy_task.apply_async(countdown=10)
Ejemplo n.º 8
0
def resume_instance(esh_driver,
                    esh_instance,
                    provider_id,
                    identity_id,
                    user,
                    restore_ip=True,
                    update_meta=True):
    """

    raise OverQuotaError, OverAllocationError, InvalidCredsError
    """
    from service.tasks.driver import update_metadata, _update_status_log
    _update_status_log(esh_instance, "Resuming Instance")
    size = esh_driver.get_size(esh_instance.size.id)
    check_quota(user.username, identity_id, size, resuming=True)
    #admin_capacity_check(provider_id, esh_instance.id)
    if restore_ip:
        restore_network(esh_driver, esh_instance, identity_id)
        deploy_task = restore_ip_chain(esh_driver,
                                       esh_instance,
                                       redeploy=False)
    esh_driver.resume_instance(esh_instance)
    if restore_ip:
        deploy_task.apply_async(countdown=10)
Ejemplo n.º 9
0
def unshelve_instance(esh_driver, esh_instance,
                    provider_uuid, identity_uuid,
                    user, restore_ip=True,
                    update_meta=True):
    """
    raise OverQuotaError, OverAllocationError, InvalidCredsError
    """
    from service.tasks.driver import _update_status_log
    _permission_to_act(identity_uuid, "Unshelve")
    _update_status_log(esh_instance, "Unshelving Instance")
    size = _get_size(esh_driver, esh_instance)
    check_quota(user.username, identity_uuid, size, resuming=True)
    admin_capacity_check(provider_uuid, esh_instance.id)
    if restore_ip:
        restore_network(esh_driver, esh_instance, identity_uuid)
        #restore_instance_port(esh_driver, esh_instance)
        deploy_task = restore_ip_chain(esh_driver, esh_instance, redeploy=True,
                #NOTE: after removing FIXME, This parameter can be removed as well
                core_identity_uuid=identity_uuid)

    unshelved = esh_driver._connection.ex_unshelve_instance(esh_instance)
    if restore_ip:
        deploy_task.apply_async(countdown=10)
    return unshelved