def post(self): """Trigger a new run""" run_payload = utils.uni_to_str(json.loads(request.get_data())) run_payload['id'] = str(uuid.uuid4()) LOG.info('Triggering new ansible run %s', run_payload['id']) run = self.manager.create_run(run_payload) return run_model.format_response(run)
def get(self): """Get run list""" LOG.info('Returning all ansible runs') response = [] for run in self.backend_store.list_runs(): response.append(run_model.format_response(run)) return response
def get(self, id): """Get run by id""" run = self.backend_store.get_run(id) if not run: return abort(http_client.NOT_FOUND, message="Run {} doesn't exist".format(id)) return run_model.format_response(run)
def create_run(self, run): run['state'] = objects.State.RUNNING run['api_runner'] = self.column_manager self.backend_store.create_run(run['id'], run) LOG.debug('Triggering a new run with %s', run_model.format_response(run)) t = threading.Thread(target=self._run_playbook, args=[run]) t.start() return run