Get rid of httperror module
[ganeti-local] / lib / hypervisor / hv_base.py
1 #
2 #
3
4 # Copyright (C) 2006, 2007, 2008 Google Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21
22 """Base class for all hypervisors
23
24 """
25
26 class BaseHypervisor(object):
27   """Abstract virtualisation technology interface
28
29   The goal is that all aspects of the virtualisation technology must
30   be abstracted away from the rest of code.
31
32   """
33   def __init__(self):
34     pass
35
36   def StartInstance(self, instance, block_devices, extra_args):
37     """Start an instance."""
38     raise NotImplementedError
39
40   def StopInstance(self, instance, force=False):
41     """Stop an instance."""
42     raise NotImplementedError
43
44   def RebootInstance(self, instance):
45     """Reboot an instance."""
46     raise NotImplementedError
47
48   def ListInstances(self):
49     """Get the list of running instances."""
50     raise NotImplementedError
51
52   def GetInstanceInfo(self, instance_name):
53     """Get instance properties.
54
55     Args:
56       instance_name: the instance name
57
58     Returns:
59       (name, id, memory, vcpus, state, times)
60
61     """
62     raise NotImplementedError
63
64   def GetAllInstancesInfo(self):
65     """Get properties of all instances.
66
67     Returns:
68       [(name, id, memory, vcpus, stat, times),...]
69     """
70     raise NotImplementedError
71
72   def GetNodeInfo(self):
73     """Return information about the node.
74
75     The return value is a dict, which has to have the following items:
76       (all values in MiB)
77       - memory_total: the total memory size on the node
78       - memory_free: the available memory on the node for instances
79       - memory_dom0: the memory used by the node itself, if available
80
81     """
82     raise NotImplementedError
83
84   @staticmethod
85   def GetShellCommandForConsole(instance):
86     """Return a command for connecting to the console of an instance.
87
88     """
89     raise NotImplementedError
90
91   def Verify(self):
92     """Verify the hypervisor.
93
94     """
95     raise NotImplementedError
96
97   def MigrateInstance(self, name, target, live):
98     """Migrate an instance.
99
100     Arguments:
101       - name: the name of the instance
102       - target: the target of the migration (usually will be IP and not name)
103       - live: whether to do live migration or not
104
105     Returns: none, errors will be signaled by exception.
106
107     """
108     raise NotImplementedError