Commit 76d5d3a3 authored by Iustin Pop's avatar Iustin Pop
Browse files

Automatically fill in missing UUIDs

The patch also starts using the current UUIDs (in the new attributes)
while computing the _AllIDs list.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent e1dcc53a
......@@ -175,6 +175,7 @@ class ConfigWriter:
existing.update([i.uuid for i in self._AllUUIDObjects() if i.uuid])
return existing
@locking.ssynchronized(_config_lock, shared=1)
......@@ -1057,6 +1058,14 @@ class ConfigWriter:
self._config_data.serial_no += 1
self._config_data.mtime = time.time()
def _AllUUIDObjects(self):
"""Returns all objects with uuid attributes.
return (self._config_data.instances.values() +
self._config_data.nodes.values() +
def _OpenConfig(self):
"""Read the config data from disk.
......@@ -1084,6 +1093,28 @@ class ConfigWriter:
# ssconf update
self._last_cluster_serial = -1
# And finally run our (custom) config upgrade sequence
def _UpgradeConfig(self):
"""Run upgrade steps that cannot be done purely in the objects.
This is because some data elements need uniqueness across the
whole configuration, etc.
@warning: this function will call L{_WriteConfig()}, so it needs
to either be called with the lock held or from a safe place
(the constructor)
modified = False
for item in self._AllUUIDObjects():
if item.uuid is None:
item.uuid = self.GenerateUniqueID()
modified = True
if modified:
def _DistributeConfig(self):
"""Distribute the configuration to the other nodes.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment