[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master] Add commands to list keyrings



Signed-off-by: Mark Hymers <mhy@debian.org>
---
 dak/admin.py |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/dak/admin.py b/dak/admin.py
index d159651..1dc7e7b 100755
--- a/dak/admin.py
+++ b/dak/admin.py
@@ -61,6 +61,11 @@ Perform administrative work on the dak database.
      c db-shell             show db config in a usable form for psql
      c NAME                 show option NAME as set in configuration table
 
+  keyring / k:
+     k list-all             list all keyrings
+     k list-binary          list all keyrings with a NULL source acl
+     k list-source          list all keyrings with a non NULL source acl
+
   architecture / a:
      a list                 show a list of architectures
      a rm ARCH              remove an architecture (will only work if
@@ -469,6 +474,35 @@ dispatch['c'] = show_config
 
 ################################################################################
 
+def show_keyring(command):
+    args = [str(x) for x in command]
+    cnf = utils.get_conf()
+
+    die_arglen(args, 2, "E: keyring needs at least a command")
+
+    mode = args[1].lower()
+
+    d = DBConn()
+
+    q = d.session().query(Keyring).filter(Keyring.active == True)
+
+    if mode == 'list-all':
+        pass
+    elif mode == 'list-binary':
+        q = q.filter(Keyring.default_source_acl_id == None)
+    elif mode == 'list-source':
+        q = q.filter(Keyring.default_source_acl_id != None)
+    else:
+        die("E: keyring command unknown")
+
+    for k in q.all():
+        print k.keyring_name
+
+dispatch['keyring'] = show_keyring
+dispatch['k'] = show_keyring
+
+################################################################################
+
 def main():
     """Perform administrative work on the dak database"""
     global dryrun
-- 
1.7.2.5


Reply to: