From 490acd18fa39b82af4509ef420e70aed8f557c29 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Tue, 26 Oct 2010 14:05:56 +0200 Subject: [PATCH] Add the master/vm_capable flags to objects This adds the flag and some initial handling. The rest of the changes, for cmdlib, come in a separate patch. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/cmdlib.py | 2 ++ lib/config.py | 4 ++-- lib/objects.py | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index d5731ace2..be4ccddae 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3703,6 +3703,8 @@ class LUAddNode(LogicalUnit): primary_ip=primary_ip, secondary_ip=secondary_ip, master_candidate=self.master_candidate, + master_capable=True, + vm_capable=True, offline=False, drained=False, group=node_group) diff --git a/lib/config.py b/lib/config.py index 3276795f1..ef37882e5 100644 --- a/lib/config.py +++ b/lib/config.py @@ -1198,7 +1198,7 @@ class ConfigWriter: for node in self._config_data.nodes.values(): if exceptions and node.name in exceptions: continue - if not (node.offline or node.drained): + if not (node.offline or node.drained) and node.master_capable: mc_max += 1 if node.master_candidate: mc_now += 1 @@ -1239,7 +1239,7 @@ class ConfigWriter: break node = self._config_data.nodes[name] if (node.master_candidate or node.offline or node.drained or - node.name in exceptions): + node.name in exceptions or not node.master_capable): continue mod_list.append(node) node.master_candidate = True diff --git a/lib/objects.py b/lib/objects.py index 4bdd245bb..768bf99de 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -940,8 +940,22 @@ class Node(TaggableObject): "offline", "drained", "group", + "master_capable", + "vm_capable", ] + _TIMESTAMPS + _UUID + def UpgradeConfig(self): + """Fill defaults for missing configuration values. + + """ + # pylint: disable-msg=E0203 + # because these are "defined" via slots, not manually + if self.master_capable is None: + self.master_capable = True + + if self.vm_capable is None: + self.vm_capable = True + class NodeGroup(ConfigObject): """Config object representing a node group.""" -- GitLab