client: fix REST autohold-list response

The current REST client code takes the autohold API response and
modifies it into a format that the display function can't work with.
I couldn't exactly pinpoint how it got this way, but it seems
emperically that the RPC response is the same as the API response;
i.e. we can remove this munging and the display function can handle
both.

 zuul --zuul-url=https://zuul.opendev.org/ autohold-list --tenant openstack

is an example of this response.

Change-Id: I1087041f1054244130f1b5a68a0282742d6581d7
This commit is contained in:
Ian Wienand 2021-05-27 17:04:15 +10:00
parent 997f88185a
commit 01efd92d2a
1 changed files with 3 additions and 12 deletions

View File

@ -82,17 +82,7 @@ class ZuulRESTClient(object):
'tenant/%s/autohold' % tenant)
req = requests.get(url, verify=self.verify)
self._check_status(req)
resp = req.json()
# reformat the answer to match RPC format
ret = {}
for d in resp:
key = ','.join([d['tenant'],
d['project'],
d['job'],
d['ref_filter']])
ret[key] = (d['count'], d['reason'], d['node_hold_expiration'])
return ret
return req.json()
def enqueue(self, tenant, pipeline, project, trigger, change):
if not self.auth_token:
@ -494,7 +484,7 @@ class Client(zuul.cmd.ZuulApp):
table = prettytable.PrettyTable(
field_names=[
'ID', 'Tenant', 'Project', 'Job', 'Ref Filter',
'Max Count', 'Reason'
'Current Count', 'Max Count', 'Reason'
])
for request in autohold_requests:
@ -504,6 +494,7 @@ class Client(zuul.cmd.ZuulApp):
request['project'],
request['job'],
request['ref_filter'],
request['current_count'],
request['max_count'],
request['reason'],
])