4 # Copyright (C) 2006, 2007, 2008 Google Inc.
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.
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.
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
22 """Base class for all hypervisors
26 class BaseHypervisor(object):
27 """Abstract virtualisation technology interface
29 The goal is that all aspects of the virtualisation technology must
30 be abstracted away from the rest of code.
36 def StartInstance(self, instance, block_devices, extra_args):
37 """Start an instance."""
38 raise NotImplementedError
40 def StopInstance(self, instance, force=False):
41 """Stop an instance."""
42 raise NotImplementedError
44 def RebootInstance(self, instance):
45 """Reboot an instance."""
46 raise NotImplementedError
48 def ListInstances(self):
49 """Get the list of running instances."""
50 raise NotImplementedError
52 def GetInstanceInfo(self, instance_name):
53 """Get instance properties.
56 instance_name: the instance name
59 (name, id, memory, vcpus, state, times)
62 raise NotImplementedError
64 def GetAllInstancesInfo(self):
65 """Get properties of all instances.
68 [(name, id, memory, vcpus, stat, times),...]
70 raise NotImplementedError
72 def GetNodeInfo(self):
73 """Return information about the node.
75 The return value is a dict, which has to have the following items:
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
82 raise NotImplementedError
85 def GetShellCommandForConsole(instance):
86 """Return a command for connecting to the console of an instance.
89 raise NotImplementedError
92 """Verify the hypervisor.
95 raise NotImplementedError
97 def MigrateInstance(self, name, target, live):
98 """Migrate an instance.
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
105 Returns: none, errors will be signaled by exception.
108 raise NotImplementedError