# HG changeset patch # User Pascal Volk # Date 1208227761 0 # Node ID c98e08791ee89e4fa3f1b3bf063b1f2d6e697f0c # Parent fe9be0081e5f9e20ad30fa18d2dd3fcec6cb3acc * 'VirtualMailManager/VirtualMailManager.py' * 'VirtualMailManager/Domain.py' * 'vmm' - added code to optional force new transport for all existing accounts. diff -r fe9be0081e5f -r c98e08791ee8 ChangeLog --- a/ChangeLog Tue Apr 15 01:28:34 2008 +0000 +++ b/ChangeLog Tue Apr 15 02:49:21 2008 +0000 @@ -5,6 +5,11 @@ * vmm (main): Added code for modify user's transport * VirtualMailManager/VirtualMailManager.py: Implemented VirtualMailManager.user_transport() + * VirtualMailManager/VirtualMailManager.py + (VirtualMailManager.domain_transport()): + * vmm: + * VirtualMailManager/Domain.py (Domain.updateTransport()): Added code to + optional force new transport for all existing accounts. 2008-04-14 Pascal Volk diff -r fe9be0081e5f -r c98e08791ee8 VirtualMailManager/Domain.py --- a/VirtualMailManager/Domain.py Tue Apr 15 01:28:34 2008 +0000 +++ b/VirtualMailManager/Domain.py Tue Apr 15 02:49:21 2008 +0000 @@ -153,11 +153,12 @@ raise VMMDomainException(("Domain doesn't exist yet.", ERR.NO_SUCH_DOMAIN)) - def updateTransport(self, transport): + def updateTransport(self, transport, force = False): """Sets a new transport for the domain. Keyword arguments: transport -- the new transport (str) + force -- True/False force new transport for all accounts (bool) """ if self._id > 0: trsp = Transport(self._dbh, transport=transport) @@ -166,6 +167,11 @@ self._id) if dbc.rowcount > 0: self._dbh.commit() + if force: + dbc.execute("UPDATE users SET tid=%s WHERE gid=%s", + trsp.getID(), self._id) + if dbc.rowcount > 0: + self._dbh.commit() dbc.close() else: raise VMMDomainException(("Domain doesn't exist yet.", diff -r fe9be0081e5f -r c98e08791ee8 VirtualMailManager/VirtualMailManager.py --- a/VirtualMailManager/VirtualMailManager.py Tue Apr 15 01:28:34 2008 +0000 +++ b/VirtualMailManager/VirtualMailManager.py Tue Apr 15 02:49:21 2008 +0000 @@ -414,13 +414,19 @@ dom.save() self.__domdirmake(dom.getDir(), dom.getID()) - def domain_transport(self, domainname, transport): + def domain_transport(self, domainname, transport, force=None): + if force is not None and force != 'force': + raise VMMDomainException(('Invalid argument: »%s«' % force, + ERR.INVALID_OPTION)) dom = self.__getDomain(domainname, None) - dom.updateTransport(transport) + if force is None: + dom.updateTransport(transport) + else: + dom.updateTransport(transport, force=True) def domain_delete(self, domainname, force=None): if not force is None and force not in ['deluser','delalias','delall']: - raise VMMDomainException(('Invalid argument: «%s»' % force, + raise VMMDomainException(('Invalid argument: »%s«' % force, ERR.INVALID_OPTION)) dom = self.__getDomain(domainname) gid = dom.getID() diff -r fe9be0081e5f -r c98e08791ee8 vmm --- a/vmm Tue Apr 15 01:28:34 2008 +0000 +++ b/vmm Tue Apr 15 02:49:21 2008 +0000 @@ -32,12 +32,13 @@ da domainadd domain.tld transport* di domaininfo domain.tld detailed* - dt domaintransport domain.tld transport + dt domaintransport domain.tld transport force* dd domaindelete domain.tld delalias*|deluser*|delall* ua useradd user@domain.tld password* ui userinfo user@domain.tld du* un username user@domain.tld 'Users Name' up userpassword user@domain.tld password* + ut usertransport user@domain.tld transport u0 userdisable user@domain.tld u1 userenable user@domain.tld ud userdelete user@domain.tld @@ -154,8 +155,10 @@ usage(EXIT.MISSING_ARGS, 'Missing domain name and new transport.') if argc < 4: usage(EXIT.MISSING_ARGS, 'Missing new transport.') + elif argc < 5: + vmm.domain_transport(sys.argv[2].lower(), sys.argv[3]) else: - vmm.domain_transport(sys.argv[2].lower(), sys.argv[3]) + vmm.domain_transport(sys.argv[2].lower(), sys.argv[3], sys.argv[4]) def user_add(): global argc