sca result -> rpc mode
Change-Id: I71c35b06f1a115d242384ac9f9163cb9caedb2de
This commit is contained in:
parent
9fc3dcde17
commit
fe44498986
@ -84,6 +84,10 @@ class TaskEndpoint(object):
|
||||
return {"uuid":task.uuid,
|
||||
"results":task.results,}
|
||||
|
||||
class ResultEndpoint(object):
|
||||
|
||||
target = oslo_messaging.Target(topic="test", version='1.0')
|
||||
|
||||
def get_result(self, ctx, uuid):
|
||||
ret = db_api.result_get(uuid)
|
||||
# TODO object
|
||||
@ -95,12 +99,22 @@ class TaskEndpoint(object):
|
||||
"data":ret.data,
|
||||
}
|
||||
|
||||
def get_all_results(self, ctx):
|
||||
rets = db_api.get_all_results()
|
||||
# TODO object
|
||||
return [{"id":ret.id,
|
||||
"uuid":ret.uuid,
|
||||
"name":ret.name,
|
||||
"unit":ret.unit,
|
||||
"data":ret.data} for ret in rets]
|
||||
|
||||
transport = oslo_messaging.get_transport(cfg.CONF)
|
||||
target = oslo_messaging.Target(topic='test', server='localhost')
|
||||
endpoints = [
|
||||
ServerControlEndpoint(None),
|
||||
TraceEndpoint(),
|
||||
TaskEndpoint(),
|
||||
ResultEndpoint(),
|
||||
]
|
||||
server = oslo_messaging.get_rpc_server(transport, target, endpoints,
|
||||
executor='blocking')
|
||||
|
@ -2,8 +2,8 @@
|
||||
#-*- coding:utf-8 -*-
|
||||
# Author: Kun Huang <academicgareth@gmail.com>
|
||||
|
||||
from scalpels.db import api as db_api
|
||||
from scalpels.cli.actions import report
|
||||
from scalpels.cli.api import api as agent_api
|
||||
|
||||
def run(config):
|
||||
"""
|
||||
@ -13,7 +13,7 @@ def run(config):
|
||||
list and html: generate_multiple_result_html
|
||||
"""
|
||||
if config.get("list"):
|
||||
rets = db_api.get_all_results()
|
||||
rets = agent_api.get_all_results()
|
||||
if config.get("html"):
|
||||
report.generate_multiple_result_html(rets)
|
||||
elif config.get("short"):
|
||||
@ -22,7 +22,7 @@ def run(config):
|
||||
else:
|
||||
map(report.pprint_result, rets)
|
||||
elif config.get("uuid"):
|
||||
ret = db_api.result_get(config["uuid"])
|
||||
ret = agent_api.get_result(config["uuid"])
|
||||
if config.get("html"):
|
||||
report.generate_result_html(ret)
|
||||
else:
|
||||
|
@ -27,4 +27,7 @@ class API(object):
|
||||
def get_result(self, uuid):
|
||||
return rpcapi.get_result(uuid=uuid)
|
||||
|
||||
def get_all_results(self):
|
||||
return rpcapi.get_all_results()
|
||||
|
||||
api = API()
|
||||
|
@ -25,5 +25,8 @@ class RPCAPI(object):
|
||||
def get_result(self, ctxt={}, uuid=None):
|
||||
return self._client.call(ctxt, "get_result", uuid=uuid)
|
||||
|
||||
def get_all_results(self, ctxt={}):
|
||||
return self._client.call(ctxt, "get_all_results")
|
||||
|
||||
transport = messaging.get_transport(cfg.CONF)
|
||||
rpcapi = RPCAPI(transport)
|
||||
|
Loading…
x
Reference in New Issue
Block a user