X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/00cd937c3b2428494d6a612e0614aad2e92262e9..9dd6889ba89836fe85de9ecee5c554909ce20aa5:/lib/hypervisor/__init__.py diff --git a/lib/hypervisor/__init__.py b/lib/hypervisor/__init__.py index 8360402..e1b39ba 100644 --- a/lib/hypervisor/__init__.py +++ b/lib/hypervisor/__init__.py @@ -29,21 +29,25 @@ from ganeti import errors from ganeti.hypervisor import hv_fake from ganeti.hypervisor import hv_xen from ganeti.hypervisor import hv_kvm +from ganeti.hypervisor import hv_chroot +from ganeti.hypervisor import hv_lxc _HYPERVISOR_MAP = { - constants.HT_XEN_PVM: hv_xen.XenPvmHypervisor, - constants.HT_XEN_HVM: hv_xen.XenHvmHypervisor, - constants.HT_FAKE: hv_fake.FakeHypervisor, - constants.HT_KVM: hv_kvm.KVMHypervisor, - } + constants.HT_XEN_PVM: hv_xen.XenPvmHypervisor, + constants.HT_XEN_HVM: hv_xen.XenHvmHypervisor, + constants.HT_FAKE: hv_fake.FakeHypervisor, + constants.HT_KVM: hv_kvm.KVMHypervisor, + constants.HT_CHROOT: hv_chroot.ChrootManager, + constants.HT_LXC: hv_lxc.LXCHypervisor, + } -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 +57,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()