def resize_and_redeploy(esh_driver, esh_instance, core_identity_id): """ Use this function to kick off the async task when you ONLY want to deploy (No add fixed, No add floating) """ from service.tasks.driver import deploy_init_to, deploy_script from service.tasks.driver import wait_for, complete_resize from service.deploy import deploy_test touch_script = deploy_test() core_identity = CoreIdentity.objects.get(id=core_identity_id) task_one = wait_for.s(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, "verify_resize") task_two = deploy_script.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, touch_script) task_three = complete_resize.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, core_identity.provider.id, core_identity.id, core_identity.created_by) task_four = deploy_init_to.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, redeploy=True) #Link em all together! task_one.link(task_two) task_two.link(task_three) task_three.link(task_four) return task_one
def restore_ip_chain(esh_driver, esh_instance, redeploy=False): """ Returns: a task, chained together task chain: wait_for("active") --> AddFixed --> AddFloating --> reDeploy start with: task.apply_async() """ from service.tasks.driver import \ wait_for, add_fixed_ip, add_floating_ip, deploy_init_to init_task = wait_for.s( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, ["active",], no_tasks=True) #Step 1: Add fixed fixed_ip_task = add_fixed_ip.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id) init_task.link(fixed_ip_task) #Add float and re-deploy OR just add floating IP... if redeploy: deploy_task = deploy_init_to.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, redeploy=True) fixed_ip_task.link(deploy_task) else: logger.info("Skip deployment, Add floating IP only") floating_ip_task = add_floating_ip.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id) fixed_ip_task.link(floating_ip_task) return init_task
def resize_and_redeploy(esh_driver, esh_instance, core_identity_id): """ Use this function to kick off the async task when you ONLY want to deploy (No add fixed, No add floating) """ from service.tasks.driver import deploy_init_to, deploy_script from service.tasks.driver import wait_for, complete_resize from service.deploy import deploy_test touch_script = deploy_test() core_identity = CoreIdentity.objects.get(id=core_identity_id) task_one = wait_for.s( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, "verify_resize") task_two = deploy_script.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, touch_script) task_three = complete_resize.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, core_identity.provider.id, core_identity.id, core_identity.created_by) task_four = deploy_init_to.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, redeploy=True) #Link em all together! task_one.link(task_two) task_two.link(task_three) task_three.link(task_four) return task_one
def restore_ip_chain(esh_driver, esh_instance, redeploy=False, core_identity_uuid=None): """ Returns: a task, chained together task chain: wait_for("active") --> AddFixed --> AddFloating --> reDeploy start with: task.apply_async() """ from service.tasks.driver import \ wait_for_instance, add_fixed_ip, add_floating_ip, deploy_init_to init_task = wait_for_instance.s( esh_instance.id, esh_driver.__class__, esh_driver.provider, esh_driver.identity, "active", #TODO: DELETEME below. no_tasks=True) #Step 1: Add fixed fixed_ip_task = add_fixed_ip.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, core_identity_uuid) init_task.link(fixed_ip_task) #Add float and re-deploy OR just add floating IP... if redeploy: deploy_task = deploy_init_to.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, redeploy=True) fixed_ip_task.link(deploy_task) else: logger.info("Skip deployment, Add floating IP only") floating_ip_task = add_floating_ip.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id) fixed_ip_task.link(floating_ip_task) return init_task
def _repair_instance_networking( esh_driver, esh_instance, provider_uuid, identity_uuid): from service.tasks.driver import \ add_floating_ip, wait_for_instance, \ deploy_init_to, deploy_failed, update_metadata logger.info("Instance %s needs to create and attach port instead" % esh_instance.id) core_identity = CoreIdentity.objects.get(uuid=identity_uuid) provider = Provider.objects.get(uuid=provider_uuid) logger.info("Attaching interface manually, Instance %s" % esh_instance.id) attached_intf = _create_and_attach_port(provider, esh_driver, esh_instance, core_identity) logger.info("Attached Interface: %s" % attached_intf) logger.info("Adding floating IP manually, Instance %s" % esh_instance.id) add_floating_ip(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id) logger.info("Instance %s needs to hard reboot instead of resume" % esh_instance.id) esh_driver.reboot_instance(esh_instance, 'HARD') # Custom task-chain.. Wait for active then redeploy scripts #(Adding IP is done).. Then remove metadata init_task = wait_for_instance.s( esh_instance.id, esh_driver.__class__, esh_driver.provider, esh_driver.identity, "active") deploy_task = deploy_init_to.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, redeploy=True) deploy_task.link_error( deploy_failed.s(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id)) final_update = esh_instance.extra['metadata'] final_update.pop('tmp_status', None) final_update.pop('iplant_suspend_fix', None) remove_status_task = update_metadata.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, final_update, replace_metadata=True) deploy_task.link(remove_status_task) # Attempt to redeploy after the restart.. init_task.link(deploy_task) init_task.apply_async() return
def _repair_instance_networking(esh_driver, esh_instance, provider_uuid, identity_uuid): from service.tasks.driver import \ add_floating_ip, wait_for_instance, \ deploy_init_to, deploy_failed, update_metadata logger.info("Instance %s needs to create and attach port instead" % esh_instance.id) core_identity = CoreIdentity.objects.get(uuid=identity_uuid) provider = Provider.objects.get(uuid=provider_uuid) logger.info("Attaching interface manually, Instance %s" % esh_instance.id) attached_intf = _create_and_attach_port(provider, esh_driver, esh_instance, core_identity) logger.info("Attached Interface: %s" % attached_intf) logger.info("Adding floating IP manually, Instance %s" % esh_instance.id) add_floating_ip(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id) logger.info("Instance %s needs to hard reboot instead of resume" % esh_instance.id) esh_driver.reboot_instance(esh_instance,'HARD') #Custom task-chain.. Wait for active then redeploy scripts #(Adding IP is done).. Then remove metadata init_task = wait_for_instance.s( esh_instance.id, esh_driver.__class__, esh_driver.provider, esh_driver.identity, "active") deploy_task = deploy_init_to.si(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, redeploy=True) deploy_task.link_error( deploy_failed.s(esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id)) final_update = esh_instance.extra['metadata'] final_update.pop('tmp_status') final_update.pop('iplant_suspend_fix') remove_status_task = update_metadata.si( esh_driver.__class__, esh_driver.provider, esh_driver.identity, esh_instance.id, final_update, replace_metadata=True) deploy_task.link(remove_status_task) #Attempt to redeploy after the restart.. init_task.link(deploy_task) init_task.apply_async() return