Add 2.2->2.3 cluster upgrade function
authorManuel Franceschini <livewire@google.com>
Wed, 25 Aug 2010 17:32:58 +0000 (19:32 +0200)
committerManuel Franceschini <livewire@google.com>
Fri, 27 Aug 2010 13:28:21 +0000 (15:28 +0200)
Signed-off-by: Manuel Franceschini <livewire@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

tools/cfgupgrade

index 00dbb22..f1df288 100755 (executable)
@@ -32,6 +32,7 @@ import os.path
 import sys
 import optparse
 import logging
+import socket
 
 from ganeti import constants
 from ganeti import serializer
@@ -70,6 +71,16 @@ def SetupLogging():
   root_logger.addHandler(stderr_handler)
 
 
+def Cluster22To23(cluster):
+  """Upgrades the cluster object from 2.2 to 2.3.
+
+  """
+  logging.info("Upgrading the cluster object")
+  if "primary_ip_family" not in cluster:
+    # Add primary ip family to config
+    cluster["primary_ip_family"] = socket.AF_INET
+
+
 def main():
   """Main program.
 
@@ -150,6 +161,8 @@ def main():
 
   elif config_major == 2 and config_minor == 2:
     logging.info("No changes necessary")
+    # TODO: For Ganeti 2.3 uncomment the following line
+    # Cluster22To23(config_data["cluster"])
 
   else:
     raise Error("Configuration version %d.%d.%d not supported by this tool" %