app.root_path = root_path
socketio = SocketIO(app, async_mode='threading')
busy_json = result_json(STATUS_ERROR, 'there is already an NFVbench request running')
- config_is_null_json = result_json(STATUS_ERROR, 'configuration is missing')
not_busy_json = result_json(STATUS_ERROR, 'no pending NFVbench run')
not_found_msg = 'results not found'
pending_msg = 'NFVbench run still pending'
@app.route('/start_run', methods=['POST'])
def start_run():
config = load_json(request.json)
- if config:
- if Ctx.is_busy():
- return jsonify(busy_json)
- else:
- request_id = get_uuid()
- Ctx.enqueue(config, request_id)
- return jsonify(result_json(STATUS_PENDING, pending_msg, request_id))
- else:
- return jsonify(config_is_null_json)
+ if not config:
+ config = {}
+ if Ctx.is_busy():
+ return jsonify(busy_json)
+ request_id = get_uuid()
+ Ctx.enqueue(config, request_id)
+ return jsonify(result_json(STATUS_PENDING, pending_msg, request_id))
@app.route('/status', defaults={'request_id': None}, methods=['GET'])
@app.route('/status/<request_id>', methods=['GET'])
self.nfvbench_runner = runner
setup_flask(http_root)
self.fluent_logger = logger
- self.result_fluent_logger = FluentLogHandler("resultnfvbench",
- fluentd_ip=self.fluent_logger.sender.host,
- fluentd_port=self.fluent_logger.sender.port) \
- if self.fluent_logger else None
+ self.result_fluent_logger = None
+ if self.fluent_logger:
+ self.result_fluent_logger = \
+ FluentLogHandler("resultnfvbench",
+ fluentd_ip=self.fluent_logger.sender.host,
+ fluentd_port=self.fluent_logger.sender.port)
+ self.result_fluent_logger.runlogdate = self.fluent_logger.runlogdate
def run(self, host='127.0.0.1', port=7556):
else:
# this might overwrite a previously unfetched result
Ctx.set_result(results)
+ if self.fluent_logger:
+ self.result_fluent_logger.runlogdate = self.fluent_logger.runlogdate
summary = NFVBenchSummarizer(results['result'], self.result_fluent_logger)
LOG.info(str(summary))
Ctx.release()