Esempio n. 1
0
File: job.py Progetto: vicgud/pacbot
 def post_terraform_destroy(self):
     deregister_task_definition(
         Settings.AWS_ACCESS_KEY,
         Settings.AWS_SECRET_KEY,
         Settings.AWS_REGION,
         self.get_input_attr('name')
     )
Esempio n. 2
0
def deregister_ecs_task_definition_of_batch_job(task_definition_name):
    ecs.deregister_task_definition(
        Settings.AWS_ACCESS_KEY,
        Settings.AWS_SECRET_KEY,
        Settings.AWS_REGION,
        task_definition_name
    )
Esempio n. 3
0
    def inactivate_required_services_for_redeploy(self, resources_to_process,
                                                  dry_run):
        """
        Before redeploy get started or on redeploy happens stop the tasks and deregister task definition

        Args:
            resources_to_process (list): List of resources to be created/updated
            only_tasks (boolean): This flasg decides whther to deregister task definition or not
        """
        if dry_run:
            return

        for resource in resources_to_process:
            if self.terraform_thread.isAlive():
                resource_base_classes = inspect.getmro(resource.__class__)

                if ECSTaskDefinitionResource in resource_base_classes:
                    try:
                        deregister_task_definition(
                            Settings.AWS_ACCESS_KEY,
                            Settings.AWS_SECRET_KEY,
                            Settings.AWS_REGION,
                            resource.get_input_attr('family'),
                        )
                    except:
                        pass
                elif ECSClusterResource in resource_base_classes:
                    cluster_name = resource.get_input_attr('name')
            else:
                return

        for i in range(3):
            if self.terraform_thread.isAlive():
                try:
                    stop_all_tasks_in_a_cluster(cluster_name,
                                                Settings.AWS_ACCESS_KEY,
                                                Settings.AWS_SECRET_KEY,
                                                Settings.AWS_REGION)
                except:
                    pass
                time.sleep(20)
            else:
                return
Esempio n. 4
0
 def post_terraform_destroy(self):
     deregister_task_definition(self.get_input_attr('name'),
                                Settings.AWS_AUTH_CRED)
Esempio n. 5
0
def deregister_ecs_task_definition_of_batch_job(task_definition_name):
    ecs.deregister_task_definition(
        task_definition_name,
        Settings.AWS_AUTH_CRED,
    )