Adding verbose option to the cloudpulse server

Change-Id: I07dde100abaef4803e93c21996dd7bf80f8823c8
This commit is contained in:
Anand Shanmugam
2015-07-09 07:19:37 -07:00
parent 5a2af3f73d
commit cebccb33ef
3 changed files with 30 additions and 24 deletions

View File

@@ -26,7 +26,6 @@ from cloudpulse.api.controllers import link
from cloudpulse.api.controllers.v1 import collection
from cloudpulse.api.controllers.v1 import types
from cloudpulse.api.controllers.v1 import utils as api_utils
from cloudpulse.common import exception
from cloudpulse import objects
@@ -165,29 +164,6 @@ class cpulseController(rest.RestController):
return self._get_tests_collection(marker, limit, sort_key,
sort_dir)
@wsme_pecan.wsexpose(CpulseCollection, types.uuid,
types.uuid, int, wtypes.text, wtypes.text)
def detail(self, test_uuid=None, marker=None, limit=None,
sort_key='id', sort_dir='asc'):
"""Retrieve a list of tests with detail.
:param test_uuid: UUID of a test, to get only tests for that test.
:param marker: pagination marker for large data sets.
:param limit: maximum number of resources to return in a single result.
:param sort_key: column to sort results by. Default: id.
:param sort_dir: direction to sort. "asc" or "desc". Default: asc.
"""
# NOTE(lucasagomes): /detail should only work agaist collections
parent = pecan.request.path.split('/')[:-1][-1]
if parent != "tests":
raise exception.HTTPNotFound
expand = True
resource_url = '/'.join(['tests', 'detail'])
return self._get_tests_collection(marker, limit,
sort_key, sort_dir, expand,
resource_url)
@wsme_pecan.wsexpose(Cpulse, types.uuid_or_name)
def get_one(self, test_ident):
"""Retrieve information about the given test.
@@ -199,6 +175,16 @@ class cpulseController(rest.RestController):
return Cpulse.convert_with_links(rpc_test)
@pecan.expose('json')
def detail(self, test_ident):
"""Retrieve detail information about the given test.
:param test_ident: UUID of a test or logical name of the test.
"""
rpc_test_detail = api_utils.get_rpc_resource_detail('Cpulse',
test_ident)
return rpc_test_detail
@wsme_pecan.wsexpose(Cpulse, body=Cpulse, status_code=201)
def post(self, test):
"""Create a new test.

View File

@@ -19,9 +19,11 @@ import pecan
import wsme
from cloudpulse.common import exception
from cloudpulse.common.plugin import discover
from cloudpulse.common import utils
from cloudpulse import objects
from cloudpulse.openstack.common._i18n import _
from cloudpulse.scenario import base
CONF = cfg.CONF
@@ -68,3 +70,15 @@ def get_rpc_resource(resource, resource_ident):
return resource.get_by_name(pecan.request.context, resource_ident)
raise exception.InvalidUuidOrName(name=resource_ident)
def get_rpc_resource_detail(resource, resource_ident):
resource = getattr(objects, resource)
test = resource.get_by_uuid(pecan.request.context, resource_ident)
discover.import_modules_from_package("cloudpulse.scenario.plugins")
for scenario_group in discover.itersubclasses(base.Scenario):
for method in dir(scenario_group):
if test['name'] == method:
scenario = scenario_group()
callback = getattr(scenario, 'verbose')
return callback()

View File

@@ -30,3 +30,9 @@ class dummy_scenario(base.Scenario):
@base.scenario(operator=True)
def dummy_cloudtest(self, *args, **kwargs):
return (200, "success", ['dummy_result'])
def verbose(self, *args, **kwargs):
# This is a sample entry which spcifies how the verbose call
# should handle in each module.
return [{'result': 'success',
'description': 'The test run successfully'}]