Change nfvbench git checkout to stable/fraser in Dockerfile
[nfvbench.git] / nfvbench / nfvbenchd.py
index 4772700..fa781af 100644 (file)
@@ -16,7 +16,6 @@
 
 import json
 import Queue
-import traceback
 import uuid
 
 from flask import Flask
@@ -227,7 +226,7 @@ class WebSocketIoServer(object):
             # print 'main thread waiting for requests...'
             config = Ctx.dequeue()
             # print 'main thread processing request...'
-            print config
+            print config
             try:
                 # remove unfilled values as we do not want them to override default values with None
                 config = {k: v for k, v in config.items() if v is not None}
@@ -236,18 +235,23 @@ class WebSocketIoServer(object):
                         self.fluent_logger.start_new_run()
                     results = self.nfvbench_runner.run(config, config)
             except Exception as exc:
-                print 'NFVbench runner exception:'
-                traceback.print_exc()
                 results = result_json(STATUS_ERROR, str(exc))
-                LOG.exception()
+                LOG.exception('NFVbench runner exception:')
 
             if Ctx.request_from_socketio:
                 socketio.emit('run_end', results)
             else:
                 # this might overwrite a previously unfetched result
                 Ctx.set_result(results)
-            summary = NFVBenchSummarizer(results['result'], self.fluent_logger)
-            LOG.info(str(summary))
+            try:
+                summary = NFVBenchSummarizer(results['result'], self.fluent_logger)
+                LOG.info(str(summary))
+            except KeyError:
+                # in case of error, 'result' might be missing
+                if 'error_message' in results:
+                    LOG.error(results['error_message'])
+                else:
+                    LOG.error('REST request completed without results or error message')
             Ctx.release()
             if self.fluent_logger:
                 self.fluent_logger.send_run_summary(True)