mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 1 | #!/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), |
| 11 | poirier@google.com (Benjamin Poirier), |
| 12 | stutsman@google.com (Ryan Stutsman)""" |
| 13 | |
| 14 | |
| 15 | import os |
| 16 | import os.path |
| 17 | import time |
| 18 | import urllib |
| 19 | |
| 20 | import kernel |
| 21 | import errors |
| 22 | import utils |
| 23 | |
| 24 | |
| 25 | class 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 | |
mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 38 | def install(self, host): |
| 39 | # this directory will get cleaned up for us automatically |
| 40 | remote_tmpdir = host.get_tmp_dir() |
mbligh | c8949b8 | 2007-07-23 16:33:58 +0000 | [diff] [blame] | 41 | basename = os.path.basename(self.source_material) |
mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 42 | remote_filename = os.path.join(remote_tmpdir, basename) |
mbligh | c8949b8 | 2007-07-23 16:33:58 +0000 | [diff] [blame] | 43 | host.send_file(self.source_material, remote_filename) |
mbligh | dcd57a8 | 2007-07-11 23:06:47 +0000 | [diff] [blame] | 44 | 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') |