Skip to content
Snippets Groups Projects
Commit 26b316d0 authored by Iustin Pop's avatar Iustin Pop
Browse files

Separate the computation of all config IDs


We will need this in another place, so we abstract the 'compute all
current IDs' functionality into a separate function. We also change the
name of the _ComputeAllLVs to _AllLVs to match the other _All*s
functions.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
(cherry picked from commit 34e54ebc)
parent 2d90608c
No related branches found
No related tags found
No related merge requests found
...@@ -148,7 +148,7 @@ class ConfigWriter: ...@@ -148,7 +148,7 @@ class ConfigWriter:
raise errors.ConfigurationError("Can't generate unique DRBD secret") raise errors.ConfigurationError("Can't generate unique DRBD secret")
return secret return secret
def _ComputeAllLVs(self): def _AllLVs(self):
"""Compute the list of all LVs. """Compute the list of all LVs.
""" """
...@@ -159,6 +159,23 @@ class ConfigWriter: ...@@ -159,6 +159,23 @@ class ConfigWriter:
lvnames.update(lv_list) lvnames.update(lv_list)
return lvnames return lvnames
def _AllIDs(self, include_temporary):
"""Compute the list of all UUIDs and names we have.
@type include_temporary: boolean
@param include_temporary: whether to include the _temporary_ids set
@rtype: set
@return: a set of IDs
"""
existing = set()
if include_temporary:
existing.update(self._temporary_ids)
existing.update(self._AllLVs())
existing.update(self._config_data.instances.keys())
existing.update(self._config_data.nodes.keys())
return existing
@locking.ssynchronized(_config_lock, shared=1) @locking.ssynchronized(_config_lock, shared=1)
def GenerateUniqueID(self, exceptions=None): def GenerateUniqueID(self, exceptions=None):
"""Generate an unique disk name. """Generate an unique disk name.
...@@ -175,11 +192,7 @@ class ConfigWriter: ...@@ -175,11 +192,7 @@ class ConfigWriter:
@return: the unique id @return: the unique id
""" """
existing = set() existing = self._AllIDs(include_temporary=True)
existing.update(self._temporary_ids)
existing.update(self._ComputeAllLVs())
existing.update(self._config_data.instances.keys())
existing.update(self._config_data.nodes.keys())
if exceptions is not None: if exceptions is not None:
existing.update(exceptions) existing.update(exceptions)
retries = 64 retries = 64
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment