From 81bebfca09815b8c147e3e868d4826172ead11e1 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Thu, 14 Jul 2011 15:26:49 -0700 Subject: [PATCH] lock server: return host pubkeys with locked machine names --- teuthology/locker/api.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/teuthology/locker/api.py b/teuthology/locker/api.py index 0a5641ddd95e0..d5091ffef2814 100644 --- a/teuthology/locker/api.py +++ b/teuthology/locker/api.py @@ -83,13 +83,17 @@ class Lock: while True: try: with DB.transaction(): - results = list(DB.select('machine', what='name', + results = list(DB.select('machine', what='name, sshpubkey', where='locked = false and up = true', limit=num)) if len(results) < num: raise web.HTTPError(status='503 Service Unavailable') - names = [row.name for row in results] - num_locked = DB.update('machine', where=web.db.sqlors('name = ', names), + name_keys = {} + for row in results: + name_keys[row.name] = row.sshpubkey + num_locked = DB.update('machine', + where=web.db.sqlors('name = ', + name_keys.keys()), locked=True, locked_by=user, locked_since=web.db.SQLLiteral('NOW()')) @@ -103,4 +107,4 @@ class Lock: break web.header('Content-type', 'text/json') - return json.dumps(names) + return json.dumps(name_keys) -- 2.39.5