summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKerim Gokarslan <kgokarsl@cisco.com>2017-08-31 15:03:42 -0700
committerKerim Gokarslan <kgokarsl@cisco.com>2017-08-31 15:03:51 -0700
commite47c2b40e71a545ede1c7c4d05387a15ad00fc72 (patch)
treefdc5c834efeac37d1a1c3c65804b5c9d4aa8519e
parent00410ac4f2b167af4d6cd01072c791ac6804ce5a (diff)
NFVBENCH-15 REST server stays busy after invalid run request without body
Change-Id: Ic0a69aaf8ed013b2e43e1fbd9dceb8f66d56f7ff Signed-off-by: Kerim Gokarslan <kgokarsl@cisco.com>
-rw-r--r--nfvbench/nfvbenchd.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/nfvbench/nfvbenchd.py b/nfvbench/nfvbenchd.py
index 4bbd69d..3534950 100644
--- a/nfvbench/nfvbenchd.py
+++ b/nfvbench/nfvbenchd.py
@@ -135,6 +135,7 @@ def setup_flask(root_path):
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'
@@ -166,12 +167,15 @@ def setup_flask(root_path):
@app.route('/start_run', methods=['POST'])
def start_run():
config = load_json(request.json)
- if Ctx.is_busy():
- return jsonify(busy_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:
- request_id = get_uuid()
- Ctx.enqueue(config, request_id)
- return jsonify(result_json(STATUS_PENDING, pending_msg, request_id))
+ return jsonify(config_is_null_json)
@app.route('/status', defaults={'request_id': None}, methods=['GET'])
@app.route('/status/<request_id>', methods=['GET'])