Statistics
| Branch: | Tag: | Revision:

root / lib / hypervisor / __init__.py @ b74159ee

History | View | Annotate | Download (1.5 kB)

1 65a6f9b7 Michael Hanselmann
#
2 65a6f9b7 Michael Hanselmann
#
3 65a6f9b7 Michael Hanselmann
4 65a6f9b7 Michael Hanselmann
# Copyright (C) 2006, 2007, 2008 Google Inc.
5 65a6f9b7 Michael Hanselmann
#
6 65a6f9b7 Michael Hanselmann
# This program is free software; you can redistribute it and/or modify
7 65a6f9b7 Michael Hanselmann
# it under the terms of the GNU General Public License as published by
8 65a6f9b7 Michael Hanselmann
# the Free Software Foundation; either version 2 of the License, or
9 65a6f9b7 Michael Hanselmann
# (at your option) any later version.
10 65a6f9b7 Michael Hanselmann
#
11 65a6f9b7 Michael Hanselmann
# This program is distributed in the hope that it will be useful, but
12 65a6f9b7 Michael Hanselmann
# WITHOUT ANY WARRANTY; without even the implied warranty of
13 65a6f9b7 Michael Hanselmann
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 65a6f9b7 Michael Hanselmann
# General Public License for more details.
15 65a6f9b7 Michael Hanselmann
#
16 65a6f9b7 Michael Hanselmann
# You should have received a copy of the GNU General Public License
17 65a6f9b7 Michael Hanselmann
# along with this program; if not, write to the Free Software
18 65a6f9b7 Michael Hanselmann
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 65a6f9b7 Michael Hanselmann
# 02110-1301, USA.
20 65a6f9b7 Michael Hanselmann
21 65a6f9b7 Michael Hanselmann
22 65a6f9b7 Michael Hanselmann
"""Virtualization interface abstraction
23 65a6f9b7 Michael Hanselmann

24 65a6f9b7 Michael Hanselmann
"""
25 65a6f9b7 Michael Hanselmann
26 65a6f9b7 Michael Hanselmann
from ganeti import ssconf
27 65a6f9b7 Michael Hanselmann
from ganeti import constants
28 65a6f9b7 Michael Hanselmann
from ganeti import errors
29 65a6f9b7 Michael Hanselmann
30 65a6f9b7 Michael Hanselmann
from ganeti.hypervisor import FakeHypervisor
31 65a6f9b7 Michael Hanselmann
from ganeti.hypervisor import XenHypervisor
32 65a6f9b7 Michael Hanselmann
33 65a6f9b7 Michael Hanselmann
34 65a6f9b7 Michael Hanselmann
def GetHypervisor():
35 65a6f9b7 Michael Hanselmann
  """Return a Hypervisor instance.
36 65a6f9b7 Michael Hanselmann

37 65a6f9b7 Michael Hanselmann
  This function parses the cluster hypervisor configuration file and
38 65a6f9b7 Michael Hanselmann
  instantiates a class based on the value of this file.
39 65a6f9b7 Michael Hanselmann

40 65a6f9b7 Michael Hanselmann
  """
41 65a6f9b7 Michael Hanselmann
  ht_kind = ssconf.SimpleStore().GetHypervisorType()
42 65a6f9b7 Michael Hanselmann
  if ht_kind == constants.HT_XEN_PVM30:
43 65a6f9b7 Michael Hanselmann
    cls = XenHypervisor.XenPvmHypervisor
44 65a6f9b7 Michael Hanselmann
  elif ht_kind == constants.HT_XEN_HVM31:
45 65a6f9b7 Michael Hanselmann
    cls = XenHypervisor.XenHvmHypervisor
46 65a6f9b7 Michael Hanselmann
  elif ht_kind == constants.HT_FAKE:
47 65a6f9b7 Michael Hanselmann
    cls = FakeHypervisor.FakeHypervisor
48 65a6f9b7 Michael Hanselmann
  else:
49 65a6f9b7 Michael Hanselmann
    raise errors.HypervisorError("Unknown hypervisor type '%s'" % ht_kind)
50 65a6f9b7 Michael Hanselmann
  return cls()