KVM test: physical_resources_check: Fixing error message
[autotest-zwu.git] / server / source_kernel.py
blobbdd5891b6521768ec6c38699b2f27c1043c8a558
1 # Copyright 2007 Google Inc. Released under the GPL v2
3 """
4 This module defines the SourceKernel class
6 SourceKernel: an linux kernel built from source
7 """
10 from autotest_lib.server import kernel, autotest
13 class SourceKernel(kernel.Kernel):
14 """
15 This class represents a linux kernel built from source.
17 It is used to obtain a built kernel or create one from source and
18 install it on a Host.
20 Implementation details:
21 This is a leaf class in an abstract class hierarchy, it must
22 implement the unimplemented methods in parent classes.
23 """
24 def __init__(self, k):
25 super(kernel.Kernel, self).__init__()
26 self.__kernel = k
27 self.__patch_list = []
28 self.__config_file = None
29 self.__autotest = autotest.Autotest()
32 def configure(self, configFile):
33 self.__config_file = configFile
36 def patch(self, patchFile):
37 self.__patch_list.append(patchFile)
40 def build(self, host):
41 ctlfile = self.__control_file(self.__kernel, self.__patch_list,
42 self.__config_file)
43 self.__autotest.run(ctlfile, host.get_tmp_dir(), host)
46 def install(self, host):
47 self.__autotest.install(host)
48 ctlfile = ("testkernel = job.kernel('%s')\n"
49 "testkernel.install()\n"
50 "testkernel.add_to_bootloader()\n" %(self.__kernel))
51 self.__autotest.run(ctlfile, host.get_tmp_dir(), host)
54 def __control_file(self, kernel, patch_list, config):
55 ctl = ("testkernel = job.kernel('%s')\n" % kernel)
57 if len(patch_list):
58 patches = ', '.join(["'%s'" % x for x in patch_list])
59 ctl += "testkernel.patch(%s)\n" % patches
61 if config:
62 ctl += "testkernel.config('%s')\n" % config
63 else:
64 ctl += "testkernel.config('', None, True)\n"
66 ctl += "testkernel.build()\n"
68 # copy back to server
70 return ctl