Revision 664fbc9d lib/config.py
b/lib/config.py | ||
---|---|---|
177 | 177 |
existing.update([i.uuid for i in self._AllUUIDObjects() if i.uuid]) |
178 | 178 |
return existing |
179 | 179 |
|
180 |
def _GenerateUniqueID(self, exceptions=None):
|
|
180 |
def _GenerateUniqueID(self): |
|
181 | 181 |
"""Generate an unique UUID. |
182 | 182 |
|
183 | 183 |
This checks the current node, instances and disk names for |
184 | 184 |
duplicates. |
185 | 185 |
|
186 |
@param exceptions: a list with some other names which should be |
|
187 |
checked for uniqueness (used for example when you want to get |
|
188 |
more than one id at one time without adding each one in turn |
|
189 |
to the config file) |
|
190 |
|
|
191 | 186 |
@rtype: string |
192 | 187 |
@return: the unique id |
193 | 188 |
|
194 | 189 |
""" |
195 | 190 |
existing = self._AllIDs(include_temporary=True) |
196 |
if exceptions is not None: |
|
197 |
existing.update(exceptions) |
|
198 | 191 |
retries = 64 |
199 | 192 |
while retries > 0: |
200 | 193 |
unique_id = utils.NewUUID() |
... | ... | |
207 | 200 |
return unique_id |
208 | 201 |
|
209 | 202 |
@locking.ssynchronized(_config_lock, shared=1) |
210 |
def GenerateUniqueID(self, exceptions=None):
|
|
203 |
def GenerateUniqueID(self): |
|
211 | 204 |
"""Generate an unique ID. |
212 | 205 |
|
213 | 206 |
This is just a wrapper over the unlocked version. |
214 | 207 |
|
215 | 208 |
""" |
216 |
return self._GenerateUniqueID(exceptions=exceptions)
|
|
209 |
return self._GenerateUniqueID() |
|
217 | 210 |
|
218 | 211 |
def _CleanupTemporaryIDs(self): |
219 | 212 |
"""Cleanups the _temporary_ids structure. |
Also available in: Unified diff