diff --git a/.gitignore b/.gitignore index c992f7a..a608819 100644 --- a/.gitignore +++ b/.gitignore @@ -57,7 +57,6 @@ ChangeLog # KloudBuster kb*.log *.json -*.html *.qcow2 scale/dib/kloudbuster.d/ .vagrant/ diff --git a/kb_server/kb_server/controllers/api_kb.py b/kb_server/kb_server/controllers/api_kb.py index 5b0d4f6..37460b8 100644 --- a/kb_server/kb_server/controllers/api_kb.py +++ b/kb_server/kb_server/controllers/api_kb.py @@ -66,7 +66,7 @@ class KBController(object): return response.text @expose(generic=True) - def log(self, *args): + def log(self, *args, **kwargs): if len(args): session_id = args[0] else: @@ -74,9 +74,18 @@ class KBController(object): response.text = u"Please specify the session_id." return response.text + offset = 0 + if 'offset' in kwargs: + try: + offset = int(kwargs['offset']) + except ValueError: + response.status = 400 + response.text = u"Parameter 'offset' is invalid." + return response.text + if KBSessionManager.has(session_id): kb_session = KBSessionManager.get(session_id) - plog = kb_session.kloudbuster.dump_logs(offset=0)\ + plog = kb_session.kloudbuster.dump_logs(offset=offset)\ if kb_session.kloudbuster else "" return json.dumps(plog) else: @@ -85,7 +94,7 @@ class KBController(object): return response.text @expose(generic=True) - def report(self, *args): + def report(self, *args, **kwargs): if len(args): session_id = args[0] else: @@ -93,10 +102,17 @@ class KBController(object): response.text = u"Please specify the session_id." return response.text + final = False + if 'final' in kwargs: + final = True if kwargs['final'].lower() == 'true' else False + + preport = None if KBSessionManager.has(session_id): kb_session = KBSessionManager.get(session_id) - preport = kb_session.kloudbuster.kb_runner.report\ - if kb_session.kloudbuster and kb_session.kloudbuster.kb_runner else "" + if kb_session.kloudbuster and kb_session.kloudbuster.kb_runner: + preport = kb_session.kloudbuster.final_result\ + if final else kb_session.kloudbuster.kb_runner.report + return json.dumps(preport) else: response.status = 404 diff --git a/kb_server/kloudbuster-swagger.yaml b/kb_server/kloudbuster-swagger.yaml index 7905a92..9d01a2e 100644 --- a/kb_server/kloudbuster-swagger.yaml +++ b/kb_server/kloudbuster-swagger.yaml @@ -169,6 +169,11 @@ paths: in: path description: The session to be queried required: true + - name: offset + type: int + in: query + description: The offset of the log file to read + required: false tags: - kloudbuster responses: @@ -177,14 +182,16 @@ paths: schema: type: string description: The console log of the given session + 400: + description: Parameter is missing or invalid 404: description: The session_id is not found or invalid /kloudbuster/report/{session_id}: get: description: | - Get KloudBuster periodical report for a given session. Only - last report will be returned. + Get the latest KloudBuster periodical report for a given session. + Set final to true to retrieve the final report. parameters: - name: session_id type: string @@ -192,6 +199,11 @@ paths: in: path description: The session to be queried required: true + - name: final + type: boolean + in: query + description: Set to true to retrieve the final report + required: false tags: - kloudbuster responses: diff --git a/kb_server/public/ui/test.html b/kb_server/public/ui/test.html new file mode 100644 index 0000000..c2ddcc1 --- /dev/null +++ b/kb_server/public/ui/test.html @@ -0,0 +1,9 @@ + + + +Test + + +

Test

+ + diff --git a/kloudbuster/cfg.scale.yaml b/kloudbuster/cfg.scale.yaml index 0c0978b..e7153cf 100644 --- a/kloudbuster/cfg.scale.yaml +++ b/kloudbuster/cfg.scale.yaml @@ -21,7 +21,7 @@ keystone_admin_role: "admin" # Cleanup all kloudbuster resources upon exit # If set to False, resources created will not be deleted on exit and the user -# will have to execute the cleanup script later to remove all these resources +# will have to execute the cleanup script later to remove all these resources cleanup_resources: True # VM creation concurrency @@ -84,7 +84,7 @@ server: # Availability zone to use for servers in the server cloud # Leave empty if you prefer to have the Nova scheduler place the server VMs # If you want to pick a particular AZ, put that AZ name (e.g. nova) - # If you want a paticular compute host, put the AZ and compute host names + # If you want a paticular compute host, put the AZ and compute host names # separated by ':' (e.g. nova:tme100) # Note that this is ignored/overriden if you specify a topology file (-t) availability_zone: @@ -119,7 +119,7 @@ client: # HTTP tool specific configs (per VM) # Every HTTP server VM is paired to 1 HTTP traffic generator VM - # KloudBuster will take care of setting up the proper static routes + # KloudBuster will take care of setting up the proper static routes # to allow connectivity between all pairs of VMs. # For example, if 1000 HTTP servers are configured, KloudBuster will # instantiate 1000 HTTP traffic generators and match them 1:1, for a total diff --git a/kloudbuster/cfg.topo.yaml b/kloudbuster/cfg.topo.yaml index bfb9c00..5c6756b 100644 --- a/kloudbuster/cfg.topo.yaml +++ b/kloudbuster/cfg.topo.yaml @@ -3,15 +3,17 @@ # # A typical use of this topology file is to shape traffic in order to maximize # inter-rack L3 traffic. +# # With 2 racks, simply place each rack node name in each group. # With more than 2 racks, separate the racks in 2 groups. # -# When used, the topology file will override any availability zone settings in the -# confguration file. -# - - -# The compute host name must be exactly the same as shown from NOVA: +# Note +# ==== +# +# 1. When used, the topology file will override any availability zone +# settings in the confguration file. +# +# 2. The compute host name must be exactly the same as shown from NOVA: # i.e. "nova hypervisor-list" # Grouping for placing all the server side VMs diff --git a/kloudbuster/log.py b/kloudbuster/log.py index dff57e7..a434706 100644 --- a/kloudbuster/log.py +++ b/kloudbuster/log.py @@ -47,12 +47,15 @@ def setup(product_name, logfile=None): handlers.ColorHandler.LEVEL_COLORS[logging.KBDEBUG] = dbg_color oslogging.setup(CONF, product_name) + # Adding the FileHandler to all known loggers inside KloudBuster if logfile: if os.path.exists(logfile): os.remove(logfile) CONF.log_file = logfile hdlr = logging.FileHandler(logfile) - oslogging.getLogger(product_name).logger.addHandler(hdlr) + for name in oslogging._loggers: + if name: + oslogging.getLogger(name).logger.addHandler(hdlr) if CONF.kb_debug: oslogging.getLogger(