diff --git a/lib/backend.py b/lib/backend.py index fc6fca7c932a97fe07be8350196285a18e1aab1b..5392efdcc39356d5eedc25218a36a53c46e3ca95 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -166,7 +166,7 @@ def _BuildUploadFileList(): ]) for hv_name in constants.HYPER_TYPES: - hv_class = hypervisor.GetHypervisor(hv_name) + hv_class = hypervisor.GetHypervisorClass(hv_name) allowed_files.update(hv_class.GetAncillaryFiles()) return frozenset(allowed_files) diff --git a/lib/hypervisor/__init__.py b/lib/hypervisor/__init__.py index 83604022d553430a3a55dc5f37c0ec8498e4d7f4..453286c072441264bb71beb0e67b419180452f95 100644 --- a/lib/hypervisor/__init__.py +++ b/lib/hypervisor/__init__.py @@ -39,11 +39,11 @@ _HYPERVISOR_MAP = { } -def GetHypervisor(ht_kind): - """Return a Hypervisor instance. +def GetHypervisorClass(ht_kind): + """Return a Hypervisor class. - This function parses the cluster hypervisor configuration file and - instantiates a class based on the value of this file. + This function returns the hypervisor class corresponding to the + given hypervisor name. @type ht_kind: string @param ht_kind: The requested hypervisor type @@ -53,4 +53,19 @@ def GetHypervisor(ht_kind): raise errors.HypervisorError("Unknown hypervisor type '%s'" % ht_kind) cls = _HYPERVISOR_MAP[ht_kind] + return cls + + +def GetHypervisor(ht_kind): + """Return a Hypervisor instance. + + This is a wrapper over L{GetHypervisorClass} which returns an + instance of the class. + + @type ht_kind: string + @param ht_kind: The requested hypervisor type + + """ + cls = GetHypervisorClass(ht_kind) + return cls()