mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
domain_remove function
This commit is contained in:
parent
cbd61fc3bc
commit
f38f99f6a7
3 changed files with 31 additions and 2 deletions
|
@ -92,7 +92,7 @@ user:
|
|||
arguments:
|
||||
users:
|
||||
help: Username of users to delete
|
||||
nargs: "+"
|
||||
nargs: "*"
|
||||
--purge:
|
||||
action: store_true
|
||||
|
||||
|
@ -184,7 +184,7 @@ domain:
|
|||
arguments:
|
||||
domain:
|
||||
help: Domain(s) to delete
|
||||
nargs: "+"
|
||||
nargs: "*"
|
||||
|
||||
### domain_info()
|
||||
info:
|
||||
|
|
|
@ -72,3 +72,31 @@ def domain_add(args, connections):
|
|||
return { 'Domains' : result }
|
||||
|
||||
|
||||
def domain_remove(args, connections):
|
||||
"""
|
||||
Remove domain from LDAP
|
||||
|
||||
Keyword argument:
|
||||
args -- Dictionnary of values
|
||||
connections -- LDAP connection
|
||||
|
||||
Returns:
|
||||
Dict
|
||||
"""
|
||||
yldap = connections['ldap']
|
||||
result = []
|
||||
|
||||
args = get_required_args(args, { 'domain' : _('Domain to remove') })
|
||||
if not isinstance(args['domain'], list):
|
||||
args['domain'] = [ args['domain'] ]
|
||||
|
||||
for domain in args['domain']:
|
||||
validate({ domain : r'^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$' })
|
||||
if yldap.remove('virtualdomain=' + domain + ',ou=domains'):
|
||||
result.append(domain)
|
||||
continue
|
||||
else:
|
||||
raise YunoHostError(169, _("An error occured during domain deletion"))
|
||||
|
||||
win_msg(_("Domain(s) successfully deleted"))
|
||||
return { 'Domains' : result }
|
||||
|
|
|
@ -159,6 +159,7 @@ def user_delete(args, connections):
|
|||
yldap = connections['ldap']
|
||||
result = { 'Users' : [] }
|
||||
|
||||
args = get_required_args(args, { 'users' : _('User to delete') })
|
||||
if not isinstance(args['users'], list):
|
||||
args['users'] = [ args['users'] ]
|
||||
|
||||
|
|
Loading…
Reference in a new issue