Revert "Add /label-list to the webapp"
This reverts commit b7378892502836f257456cd277190ee75a7ca75f. As discussed in [1] the label list is intended to provide a list of available labels so users don't have to dig into configuration files to determine what is available to run jobs on. As written it possibly misses nodes without a min-ready or in-use nodes, so an alternative implementation is probably called for. This is also currently returns values in a plain list, rather than a list of dicts, which prevents some de-deuplication refactoring. Thus remove it for now, pending some more work. [1] http://lists.zuul-ci.org/pipermail/zuul-discuss/2018-February/000039.html Change-Id: Ic88da24dd5d140697d4af8e6f5ee0936c44f59c5
This commit is contained in:
parent
a4f87b6270
commit
cc95d679bd
@ -135,22 +135,6 @@ def node_list(zk, node_id=None, detail=False, format='pretty'):
|
|||||||
raise ValueError('Unknown format "%s"' % format)
|
raise ValueError('Unknown format "%s"' % format)
|
||||||
|
|
||||||
|
|
||||||
def label_list(zk, format='pretty'):
|
|
||||||
labels = set()
|
|
||||||
for node in zk.nodeIterator():
|
|
||||||
labels.add(node.type)
|
|
||||||
if format == 'pretty':
|
|
||||||
t = PrettyTable(["Label", ])
|
|
||||||
t.align = 'l'
|
|
||||||
for label in labels:
|
|
||||||
t.add_row(label)
|
|
||||||
return str(t)
|
|
||||||
elif format == 'json':
|
|
||||||
return json.dumps(list(labels))
|
|
||||||
else:
|
|
||||||
raise ValueError('Unknown format "%s"' % format)
|
|
||||||
|
|
||||||
|
|
||||||
def dib_image_list(zk, format='pretty'):
|
def dib_image_list(zk, format='pretty'):
|
||||||
headers_table = OrderedDict([
|
headers_table = OrderedDict([
|
||||||
("id", "ID"),
|
("id", "ID"),
|
||||||
|
@ -147,27 +147,6 @@ class TestWebApp(tests.DBTestCase):
|
|||||||
objs = json.loads(data.decode('utf8'))
|
objs = json.loads(data.decode('utf8'))
|
||||||
self.assertEqual(0, len(objs), objs)
|
self.assertEqual(0, len(objs), objs)
|
||||||
|
|
||||||
def test_label_list_json(self):
|
|
||||||
configfile = self.setup_config('node.yaml')
|
|
||||||
pool = self.useNodepool(configfile, watermark_sleep=1)
|
|
||||||
self.useBuilder(configfile)
|
|
||||||
pool.start()
|
|
||||||
webapp = self.useWebApp(pool, port=0)
|
|
||||||
webapp.start()
|
|
||||||
port = webapp.server.socket.getsockname()[1]
|
|
||||||
|
|
||||||
self.waitForImage('fake-provider', 'fake-image')
|
|
||||||
self.waitForNodes('fake-label')
|
|
||||||
|
|
||||||
req = request.Request(
|
|
||||||
"http://localhost:%s/label-list.json" % port)
|
|
||||||
f = request.urlopen(req)
|
|
||||||
self.assertEqual(f.info().get('Content-Type'),
|
|
||||||
'application/json')
|
|
||||||
data = f.read()
|
|
||||||
objs = json.loads(data.decode('utf8'))
|
|
||||||
self.assertEqual(['fake-label'], objs)
|
|
||||||
|
|
||||||
def test_request_list_json(self):
|
def test_request_list_json(self):
|
||||||
configfile = self.setup_config('node.yaml')
|
configfile = self.setup_config('node.yaml')
|
||||||
pool = self.useNodepool(configfile, watermark_sleep=1)
|
pool = self.useNodepool(configfile, watermark_sleep=1)
|
||||||
|
@ -104,12 +104,6 @@ class WebApp(threading.Thread):
|
|||||||
output = status.node_list(self.nodepool.getZK(),
|
output = status.node_list(self.nodepool.getZK(),
|
||||||
format='json',
|
format='json',
|
||||||
node_id=params.get('node_id'))
|
node_id=params.get('node_id'))
|
||||||
elif path == '/label-list':
|
|
||||||
output = status.label_list(self.nodepool.getZK(),
|
|
||||||
format='pretty')
|
|
||||||
elif path == '/label-list.json':
|
|
||||||
output = status.label_list(self.nodepool.getZK(),
|
|
||||||
format='json')
|
|
||||||
elif path == '/request-list':
|
elif path == '/request-list':
|
||||||
output = status.request_list(self.nodepool.getZK(),
|
output = status.request_list(self.nodepool.getZK(),
|
||||||
format='pretty')
|
format='pretty')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user