Beispiel #1
0
    def update_action_log(cls, task, al_instance=None):
        from nailgun.objects import ActionLog

        try:
            if not al_instance:
                al_instance = ActionLog.get_by_kwargs(task_uuid=task.uuid,
                                                      action_name=task.name)
            # this is needed as status for check_networks task is not set to
            # "ready" in case of success (it is left in status "running") so
            # we do it here manually, there is no such issue with "error"
            # status though.
            set_to_ready_cond = (
                task.name == consts.TASK_NAMES.check_networks
                and task.status == consts.TASK_STATUSES.running
            )
            task_status = consts.TASK_STATUSES.ready if set_to_ready_cond \
                else task.status

            if al_instance:
                task_cache = cls.get_task_cache(task)
                update_data = {
                    "end_timestamp": datetime.datetime.utcnow(),
                    "additional_info": {
                        "ended_with_status": task_status,
                        "message": "",
                        "output": cls.sanitize_task_output(task_cache,
                                                           al_instance)
                    }
                }
                ActionLog.update(al_instance, update_data)
        except Exception as e:
            logger.error("update_action_log failed: %s", six.text_type(e))
Beispiel #2
0
    def update_action_log(cls, task, al_instance=None):
        from nailgun.objects import ActionLog

        try:
            if not al_instance:
                al_instance = ActionLog.get_by_kwargs(task_uuid=task.uuid,
                                                      action_name=task.name)
            # this is needed as status for check_networks task is not set to
            # "ready" in case of success (it is left in status "running") so
            # we do it here manually, there is no such issue with "error"
            # status though.
            set_to_ready_cond = (task.name == consts.TASK_NAMES.check_networks
                                 and task.status
                                 == consts.TASK_STATUSES.running)
            task_status = consts.TASK_STATUSES.ready if set_to_ready_cond \
                else task.status

            if al_instance:
                task_cache = cls.get_task_cache(task)
                update_data = {
                    "end_timestamp": datetime.datetime.utcnow(),
                    "additional_info": {
                        "ended_with_status": task_status,
                        "message": "",
                        "output":
                        cls.sanitize_task_output(task_cache, al_instance)
                    }
                }
                ActionLog.update(al_instance, update_data)
        except Exception as e:
            logger.error("update_action_log failed: %s", six.text_type(e))
Beispiel #3
0
 def update_action_log(cls, task, al_instance=None):
     try:
         if not al_instance:
             al_instance = ActionLog.get_by_task_uuid(task.uuid)
         if al_instance:
             update_data = {
                 "end_timestamp": datetime.datetime.utcnow(),
                 "additional_info": {
                     "ended_with_status": task.status,
                     "message": "",
                     "output":
                     cls.sanitize_task_output(task.cache, al_instance)
                 }
             }
             ActionLog.update(al_instance, update_data)
     except Exception as e:
         logger.error("update_action_log failed: %s", six.text_type(e))
Beispiel #4
0
 def update_action_log(cls, task, al_instance=None):
     try:
         if not al_instance:
             al_instance = ActionLog.get_by_task_uuid(task.uuid)
         if al_instance:
             update_data = {
                 "end_timestamp": datetime.datetime.utcnow(),
                 "additional_info": {
                     "ended_with_status": task.status,
                     "message": task.message,
                     "output": cls.sanitize_task_output(task.cache,
                                                        al_instance)
                 }
             }
             ActionLog.update(al_instance, update_data)
     except Exception as e:
         logger.error("update_action_log failed: %s", six.text_type(e))
Beispiel #5
0
    def create_action_log(cls, task):
        from nailgun.objects import ActionLog

        try:
            create_kwargs = cls.prepare_action_log_kwargs(task)
            return ActionLog.create(create_kwargs)
        except Exception as e:
            logger.error("create_action_log failed: %s", six.text_type(e))
Beispiel #6
0
    def create_action_log(cls, task):
        """Creates action log
        :param task: SqlAlchemy task object
        :return: SqlAlchemy action_log object
        """
        from nailgun.objects import ActionLog

        try:
            create_kwargs = cls.prepare_action_log_kwargs(task)
            return ActionLog.create(create_kwargs)
        except Exception as e:
            logger.error("create_action_log failed: %s", six.text_type(e))
Beispiel #7
0
    def create_action_log(cls, task):
        """Creates action log
        :param task: SqlAlchemy task object
        :return: SqlAlchemy action_log object
        """
        from nailgun.objects import ActionLog

        try:
            create_kwargs = cls.prepare_action_log_kwargs(task)
            return ActionLog.create(create_kwargs)
        except Exception as e:
            logger.error("create_action_log failed: %s", six.text_type(e))
Beispiel #8
0
 def create_action_log(cls, task):
     try:
         create_kwargs = cls.prepare_action_log_kwargs(task)
         return ActionLog.create(create_kwargs)
     except Exception as e:
         logger.error("create_action_log failed: %s", six.text_type(e))