Add the master/vm_capable flags to objects
authorIustin Pop <iustin@google.com>
Tue, 26 Oct 2010 12:05:56 +0000 (14:05 +0200)
committerIustin Pop <iustin@google.com>
Wed, 27 Oct 2010 10:46:00 +0000 (12:46 +0200)
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
lib/config.py
lib/objects.py

index d5731ac..be4ccdd 100644 (file)
@@ -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)
 
index 3276795..ef37882 100644 (file)
@@ -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
index 4bdd245..768bf99 100644 (file)
@@ -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."""