Use default values for unset HVM instance attributes.
authorAlexander Schreiber <als@google.com>
Mon, 9 Jun 2008 10:01:28 +0000 (10:01 +0000)
committerAlexander Schreiber <als@google.com>
Mon, 9 Jun 2008 10:01:28 +0000 (10:01 +0000)
This patch is intended reduce the update friction for those who used
HVM with the Ganeti 1.2.3 version. Newly introduced HVM instance flags
will be unset for existing HVM instances after the upgrade. Those unset
flags will be treated as set to the previously hardcoded values where
this makes sense (ACPI and PAE flags).

Reviewed-by: iustinp

lib/constants.py
lib/hypervisor.py

index 69929dd..6aa91da 100644 (file)
@@ -165,6 +165,8 @@ HTS_REQ_PORT = frozenset([HT_XEN_HVM31])
 
 HT_HVM_VNC_BASE_PORT = 5900
 HT_HVM_DEFAULT_BOOT_ORDER = 'dc'
+HT_HVM_DEFAULT_ACPI_MODE = '1'
+HT_HVM_DEFAULT_PAE_MODE = '1'
 VNC_PASSWORD_FILE = _autoconf.SYSCONFDIR + "/ganeti/vnc-cluster-password"
 VNC_DEFAULT_BIND_ADDRESS = '0.0.0.0'
 
index ad24d15..ef15055 100644 (file)
@@ -603,11 +603,15 @@ class XenHvmHypervisor(XenHypervisor):
     config.write("memory = %d\n" % instance.memory)
     config.write("vcpus = %d\n" % instance.vcpus)
     config.write("name = '%s'\n" % instance.name)
-    if instance.hvm_pae:
+    if instance.hvm_pae is None:   # use default value if not specified
+      config.write("pae = %s\n" % constants.HT_HVM_DEFAULT_PAE_MODE)
+    elif instance.hvm_pae:
       config.write("pae = 1\n")
     else:
       config.write("pae = 0\n")
-    if instance.hvm_acpi:
+    if instance.hvm_acpi is None:  # use default value if not specified
+      config.write("acpi = %s\n" % constants.HT_HVM_DEFAULT_ACPI_MODE)
+    elif instance.hvm_acpi:
       config.write("acpi = 1\n")
     else:
       config.write("acpi = 0\n")