equal
deleted
inserted
replaced
114 if not delAlias: |
114 if not delAlias: |
115 hasAlias = self._has('alias') |
115 hasAlias = self._has('alias') |
116 else: |
116 else: |
117 hasAlias = False |
117 hasAlias = False |
118 if hasUser and hasAlias: |
118 if hasUser and hasAlias: |
119 raise VMMDomainException(('There are accounts and aliases.', |
119 raise VMMDomainException((_('There are accounts and aliases.'), |
120 ERR.ACCOUNT_AND_ALIAS_PRESENT)) |
120 ERR.ACCOUNT_AND_ALIAS_PRESENT)) |
121 elif hasUser: |
121 elif hasUser: |
122 raise VMMDomainException(('There are accounts.', |
122 raise VMMDomainException((_('There are accounts.'), |
123 ERR.ACCOUNT_PRESENT)) |
123 ERR.ACCOUNT_PRESENT)) |
124 elif hasAlias: |
124 elif hasAlias: |
125 raise VMMDomainException(('There are aliases.', ERR.ALIAS_PRESENT)) |
125 raise VMMDomainException((_('There are aliases.'), |
|
126 ERR.ALIAS_PRESENT)) |
126 |
127 |
127 def save(self): |
128 def save(self): |
128 """Stores the new domain in the database.""" |
129 """Stores the new domain in the database.""" |
129 if self._id < 1: |
130 if self._id < 1: |
130 self._prepare() |
131 self._prepare() |
133 VALUES (%s, %s, %s, %s)", self._id, self._name, self._transport.getID(), |
134 VALUES (%s, %s, %s, %s)", self._id, self._name, self._transport.getID(), |
134 self._domaindir) |
135 self._domaindir) |
135 self._dbh.commit() |
136 self._dbh.commit() |
136 dbc.close() |
137 dbc.close() |
137 else: |
138 else: |
138 raise VMMDomainException(('Domain already exists.', |
139 raise VMMDomainException((_('Domain already exists.'), |
139 ERR.DOMAIN_EXISTS)) |
140 ERR.DOMAIN_EXISTS)) |
140 |
141 |
141 def delete(self, delUser=False, delAlias=False): |
142 def delete(self, delUser=False, delAlias=False): |
142 """Deletes the domain. |
143 """Deletes the domain. |
143 |
144 |
153 dbc.execute('DELETE FROM relocated WHERE gid=%s', self._id) |
154 dbc.execute('DELETE FROM relocated WHERE gid=%s', self._id) |
154 dbc.execute('DELETE FROM domains WHERE gid=%s', self._id) |
155 dbc.execute('DELETE FROM domains WHERE gid=%s', self._id) |
155 self._dbh.commit() |
156 self._dbh.commit() |
156 dbc.close() |
157 dbc.close() |
157 else: |
158 else: |
158 raise VMMDomainException(("Domain doesn't exist yet.", |
159 raise VMMDomainException((_("Domain doesn't exist yet."), |
159 ERR.NO_SUCH_DOMAIN)) |
160 ERR.NO_SUCH_DOMAIN)) |
160 |
161 |
161 def updateTransport(self, transport, force = False): |
162 def updateTransport(self, transport, force = False): |
162 """Sets a new transport for the domain. |
163 """Sets a new transport for the domain. |
163 |
164 |
177 trsp.getID(), self._id) |
178 trsp.getID(), self._id) |
178 if dbc.rowcount > 0: |
179 if dbc.rowcount > 0: |
179 self._dbh.commit() |
180 self._dbh.commit() |
180 dbc.close() |
181 dbc.close() |
181 else: |
182 else: |
182 raise VMMDomainException(("Domain doesn't exist yet.", |
183 raise VMMDomainException((_("Domain doesn't exist yet."), |
183 ERR.NO_SUCH_DOMAIN)) |
184 ERR.NO_SUCH_DOMAIN)) |
184 |
185 |
185 def getID(self): |
186 def getID(self): |
186 """Returns the ID of the domain.""" |
187 """Returns the ID of the domain.""" |
187 return self._id |
188 return self._id |
207 dbc = self._dbh.cursor() |
208 dbc = self._dbh.cursor() |
208 dbc.execute(sql) |
209 dbc.execute(sql) |
209 info = dbc.fetchone() |
210 info = dbc.fetchone() |
210 dbc.close() |
211 dbc.close() |
211 if info is None: |
212 if info is None: |
212 raise VMMDomainException(("Domain doesn't exist yet.", |
213 raise VMMDomainException((_("Domain doesn't exist yet."), |
213 ERR.NO_SUCH_DOMAIN)) |
214 ERR.NO_SUCH_DOMAIN)) |
214 else: |
215 else: |
215 keys = ['gid', 'domainname', 'transport', 'domaindir', 'accounts', |
216 keys = ['gid', 'domainname', 'transport', 'domaindir', 'accounts', |
216 'aliases'] |
217 'aliases'] |
217 return dict(zip(keys, info)) |
218 return dict(zip(keys, info)) |