From f9e813966f20a385dfa4722a05e18dd09136882f Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Mon, 6 Sep 2010 16:30:10 +0100 Subject: [PATCH] ConfigWriter: create the default node group If no node groups exist we'll create a new default empty one. Signed-off-by: Guido Trotter <ultrotter@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/config.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/config.py b/lib/config.py index 9c1a5b4b5..07bc65575 100644 --- a/lib/config.py +++ b/lib/config.py @@ -1272,6 +1272,15 @@ class ConfigWriter: if item.uuid is None: item.uuid = self._GenerateUniqueID(_UPGRADE_CONFIG_JID) modified = True + if not self._config_data.nodegroups: + default_nodegroup_uuid = self._GenerateUniqueID(_UPGRADE_CONFIG_JID) + default_nodegroup = objects.NodeGroup( + uuid=default_nodegroup_uuid, + name="default", + members=[], + ) + self._config_data.nodegroups[default_nodegroup_uuid] = default_nodegroup + modified = True if modified: self._WriteConfig() # This is ok even if it acquires the internal lock, as _UpgradeConfig is -- GitLab