VirtualMailManager/cli/subcommands.py
branchv0.7.x
changeset 686 5f4abdab738e
parent 685 c6024bc1de0f
child 689 dab0630947a2
equal deleted inserted replaced
685:c6024bc1de0f 686:5f4abdab738e
   165 
   165 
   166 def domain_add(ctx):
   166 def domain_add(ctx):
   167     """create a new domain"""
   167     """create a new domain"""
   168     fqdn = ctx.args.fqdn.lower()
   168     fqdn = ctx.args.fqdn.lower()
   169     transport = ctx.args.transport.lower() if ctx.args.transport else None
   169     transport = ctx.args.transport.lower() if ctx.args.transport else None
   170     ctx.hdlr.domain_add(fqdn, transport)
   170     ctx.hdlr.domain_add(fqdn, transport, ctx.args.note)
   171     if ctx.cget('domain.auto_postmaster'):
   171     if ctx.cget('domain.auto_postmaster'):
   172         w_std(_('Creating account for postmaster@%s') % fqdn)
   172         w_std(_('Creating account for postmaster@%s') % fqdn)
   173         ctx.args.scmd = 'useradd'
   173         ctx.args.scmd = 'useradd'
   174         ctx.args.address = 'postmaster@%s' % fqdn
   174         ctx.args.address = 'postmaster@%s' % fqdn
   175         ctx.args.password = None
   175         ctx.args.password = None
       
   176         ctx.args.note = None
   176         user_add(ctx)
   177         user_add(ctx)
   177 
   178 
   178 
   179 
   179 def domain_delete(ctx):
   180 def domain_delete(ctx):
   180     """delete the given domain and all its alias domains"""
   181     """delete the given domain and all its alias domains"""
   337             raise
   338             raise
   338 
   339 
   339 
   340 
   340 def user_add(ctx):
   341 def user_add(ctx):
   341     """create a new e-mail user with the given address"""
   342     """create a new e-mail user with the given address"""
   342     gen_pass = ctx.hdlr.user_add(ctx.args.address.lower(), ctx.args.password)
   343     gen_pass = ctx.hdlr.user_add(ctx.args.address.lower(), ctx.args.password,
       
   344                                  ctx.args.note)
   343     if not ctx.args.password and gen_pass:
   345     if not ctx.args.password and gen_pass:
   344         w_std(_("Generated password: %s") % gen_pass)
   346         w_std(_("Generated password: %s") % gen_pass)
   345 
   347 
   346 
   348 
   347 def user_delete(ctx):
   349 def user_delete(ctx):
   613                "(domain.transport) from vmm.cfg. The specified transport "
   615                "(domain.transport) from vmm.cfg. The specified transport "
   614                "will be the default transport for all new accounts in this "
   616                "will be the default transport for all new accounts in this "
   615                "domain.")),
   617                "domain.")),
   616            formatter_class=RawDescriptionHelpFormatter)
   618            formatter_class=RawDescriptionHelpFormatter)
   617     da.add_argument('fqdn', help=_('a fully qualified domain name'))
   619     da.add_argument('fqdn', help=_('a fully qualified domain name'))
       
   620     da.add_argument('-n', metavar='NOTE', dest='note',
       
   621                     help=_('the note that should be set'))
   618     da.add_argument('-t', metavar='TRANSPORT', dest='transport',
   622     da.add_argument('-t', metavar='TRANSPORT', dest='transport',
   619                     help=_('a Postfix transport (transport: or '
   623                     help=_('a Postfix transport (transport: or '
   620                            'transport:nexthop)'))
   624                            'transport:nexthop)'))
   621     da.set_defaults(func=domain_add, scmd='domainadd')
   625     da.set_defaults(func=domain_add, scmd='domainadd')
   622 
   626 
   769                'will generate a random password and print it to stdout '
   773                'will generate a random password and print it to stdout '
   770                'after the account has been created.')),
   774                'after the account has been created.')),
   771            formatter_class=RawDescriptionHelpFormatter)
   775            formatter_class=RawDescriptionHelpFormatter)
   772     ua.add_argument('address',
   776     ua.add_argument('address',
   773                     help=_("an account's e-mail address (local-part@fqdn)"))
   777                     help=_("an account's e-mail address (local-part@fqdn)"))
       
   778     ua.add_argument('-n', metavar='NOTE', dest='note',
       
   779                     help=_('the note that should be set'))
   774     ua.add_argument('-p', metavar='PASSWORD', dest='password',
   780     ua.add_argument('-p', metavar='PASSWORD', dest='password',
   775                     help=_("the new user's password"))
   781                     help=_("the new user's password"))
   776     ua.set_defaults(func=user_add, scmd='useradd')
   782     ua.set_defaults(func=user_add, scmd='useradd')
   777 
   783 
   778     details = ('aliases', 'du', 'full')
   784     details = ('aliases', 'du', 'full')