def run_services(self, request): if request.json_body['action'] == 'start': return json.dumps(rpc.call( 'tasks', 'create_task', service_list=request.json_body['services'])) elif request.json_body['action'] == 'stop': return json.dumps(rpc.call( 'tasks', 'stop_task', task_id=request.json_body['task_id']))
def get_report(self, context, task_id): unit = session.get_session() task_object = unit.query(models.Task).filter_by(id=task_id).first() task_object.status = 'Generating' task_object.action = 'gen_report' with unit.begin(): unit.add(task_object) rpc.call('collector', 'handle_task', task={ 'action': 'gen_report', 'component_name': task_object.component_name, 'id': task_object.id })