示例#1
0
文件: tasks.py 项目: EzanLTD/gunnery
    def _output_callback(self, output):
        """ Handle output of command

        Remove bash colors and trigger live log event
        """
        output = output.decode("utf8").encode("utf8")
        output = re.sub(r"\x1b\[(\d;)?\d?\dm", "".encode("utf8"), output)
        self.ecs.output += output
        ExecutionLiveLog.add(self.execution_id, 'command_output', command_server_id=self.ecs.id, output=output)
示例#2
0
文件: tasks.py 项目: EzanLTD/gunnery
 def finalize(self, execution, execution_id):
     """ Trigger event, and save live log
     """
     department_id = execution.environment.application.department.id
     EventDispatcher.trigger(ExecutionFinish(department_id, execution=execution))
     ExecutionLiveLog.add(execution_id, 'execution_completed',
                          status=execution.status,
                          time_end=execution.time_end,
                          time=execution.time)
示例#3
0
 def setup(self, execution_command_server_id):
     self.ecs = ExecutionCommandServer.objects.get(pk=execution_command_server_id)
     if self.ecs.execution_command.execution.status == Execution.ABORTED:
         return
     self.ecs.celery_task_id = self.request.id
     self.ecs.save_start()
     execution = self.ecs.execution_command.execution
     self.environment_id = execution.environment.id
     self.execution_id = execution.id
     ExecutionLiveLog.add(self.execution_id, 'command_started', command_server_id=self.ecs.id)
示例#4
0
 def finalize(self, execution, execution_id):
     """ Trigger event, and save live log
     """
     department_id = execution.environment.application.department.id
     EventDispatcher.trigger(
         ExecutionFinish(department_id, execution=execution))
     ExecutionLiveLog.add(execution_id,
                          'execution_completed',
                          status=execution.status,
                          time_end=execution.time_end,
                          time=execution.time)
示例#5
0
    def _output_callback(self, output):
        """ Handle output of command

        Remove bash colors and trigger live log event
        """
        output = output.decode("utf8").encode("utf8")
        output = re.sub(r"\x1b\[(\d;)?\d?\dm", "".encode("utf8"), output)
        self.ecs.output += output
        ExecutionLiveLog.add(self.execution_id,
                             'command_output',
                             command_server_id=self.ecs.id,
                             output=output)
示例#6
0
 def setup(self, execution_command_server_id):
     self.ecs = ExecutionCommandServer.objects.get(
         pk=execution_command_server_id)
     if self.ecs.execution_command.execution.status == Execution.ABORTED:
         return
     self.ecs.celery_task_id = self.request.id
     self.ecs.save_start()
     execution = self.ecs.execution_command.execution
     self.environment_id = execution.environment.id
     self.execution_id = execution.id
     ExecutionLiveLog.add(self.execution_id,
                          'command_started',
                          command_server_id=self.ecs.id)
示例#7
0
文件: tasks.py 项目: EzanLTD/gunnery
    def finalize(self):
        """ Set command status and trigger live log event
        """
        if self.ecs.return_code == 0:
            self.ecs.status = Execution.SUCCESS
        else:
            self.ecs.status = Execution.FAILED
        self.ecs.save_end()

        ExecutionLiveLog.add(self.execution_id, 'command_completed',
                             command_server_id=self.ecs.id,
                             return_code=self.ecs.return_code,
                             status=self.ecs.status,
                             time=self.ecs.time)
示例#8
0
    def finalize(self):
        if self.ecs.return_code == 0:
            self.ecs.status = Execution.SUCCESS
        else:
            self.ecs.status = Execution.FAILED
        self.ecs.save_end()

        ExecutionLiveLog.add(self.execution_id, 'command_completed',
                             command_server_id=self.ecs.id,
                             return_code=self.ecs.return_code,
                             status=self.ecs.status,
                             time=self.ecs.time)

        if self.ecs.status == Execution.FAILED:
            raise Exception('command exit code != 0')
示例#9
0
    def finalize(self):
        """ Set command status and trigger live log event
        """
        if self.ecs.return_code == 0:
            self.ecs.status = Execution.SUCCESS
        else:
            self.ecs.status = Execution.FAILED
        self.ecs.save_end()

        ExecutionLiveLog.add(self.execution_id,
                             'command_completed',
                             command_server_id=self.ecs.id,
                             return_code=self.ecs.return_code,
                             status=self.ecs.status,
                             time=self.ecs.time)
示例#10
0
    def finalize(self):
        if self.ecs.return_code == 0:
            self.ecs.status = Execution.SUCCESS
        else:
            self.ecs.status = Execution.FAILED
        self.ecs.save_end()

        ExecutionLiveLog.add(self.execution_id,
                             'command_completed',
                             command_server_id=self.ecs.id,
                             return_code=self.ecs.return_code,
                             status=self.ecs.status,
                             time=self.ecs.time)

        if self.ecs.status == Execution.FAILED:
            raise Exception('command exit code != 0')
示例#11
0
文件: tasks.py 项目: EzanLTD/gunnery
    def run(self, execution_id):
        execution = self._get_execution(execution_id)
        if execution.status == Execution.ABORTED:
            return
        execution.celery_task_id = self.request.id
        execution.save_start()

        ExecutionLiveLog.add(execution_id, 'execution_started', status=execution.status, time_start=execution.time_start)

        chord_chain = []
        for command in execution.commands.all():
            tasks = [CommandTask().si(execution_command_server_id=server.id) for server in command.servers.all()]
            if len(tasks):
                chord_chain.append(chord(tasks, _dummy_callback.s()))
        chord_chain.append(ExecutionTaskFinish().si(execution_id))
        chain(chord_chain)()
示例#12
0
 def run(self, execution_id):
     execution = self._get_execution(execution_id)
     if execution.status == Execution.ABORTED:
         return
     failed = False
     for command in execution.commands.all():
         for server in command.servers.all():
             if server.status in [None, server.FAILED]:
                 failed = True
     if failed:
         execution.status = execution.FAILED
     else:
         execution.status = execution.SUCCESS
     execution.save_end()
     ExecutionLiveLog.add(execution_id, 'execution_completed',
                          status=execution.status,
                          time_end=execution.time_end,
                          time=execution.time)
示例#13
0
 def run(self, execution_id):
     execution = self._get_execution(execution_id)
     if execution.status == Execution.ABORTED:
         return
     failed = False
     for command in execution.commands.all():
         for server in command.servers.all():
             if server.status in [None, server.FAILED]:
                 failed = True
     if failed:
         execution.status = execution.FAILED
     else:
         execution.status = execution.SUCCESS
     execution.save_end()
     ExecutionLiveLog.add(execution_id,
                          'execution_completed',
                          status=execution.status,
                          time_end=execution.time_end,
                          time=execution.time)
示例#14
0
    def run(self, execution_id):
        execution = self._get_execution(execution_id)

        if execution.status != Execution.ABORTED:
            failed = False
            for command in execution.commands.all():
                for server in command.servers.all():
                    if server.status in [None, server.FAILED]:
                        failed = True
            if failed:
                execution.status = execution.FAILED
            else:
                execution.status = execution.SUCCESS
            execution.save_end()

        department_id = execution.environment.application.department.id
        EventDispatcher.trigger(ExecutionFinish(department_id, execution=execution))
        ExecutionLiveLog.add(execution_id, 'execution_completed',
                             status=execution.status,
                             time_end=execution.time_end,
                             time=execution.time)
示例#15
0
    def run(self, execution_id):
        execution = self._get_execution(execution_id)
        if execution.status == Execution.ABORTED:
            return
        execution.celery_task_id = self.request.id
        execution.save_start()

        ExecutionLiveLog.add(execution_id,
                             'execution_started',
                             status=execution.status,
                             time_start=execution.time_start)

        chord_chain = []
        for command in execution.commands.all():
            tasks = [
                CommandTask().si(execution_command_server_id=server.id)
                for server in command.servers.all()
            ]
            if len(tasks):
                chord_chain.append(chord(tasks, _dummy_callback.s()))
        chord_chain.append(ExecutionTaskFinish().si(execution_id))
        chain(chord_chain)()
示例#16
0
 def _output_callback(self, output):
     output = output.decode("utf8").encode("utf8")
     output = re.sub(r"\x1b\[(\d;)?\d?\dm", "".encode("utf8"), output)
     self.ecs.output += output
     ExecutionLiveLog.add(self.execution_id, 'command_output', command_server_id=self.ecs.id, output=output)
示例#17
0
 def _output_callback(self, output):
     self.ecs.output += output
     ExecutionLiveLog.add(self.execution_id, 'command_output', command_server_id=self.ecs.id, output=output)
示例#18
0
 def _output_callback(self, output):
     self.ecs.output += output
     ExecutionLiveLog.add(self.execution_id,
                          'command_output',
                          command_server_id=self.ecs.id,
                          output=output)