vmm
changeset 55 15c873f94ba6
parent 54 1fc1f82c662f
child 57 38c42e09677a
equal deleted inserted replaced
54:1fc1f82c662f 55:15c873f94ba6
    46     u_body = """\
    46     u_body = """\
    47   da    domainadd          domain.tld        transport*
    47   da    domainadd          domain.tld        transport*
    48   di    domaininfo         domain.tld        detailed*
    48   di    domaininfo         domain.tld        detailed*
    49   dt    domaintransport    domain.tld        transport force*
    49   dt    domaintransport    domain.tld        transport force*
    50   dd    domaindelete       domain.tld        delalias*|deluser*|delall*
    50   dd    domaindelete       domain.tld        delalias*|deluser*|delall*
    51   daa   domainaliasadd     aliasdomain.tld   domain.tld
    51   ada   aliasdomainadd     aliasdomain.tld   domain.tld
    52   dai   domainaliasinfo    aliasdomain.tld
    52   adi   aliasdomaininfo    aliasdomain.tld
    53   dad   domainaliasdelete  aliasdomain.tld
    53   add   aliasdomaindelete  aliasdomain.tld
    54   ua    useradd            user@domain.tld   password*
    54   ua    useradd            user@domain.tld   password*
    55   ui    userinfo           user@domain.tld   du*
    55   ui    userinfo           user@domain.tld   du*
    56   un    username           user@domain.tld   'Users Name'
    56   un    username           user@domain.tld   'Users Name'
    57   up    userpassword       user@domain.tld   password*
    57   up    userpassword       user@domain.tld   password*
    58   ut    usertransport      user@domain.tld   transport
    58   ut    usertransport      user@domain.tld   transport
   132     print
   132     print
   133 
   133 
   134 def _printAliases(alias, targets):
   134 def _printAliases(alias, targets):
   135     msg = _('Alias information')
   135     msg = _('Alias information')
   136     w_std('%s\n%s' % (msg, '-'*len(msg)))
   136     w_std('%s\n%s' % (msg, '-'*len(msg)))
   137     w_std(_('\tMail for %s goes to:') % alias)
   137     w_std(_('\tMail for %s will be redirected to:') % alias)
   138     if len(targets) > 0:
   138     if len(targets) > 0:
   139         for target in targets:
   139         for target in targets:
   140             w_std('\t     -> %s' % target)
   140             w_std('\t     * %s' % target)
   141     else:
   141     else:
   142         w_std(_('\tNone'))
   142         w_std(_('\tNone'))
   143     print
   143     print
   144 
   144 
   145 def _formatDom(domain, main=True):
   145 def _formatDom(domain, main=True):
   165             if len(domains[id]) > 1:
   165             if len(domains[id]) > 1:
   166                 for alias in domains[id][1:]:
   166                 for alias in domains[id][1:]:
   167                     w_std(_formatDom(alias, main=False))
   167                     w_std(_formatDom(alias, main=False))
   168     print
   168     print
   169 
   169 
       
   170 def _printAliasDomInfo(info):
       
   171     msg = _('Alias domain information')
       
   172     for k in ['alias', 'domain']:
       
   173         if info[k].startswith('xn--'):
       
   174             info[k] = "%s (%s)" % (info[k], vmm.ace2idna(info[k]))
       
   175     w_std('%s\n%s' % (msg, '-'*len(msg)))
       
   176     w_std(
       
   177         _('\tThe alias domain %(alias)s belongs to:\n\t    * %(domain)s')%info)
       
   178     print
       
   179     
       
   180 
   170 def configure():
   181 def configure():
   171     if need_setup or len(argv) < 3:
   182     if need_setup or len(argv) < 3:
   172         vmm.configure()
   183         vmm.configure()
   173     else:
   184     else:
   174         vmm.configure(argv[2])
   185         vmm.configure(argv[2])
   209     elif argc < 5:
   220     elif argc < 5:
   210         vmm.domainTransport(argv[2].lower(), argv[3])
   221         vmm.domainTransport(argv[2].lower(), argv[3])
   211     else:
   222     else:
   212         vmm.domainTransport(argv[2].lower(), argv[3], argv[4])
   223         vmm.domainTransport(argv[2].lower(), argv[3], argv[4])
   213 
   224 
   214 def domain_alias_add():
   225 def alias_domain_add():
   215     if argc < 3:
   226     if argc < 3:
   216         usage(EXIT.MISSING_ARGS,
   227         usage(EXIT.MISSING_ARGS,
   217                 _(u'Missing alias domain name and target domain name.'))
   228                 _(u'Missing alias domain name and target domain name.'))
   218     elif argc < 4:
   229     elif argc < 4:
   219         usage(EXIT.MISSING_ARGS, _(u'Missing target domain name.'))
   230         usage(EXIT.MISSING_ARGS, _(u'Missing target domain name.'))
   220     else:
   231     else:
   221         vmm.domainAliasAdd(argv[2].lower(), argv[3].lower())
   232         vmm.aliasDomainAdd(argv[2].lower(), argv[3].lower())
   222 
   233 
   223 def domain_alias_info():
   234 def alias_domain_info():
   224     if argc < 3:
   235     if argc < 3:
   225         usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
   236         usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
   226     else:
   237     else:
   227         info = vmm.domainAliasInfo(argv[2].lower())
   238         _printAliasDomInfo(vmm.aliasDomainInfo(argv[2].lower()))
   228         w_std(info+'\n')
   239 
   229 
   240 def alias_domain_delete():
   230 def domain_alias_delete():
       
   231     if argc < 3:
   241     if argc < 3:
   232         usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
   242         usage(EXIT.MISSING_ARGS, _(u'Missing alias domain name.'))
   233     else:
   243     else:
   234         vmm.domainAliasDelete(argv[2].lower())
   244         vmm.aliasDomainDelete(argv[2].lower())
   235 
   245 
   236 def user_add():
   246 def user_add():
   237     if argc < 3:
   247     if argc < 3:
   238         usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
   248         usage(EXIT.MISSING_ARGS, _(u'Missing e-mail address.'))
   239     elif argc < 4:
   249     elif argc < 4:
   364             domain_info()
   374             domain_info()
   365         elif argv[1] in ['dt', 'domaintransport']:
   375         elif argv[1] in ['dt', 'domaintransport']:
   366             domain_transport()
   376             domain_transport()
   367         elif argv[1] in ['dd', 'domaindelete']:
   377         elif argv[1] in ['dd', 'domaindelete']:
   368             domain_delete()
   378             domain_delete()
   369         elif argv[1] in ['daa', 'domainaliasadd']:
   379         elif argv[1] in ['ada', 'aliasdomainadd']:
   370             domain_alias_add()
   380             alias_domain_add()
   371         elif argv[1] in ['dai', 'domainaliasinfo']:
   381         elif argv[1] in ['adi', 'aliasdomaininfo']:
   372             domain_alias_info()
   382             alias_domain_info()
   373         elif argv[1] in ['dad', 'domainaliasdelete']:
   383         elif argv[1] in ['add', 'aliasdomaindelete']:
   374             domain_alias_delete()
   384             alias_domain_delete()
   375         elif argv[1] in ['ua', 'useradd']:
   385         elif argv[1] in ['ua', 'useradd']:
   376             user_add()
   386             user_add()
   377         elif argv[1] in ['ui', 'userinfo']:
   387         elif argv[1] in ['ui', 'userinfo']:
   378             user_info()
   388             user_info()
   379         elif argv[1] in ['un', 'username']:
   389         elif argv[1] in ['un', 'username']: