Statistics
| Branch: | Tag: | Revision:

root / lib / hypervisor / BaseHypervisor.py @ 65a6f9b7

History | View | Annotate | Download (2.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
"""Base class for all hypervisors
23 65a6f9b7 Michael Hanselmann

24 65a6f9b7 Michael Hanselmann
"""
25 65a6f9b7 Michael Hanselmann
26 65a6f9b7 Michael Hanselmann
class BaseHypervisor(object):
27 65a6f9b7 Michael Hanselmann
  """Abstract virtualisation technology interface
28 65a6f9b7 Michael Hanselmann

29 65a6f9b7 Michael Hanselmann
  The goal is that all aspects of the virtualisation technology must
30 65a6f9b7 Michael Hanselmann
  be abstracted away from the rest of code.
31 65a6f9b7 Michael Hanselmann

32 65a6f9b7 Michael Hanselmann
  """
33 65a6f9b7 Michael Hanselmann
  def __init__(self):
34 65a6f9b7 Michael Hanselmann
    pass
35 65a6f9b7 Michael Hanselmann
36 65a6f9b7 Michael Hanselmann
  def StartInstance(self, instance, block_devices, extra_args):
37 65a6f9b7 Michael Hanselmann
    """Start an instance."""
38 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
39 65a6f9b7 Michael Hanselmann
40 65a6f9b7 Michael Hanselmann
  def StopInstance(self, instance, force=False):
41 65a6f9b7 Michael Hanselmann
    """Stop an instance."""
42 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
43 65a6f9b7 Michael Hanselmann
44 65a6f9b7 Michael Hanselmann
  def RebootInstance(self, instance):
45 65a6f9b7 Michael Hanselmann
    """Reboot an instance."""
46 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
47 65a6f9b7 Michael Hanselmann
48 65a6f9b7 Michael Hanselmann
  def ListInstances(self):
49 65a6f9b7 Michael Hanselmann
    """Get the list of running instances."""
50 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
51 65a6f9b7 Michael Hanselmann
52 65a6f9b7 Michael Hanselmann
  def GetInstanceInfo(self, instance_name):
53 65a6f9b7 Michael Hanselmann
    """Get instance properties.
54 65a6f9b7 Michael Hanselmann

55 65a6f9b7 Michael Hanselmann
    Args:
56 65a6f9b7 Michael Hanselmann
      instance_name: the instance name
57 65a6f9b7 Michael Hanselmann

58 65a6f9b7 Michael Hanselmann
    Returns:
59 65a6f9b7 Michael Hanselmann
      (name, id, memory, vcpus, state, times)
60 65a6f9b7 Michael Hanselmann

61 65a6f9b7 Michael Hanselmann
    """
62 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
63 65a6f9b7 Michael Hanselmann
64 65a6f9b7 Michael Hanselmann
  def GetAllInstancesInfo(self):
65 65a6f9b7 Michael Hanselmann
    """Get properties of all instances.
66 65a6f9b7 Michael Hanselmann

67 65a6f9b7 Michael Hanselmann
    Returns:
68 65a6f9b7 Michael Hanselmann
      [(name, id, memory, vcpus, stat, times),...]
69 65a6f9b7 Michael Hanselmann
    """
70 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
71 65a6f9b7 Michael Hanselmann
72 65a6f9b7 Michael Hanselmann
  def GetNodeInfo(self):
73 65a6f9b7 Michael Hanselmann
    """Return information about the node.
74 65a6f9b7 Michael Hanselmann

75 65a6f9b7 Michael Hanselmann
    The return value is a dict, which has to have the following items:
76 65a6f9b7 Michael Hanselmann
      (all values in MiB)
77 65a6f9b7 Michael Hanselmann
      - memory_total: the total memory size on the node
78 65a6f9b7 Michael Hanselmann
      - memory_free: the available memory on the node for instances
79 65a6f9b7 Michael Hanselmann
      - memory_dom0: the memory used by the node itself, if available
80 65a6f9b7 Michael Hanselmann

81 65a6f9b7 Michael Hanselmann
    """
82 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
83 65a6f9b7 Michael Hanselmann
84 65a6f9b7 Michael Hanselmann
  @staticmethod
85 65a6f9b7 Michael Hanselmann
  def GetShellCommandForConsole(instance):
86 65a6f9b7 Michael Hanselmann
    """Return a command for connecting to the console of an instance.
87 65a6f9b7 Michael Hanselmann

88 65a6f9b7 Michael Hanselmann
    """
89 65a6f9b7 Michael Hanselmann
    raise NotImplementedError
90 65a6f9b7 Michael Hanselmann
91 65a6f9b7 Michael Hanselmann
  def Verify(self):
92 65a6f9b7 Michael Hanselmann
    """Verify the hypervisor.
93 65a6f9b7 Michael Hanselmann

94 65a6f9b7 Michael Hanselmann
    """
95 65a6f9b7 Michael Hanselmann
    raise NotImplementedError