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)
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)
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)
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)
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)
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)
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')
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)()
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)
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)
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)()
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)
def _output_callback(self, output): self.ecs.output += output ExecutionLiveLog.add(self.execution_id, 'command_output', command_server_id=self.ecs.id, output=output)