Add hypervisors ancillary files list
authorGuido Trotter <ultrotter@google.com>
Tue, 18 Oct 2011 15:43:44 +0000 (16:43 +0100)
committerGuido Trotter <ultrotter@google.com>
Thu, 20 Oct 2011 12:04:30 +0000 (13:04 +0100)
These lists will be used to declare some of the files not necessarily
needed on all nodes. The files selected are files without which the
various hypervisors can still work, but that when they are present
should be synchronized across the cluster (or node group).

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/backend.py
lib/cmdlib.py
lib/hypervisor/hv_base.py
lib/hypervisor/hv_kvm.py
lib/hypervisor/hv_xen.py

index 98d61ef..57b31a9 100644 (file)
@@ -203,7 +203,7 @@ def _BuildUploadFileList():
 
   for hv_name in constants.HYPER_TYPES:
     hv_class = hypervisor.GetHypervisorClass(hv_name)
-    allowed_files.update(hv_class.GetAncillaryFiles())
+    allowed_files.update(hv_class.GetAncillaryFiles()[0])
 
   return frozenset(allowed_files)
 
index 7d12689..6151ddb 100644 (file)
@@ -3760,7 +3760,7 @@ def _ComputeAncillaryFiles(cluster, redist):
   # Files which should only be on VM-capable nodes
   files_vm = set(filename
     for hv_name in cluster.enabled_hypervisors
-    for filename in hypervisor.GetHypervisor(hv_name).GetAncillaryFiles())
+    for filename in hypervisor.GetHypervisor(hv_name).GetAncillaryFiles()[0])
 
   # Filenames must be unique
   assert (len(files_all | files_all_opt | files_mc | files_vm) ==
index 7c4b1b5..5fe1978 100644 (file)
@@ -133,6 +133,7 @@ class BaseHypervisor(object):
   """
   PARAMETERS = {}
   ANCILLARY_FILES = []
+  ANCILLARY_FILES_OPT = []
   CAN_MIGRATE = False
 
   def __init__(self):
@@ -221,13 +222,16 @@ class BaseHypervisor(object):
     """Return a list of ancillary files to be copied to all nodes as ancillary
     configuration files.
 
-    @rtype: list of strings
-    @return: list of absolute paths of files to ship cluster-wide
+    @rtype: (list of absolute paths, list of absolute paths)
+    @return: (all files, optional files)
 
     """
     # By default we return a member variable, so that if an hypervisor has just
     # a static list of files it doesn't have to override this function.
-    return cls.ANCILLARY_FILES
+    assert set(cls.ANCILLARY_FILES).issuperset(cls.ANCILLARY_FILES_OPT), \
+      "Optional ancillary files must be a subset of ancillary files"
+
+    return (cls.ANCILLARY_FILES, cls.ANCILLARY_FILES_OPT)
 
   def Verify(self):
     """Verify the hypervisor.
index c4b05b1..ccf9f7d 100644 (file)
@@ -475,6 +475,9 @@ class KVMHypervisor(hv_base.BaseHypervisor):
   ANCILLARY_FILES = [
     _KVM_NETWORK_SCRIPT,
     ]
+  ANCILLARY_FILES_OPT = [
+    _KVM_NETWORK_SCRIPT,
+    ]
 
   def __init__(self):
     hv_base.BaseHypervisor.__init__(self)
index 3468fbe..ffeb017 100644 (file)
@@ -55,6 +55,9 @@ class XenHypervisor(hv_base.BaseHypervisor):
     XL_CONFIG_FILE,
     VIF_BRIDGE_SCRIPT,
     ]
+  ANCILLARY_FILES_OPT = [
+    XL_CONFIG_FILE,
+    ]
 
   @staticmethod
   def _ConfigFileName(instance_name):
@@ -589,6 +592,9 @@ class XenHvmHypervisor(XenHypervisor):
   ANCILLARY_FILES = XenHypervisor.ANCILLARY_FILES + [
     constants.VNC_PASSWORD_FILE,
     ]
+  ANCILLARY_FILES_OPT = XenHypervisor.ANCILLARY_FILES_OPT + [
+    constants.VNC_PASSWORD_FILE,
+    ]
 
   PARAMETERS = {
     constants.HV_ACPI: hv_base.NO_CHECK,