Browse Source

cmd_uacreg: added command to view records in database

Daniel-Constantin Mierla 6 years ago
parent
commit
8737c9456b
1 changed files with 29 additions and 0 deletions
  1. 29 0
      kamcli/commands/cmd_uacreg.py

+ 29 - 0
kamcli/commands/cmd_uacreg.py

@@ -65,6 +65,35 @@ def uacreg_add(ctx, realm, authha1, flags, regdelay, socket, l_uuid, l_username,
     e.execute('insert into uacreg (l_uuid, l_username, l_domain, r_username, r_domain, realm, auth_username, auth_password, auth_ha1, auth_proxy, expires, flags, reg_delay, socket) values ({0!r}, {1!r}, {2!r}, {3!r}, {4!r}, {5!r}, {6!r}, {7!r}, {8!r}, {9!r}, {10}, {11}, {12}, {13!r})'.format(l_uuid.encode('ascii','ignore').decode(), l_username.encode('ascii','ignore').decode(), l_domain.encode('ascii','ignore').decode(), r_username.encode('ascii','ignore').decode(), r_domain.encode('ascii','ignore').decode(), realm.encode('ascii','ignore').decode(), auth_username.encode('ascii','ignore').decode(), pwval.encode('ascii','ignore').decode(), ha1val.encode('ascii','ignore').decode(), auth_proxy.encode('ascii','ignore').decode(), expires, flags, regdelay, socket.encode('ascii','ignore').decode()))
     e.execute('insert into uacreg (l_uuid, l_username, l_domain, r_username, r_domain, realm, auth_username, auth_password, auth_ha1, auth_proxy, expires, flags, reg_delay, socket) values ({0!r}, {1!r}, {2!r}, {3!r}, {4!r}, {5!r}, {6!r}, {7!r}, {8!r}, {9!r}, {10}, {11}, {12}, {13!r})'.format(l_uuid.encode('ascii','ignore').decode(), l_username.encode('ascii','ignore').decode(), l_domain.encode('ascii','ignore').decode(), r_username.encode('ascii','ignore').decode(), r_domain.encode('ascii','ignore').decode(), realm.encode('ascii','ignore').decode(), auth_username.encode('ascii','ignore').decode(), pwval.encode('ascii','ignore').decode(), ha1val.encode('ascii','ignore').decode(), auth_proxy.encode('ascii','ignore').decode(), expires, flags, regdelay, socket.encode('ascii','ignore').decode()))
 
 
 
 
+##
+#
+#
[email protected]('showdb', short_help='Show dialplan records in database')
[email protected]('oformat', '--output-format', '-F',
+                type=click.Choice(['raw', 'json', 'table', 'dict']),
+                default=None, help='Format the output')
[email protected]('ostyle', '--output-style', '-S',
+                default=None, help='Style of the output (tabulate table format)')
[email protected]('l_uuid', nargs=-1, metavar='[<l_uuid>]')
+@pass_context
+def dispatcher_showdb(ctx, oformat, ostyle, l_uuid):
+    """Show details for records in uacreg database table
+
+    \b
+    Parameters:
+        [<l_uuid>] - local user unique id
+    """
+    e = create_engine(ctx.gconfig.get('db', 'rwurl'))
+    if not l_uuid:
+        ctx.vlog('Showing all uacreg records')
+        res = e.execute('select * from uacreg')
+        ioutils_dbres_print(ctx, oformat, ostyle, res)
+    else:
+        for l in l_uuid:
+            ctx.vlog('Showing uacreg records for l_uuid: ' + l)
+            res = e.execute('select * from uacreg where l_uuid="%s"', l)
+            ioutils_dbres_print(ctx, oformat, ostyle, res)
+
 ##
 ##
 #
 #
 #
 #