Rest API Enhancements

Rest API Enhancements:
1. Add the public folder for holding static files (HTML+JS);
2. Add support for dumping logs with offset;
3. Add support for dumping the final report;

Others:
1. Fix the issue for not dumping complete console logs;
2. Remove .html from the gitignore list

Change-Id: I8a4c0b35c35a818b67d445bcb913d1abfc683301
This commit is contained in:
Yichen Wang 2015-09-03 13:47:24 -07:00
parent 0db7bc9d0e
commit 315f94bdc9
7 changed files with 59 additions and 18 deletions

1
.gitignore vendored
View File

@ -57,7 +57,6 @@ ChangeLog
# KloudBuster
kb*.log
*.json
*.html
*.qcow2
scale/dib/kloudbuster.d/
.vagrant/

View File

@ -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

View File

@ -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:

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<p>Test</p>
</body>
</html>

View File

@ -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

View File

@ -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

View File

@ -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(