vmm
changeset 45 9e66138aad0b
parent 44 c9ab6900ede9
child 47 191d5a5adc4a
equal deleted inserted replaced
44:c9ab6900ede9 45:9e66138aad0b
    31 
    31 
    32 def usage(excode=0, errMsg=None):
    32 def usage(excode=0, errMsg=None):
    33     sys.stderr.write(_("""\
    33     sys.stderr.write(_("""\
    34 Usage: %s SUBCOMMAND OBJECT ARGS*
    34 Usage: %s SUBCOMMAND OBJECT ARGS*
    35   short long
    35   short long
    36   subcommand            object           args (* = optional)\n\n""")% __prog__)
    36   subcommand               object            args (* = optional)\n\n""")%
       
    37   __prog__)
    37     sys.stderr.write("""\
    38     sys.stderr.write("""\
    38   da    domainadd       domain.tld       transport*
    39   da    domainadd          domain.tld        transport*
    39   di    domaininfo      domain.tld       detailed*
    40   di    domaininfo         domain.tld        detailed*
    40   dt    domaintransport domain.tld       transport force*
    41   dt    domaintransport    domain.tld        transport force*
    41   dd    domaindelete    domain.tld       delalias*|deluser*|delall*
    42   dd    domaindelete       domain.tld        delalias*|deluser*|delall*
    42   ua    useradd         user@domain.tld  password*
    43   daa   domainaliasadd     aliasdomain.tld   domain.tld
    43   ui    userinfo        user@domain.tld  du*
    44   dad   domainaliasdelete  aliasdomain.tld
    44   un    username        user@domain.tld  'Users Name'
    45   ua    useradd            user@domain.tld   password*
    45   up    userpassword    user@domain.tld  password*
    46   ui    userinfo           user@domain.tld   du*
    46   ut    usertransport   user@domain.tld  transport
    47   un    username           user@domain.tld   'Users Name'
    47   u0    userdisable     user@domain.tld  smtp*|pop3*|imap*|managesieve*|all*
    48   up    userpassword       user@domain.tld   password*
    48   u1    userenable      user@domain.tld  smtp*|pop3*|imap*|managesieve*|all*
    49   ut    usertransport      user@domain.tld   transport
    49   ud    userdelete      user@domain.tld
    50   u0    userdisable        user@domain.tld   smtp*|pop3*|imap*|managesieve*|all*
    50   aa    aliasadd        alias@domain.tld user@domain.tld
    51   u1    userenable         user@domain.tld   smtp*|pop3*|imap*|managesieve*|all*
    51   ai    aliasinfo       alias@domain.tld
    52   ud    userdelete         user@domain.tld
    52   ad    aliasdelete     alias@domain.tld user@domain.tld*
    53   aa    aliasadd           alias@domain.tld  user@domain.tld
    53   gu    getuser         userid
    54   ai    aliasinfo          alias@domain.tld
    54   ld    listdomains                      pattern*
    55   ad    aliasdelete        alias@domain.tld  user@domain.tld*
    55   cf    configure                        section*
    56   gu    getuser            userid
       
    57   ld    listdomains                          pattern*
       
    58   cf    configure                            section*
    56   h     help
    59   h     help
    57   v     version
    60   v     version
    58 
    61 
    59 """)
    62 """)
    60     if not errMsg is None:
    63     if not errMsg is None:
   115 
   118 
   116 def _printList(alist, title):
   119 def _printList(alist, title):
   117     msg = '%s %s' % (_('Available'), title)
   120     msg = '%s %s' % (_('Available'), title)
   118     print '%s\n%s' % (msg, '-'*len(msg))
   121     print '%s\n%s' % (msg, '-'*len(msg))
   119     if len(alist) > 0:
   122     if len(alist) > 0:
   120         for val in alist:
   123         if title != _('alias domains'):
   121             print '\t%s' % val
   124             for val in alist:
       
   125                 print '\t%s' % val
       
   126         else:
       
   127             for dom in alist:
       
   128                 if not dom.startswith('xn--'):
       
   129                     print '\t%s' % dom
       
   130                 else:
       
   131                     print '\t%s (%s)' % (dom, vmm.ace2idna(dom))
   122     else:
   132     else:
   123         print _('\tNone')
   133         print _('\tNone')
   124     print
   134     print
   125 
   135 
   126 def _printAliases(alias, targets):
   136 def _printAliases(alias, targets):
   140     if main:
   150     if main:
   141         return '\t[+] %s' %  domain
   151         return '\t[+] %s' %  domain
   142     else:
   152     else:
   143         return '\t[-]     %s' % domain
   153         return '\t[-]     %s' % domain
   144 
   154 
   145 
       
   146 def _printDomList(dids, domains):
   155 def _printDomList(dids, domains):
   147     if argc < 3:
   156     if argc < 3:
   148         msg = _('Available domains')
   157         msg = _('Available domains')
   149     else:
   158     else:
   150         msg = _('Matching domains')
   159         msg = _('Matching domains')
   195         usage(EXIT.MISSING_ARGS, _('Missing new transport.'))
   204         usage(EXIT.MISSING_ARGS, _('Missing new transport.'))
   196     elif argc < 5:
   205     elif argc < 5:
   197         vmm.domain_transport(sys.argv[2].lower(), sys.argv[3])
   206         vmm.domain_transport(sys.argv[2].lower(), sys.argv[3])
   198     else:
   207     else:
   199         vmm.domain_transport(sys.argv[2].lower(), sys.argv[3], sys.argv[4])
   208         vmm.domain_transport(sys.argv[2].lower(), sys.argv[3], sys.argv[4])
       
   209 
       
   210 def domain_alias_add():
       
   211     if argc < 3:
       
   212         usage(EXIT.MISSING_ARGS,
       
   213                 _('Missing alias domain name and target domain name.'))
       
   214     elif argc < 4:
       
   215         usage(EXIT.MISSING_ARGS, _('Missing target domain name.'))
       
   216     else:
       
   217         vmm.domain_alias_add(sys.argv[2].lower(), sys.argv[3].lower())
       
   218 
       
   219 def domain_alias_delete():
       
   220     if argc < 3:
       
   221         usage(EXIT.MISSING_ARGS, _('Missing alias domain name.'))
       
   222     else:
       
   223         vmm.domain_alias_delete(sys.argv[2].lower())
   200 
   224 
   201 def user_add():
   225 def user_add():
   202     if argc < 3:
   226     if argc < 3:
   203         usage(EXIT.MISSING_ARGS, _('Missing e-mail address.'))
   227         usage(EXIT.MISSING_ARGS, _('Missing e-mail address.'))
   204     elif argc < 4:
   228     elif argc < 4:
   323             domain_info()
   347             domain_info()
   324         elif sys.argv[1] in ['dt', 'domaintransport']:
   348         elif sys.argv[1] in ['dt', 'domaintransport']:
   325             domain_transport()
   349             domain_transport()
   326         elif sys.argv[1] in ['dd', 'domaindelete']:
   350         elif sys.argv[1] in ['dd', 'domaindelete']:
   327             domain_delete()
   351             domain_delete()
       
   352         elif sys.argv[1] in ['daa', 'domainaliasadd']:
       
   353             domain_alias_add()
       
   354         elif sys.argv[1] in ['dad', 'domainaliasdelete']:
       
   355             domain_alias_delete()
   328         elif sys.argv[1] in ['ua', 'useradd']:
   356         elif sys.argv[1] in ['ua', 'useradd']:
   329             user_add()
   357             user_add()
   330         elif sys.argv[1] in ['ui', 'userinfo']:
   358         elif sys.argv[1] in ['ui', 'userinfo']:
   331             user_info()
   359             user_info()
   332         elif sys.argv[1] in ['un', 'username']:
   360         elif sys.argv[1] in ['un', 'username']: