|
@@ -0,0 +1,90 @@
|
|
|
+import click
|
|
|
+from sqlalchemy import create_engine
|
|
|
+from kamcli.ioutils import ioutils_dbres_print
|
|
|
+from kamcli.cli import pass_context
|
|
|
+from kamcli.iorpc import command_ctl
|
|
|
+
|
|
|
+##
|
|
|
+#
|
|
|
+#
|
|
|
[email protected]('uacreg', help='Manage uac remote registration')
|
|
|
+@pass_context
|
|
|
+def cli(ctx):
|
|
|
+ pass
|
|
|
+
|
|
|
+
|
|
|
+##
|
|
|
+#
|
|
|
+#
|
|
|
[email protected]('add', short_help='Add a new remote registration account')
|
|
|
[email protected]('realm', '--realm', default='',
|
|
|
+ help='Realm (default: "")')
|
|
|
[email protected]('authha1', '--auth-ha1', is_flag=True,
|
|
|
+ help='Auth password in HA1 format')
|
|
|
[email protected]('flags', '--flags', type=int, default=0,
|
|
|
+ help='Flags (default: 0)')
|
|
|
[email protected]('regdelay', '--reg-delay', type=int, default=0,
|
|
|
+ help='Registration delay (default: 0)')
|
|
|
[email protected]('socket', '--socket', default='',
|
|
|
+ help='Local socket (default: "")')
|
|
|
[email protected]('l_uuid', metavar='<l_uuid>')
|
|
|
[email protected]('l_username', metavar='<l_username>')
|
|
|
[email protected]('l_domain', metavar='<l_domain>')
|
|
|
[email protected]('r_username', metavar='<r_username>')
|
|
|
[email protected]('r_domain', metavar='<r_domain>')
|
|
|
[email protected]('auth_username', metavar='<auth_username>')
|
|
|
[email protected]('auth_password', metavar='<auth_password>')
|
|
|
[email protected]('auth_proxy', metavar='<auth_proxy>')
|
|
|
[email protected]('expires', metavar='<expires>', type=int)
|
|
|
+@pass_context
|
|
|
+def uacreg_add(ctx, realm, authha1, flags, regdelay, socket, l_uuid, l_username,
|
|
|
+ l_domain, r_username, r_domain, auth_username, auth_password,
|
|
|
+ auth_proxy, expires):
|
|
|
+ """Add a new uac remote registration account
|
|
|
+
|
|
|
+ \b
|
|
|
+ Parameters:
|
|
|
+ <l_uuid> - local user unique id
|
|
|
+ <l_username> - local username
|
|
|
+ <l_domain> - local domain
|
|
|
+ <r_username> - remote username
|
|
|
+ <r_domain> - remote domain
|
|
|
+ <auth_username> - auth username
|
|
|
+ <auth_password> - auth password
|
|
|
+ <auth_proxy> - auth proxy (sip address)
|
|
|
+ <expires> - expires interval (int)
|
|
|
+ """
|
|
|
+ ctx.vlog('Adding a new uac remote registration account - local uuid: [%s]', l_uuid)
|
|
|
+ pwval = ""
|
|
|
+ ha1val = ""
|
|
|
+ if authha1:
|
|
|
+ ha1val = auth_password
|
|
|
+ else:
|
|
|
+ pwval = auth_password
|
|
|
+ e = create_engine(ctx.gconfig.get('db', 'rwurl'))
|
|
|
+ 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]('list', short_help='Show details for remote registration records in memory')
|
|
|
+@pass_context
|
|
|
+def uacreg_list(ctx):
|
|
|
+ """Show details for remote registration records in memory
|
|
|
+
|
|
|
+ \b
|
|
|
+ """
|
|
|
+ command_ctl(ctx, 'uac.reg_dump', [ ])
|
|
|
+
|
|
|
+
|
|
|
+##
|
|
|
+#
|
|
|
+#
|
|
|
[email protected]('reload', short_help='Reload remote registration records from database into memory')
|
|
|
+@pass_context
|
|
|
+def uacreg_reload(ctx):
|
|
|
+ """Reload remote registration records from database into memory
|
|
|
+ """
|
|
|
+ command_ctl(ctx, 'uac.reg_reload', [ ])
|
|
|
+
|