web: add /{tenant}/pipelines route
This change adds the pipeline_get gearman function to the scheduler gear to expose the pipeline list. This change also adds /{tenant}/pipelines zuul-web route. Change-Id: Iabed326de409202308928d3167ca34654d3b06ba
This commit is contained in:
parent
9944f14158
commit
f0bd51a07f
|
@ -371,6 +371,17 @@ class TestWeb(BaseTestWeb):
|
|||
'voting': True
|
||||
}], data)
|
||||
|
||||
def test_web_pipeline_list(self):
|
||||
# can we fetch the list of pipelines
|
||||
data = self.get_url('api/tenant/tenant-one/pipelines').json()
|
||||
|
||||
expected_list = [
|
||||
{'name': 'check'},
|
||||
{'name': 'gate'},
|
||||
{'name': 'post'},
|
||||
]
|
||||
self.assertEqual(expected_list, data)
|
||||
|
||||
def test_web_project_list(self):
|
||||
# can we fetch the list of projects
|
||||
data = self.get_url('api/tenant/tenant-one/projects').json()
|
||||
|
|
|
@ -73,6 +73,7 @@ class RPCListener(object):
|
|||
self.worker.registerFunction("zuul:job_list")
|
||||
self.worker.registerFunction("zuul:project_get")
|
||||
self.worker.registerFunction("zuul:project_list")
|
||||
self.worker.registerFunction("zuul:pipeline_list")
|
||||
self.worker.registerFunction("zuul:key_get")
|
||||
self.worker.registerFunction("zuul:config_errors_list")
|
||||
|
||||
|
@ -441,6 +442,17 @@ class RPCListener(object):
|
|||
job.sendWorkComplete(json.dumps(
|
||||
sorted(output, key=lambda project: project["name"])))
|
||||
|
||||
def handle_pipeline_list(self, job):
|
||||
args = json.loads(job.arguments)
|
||||
tenant = self.sched.abide.tenants.get(args.get("tenant"))
|
||||
if not tenant:
|
||||
job.sendWorkComplete(json.dumps(None))
|
||||
return
|
||||
output = []
|
||||
for pipeline in tenant.layout.pipelines.keys():
|
||||
output.append({"name": pipeline})
|
||||
job.sendWorkComplete(json.dumps(output))
|
||||
|
||||
def handle_key_get(self, job):
|
||||
args = json.loads(job.arguments)
|
||||
tenant = self.sched.abide.tenants.get(args.get("tenant"))
|
||||
|
|
|
@ -329,6 +329,18 @@ class ZuulWebAPI(object):
|
|||
resp.headers['Access-Control-Allow-Origin'] = '*'
|
||||
return ret
|
||||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.save_params()
|
||||
@cherrypy.tools.json_out(content_type='application/json; charset=utf-8')
|
||||
def pipelines(self, tenant):
|
||||
job = self.rpc.submitJob('zuul:pipeline_list', {'tenant': tenant})
|
||||
ret = json.loads(job.data[0])
|
||||
if ret is None:
|
||||
raise cherrypy.HTTPError(404, 'Tenant %s does not exist.' % tenant)
|
||||
resp = cherrypy.response
|
||||
resp.headers['Access-Control-Allow-Origin'] = '*'
|
||||
return ret
|
||||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.save_params()
|
||||
def key(self, tenant, project):
|
||||
|
@ -559,6 +571,8 @@ class ZuulWeb(object):
|
|||
controller=api, action='projects')
|
||||
route_map.connect('api', '/api/tenant/{tenant}/project/{project:.*}',
|
||||
controller=api, action='project')
|
||||
route_map.connect('api', '/api/tenant/{tenant}/pipelines',
|
||||
controller=api, action='pipelines')
|
||||
route_map.connect('api', '/api/tenant/{tenant}/key/{project:.*}.pub',
|
||||
controller=api, action='key')
|
||||
route_map.connect('api', '/api/tenant/{tenant}/'
|
||||
|
|
Loading…
Reference in New Issue