Commit e5a45a16 authored by Iustin Pop's avatar Iustin Pop
Browse files

Fix backend import errors from GetHypervisorClass

The merge of commit 360b0dc2

 into branch-2.1 broke import of backend,
since it uses hypervisor.GetHypervisor() which returns an instance of
the hypervisor. Some of the hypervisors create directories at init time,
thus the import of backend failed due this chain if it's not done on a
(proper) ganeti node, such as during unittest time.

This patch adds in hypervisor a GetHypervisorClass() function, which
returns the class not the instance of the hypervisor, and uses that in
_BuildUploadFiles(). The existing GetHypervisor is then changed to use
this function.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent b397a7d2
......@@ -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)
......
......@@ -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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment