blob: a8c1471e36a5a6f9df39483b7010063c571743ad [file] [log] [blame]
mblighdcd57a82007-07-11 23:06:47 +00001#!/usr/bin/python
2#
3# Copyright 2007 Google Inc. Released under the GPL v2
4
5"""This module defines the Kernel class
6
7 Kernel: an os kernel
8"""
9
10__author__ = """mbligh@google.com (Martin J. Bligh),
11poirier@google.com (Benjamin Poirier),
12stutsman@google.com (Ryan Stutsman)"""
13
14
15import os
16import os.path
17import time
18import urllib
19
20import kernel
21import errors
22import utils
23
24
25class DEBKernel(kernel.Kernel):
26 """This class represents a .deb pre-built kernel.
27
28 It is used to obtain a built kernel and install it on a Host.
29
30 Implementation details:
31 This is a leaf class in an abstract class hierarchy, it must
32 implement the unimplemented methods in parent classes.
33 """
34 def __init__(self):
35 super(DEBKernel, self).__init__()
36
37
mblighdcd57a82007-07-11 23:06:47 +000038 def install(self, host):
39 # this directory will get cleaned up for us automatically
40 remote_tmpdir = host.get_tmp_dir()
mblighc8949b82007-07-23 16:33:58 +000041 basename = os.path.basename(self.source_material)
mblighdcd57a82007-07-11 23:06:47 +000042 remote_filename = os.path.join(remote_tmpdir, basename)
mblighc8949b82007-07-23 16:33:58 +000043 host.send_file(self.source_material, remote_filename)
mblighdcd57a82007-07-11 23:06:47 +000044 try:
45 result = host.run('dpkg -i %s'
46 % remote_filename)
47 if result.exit_status:
48 raise AutoservError('dpkg failed \
49 installing %s:\n\n%s'% (remote_filename,
50 result.stderr))
51 except NameError, e:
52 raise AutoservError('A kernel must first be \
53 specified via get_from_file or get_from_url')