harness.py revision 4046d5c5493e70406963fb29f69cca8c789fb095
1"""The harness interface
2
3The interface between the client and the server when hosted.
4"""
5
6__author__ = """Copyright Andy Whitcroft 2006"""
7
8import os, sys
9
10class harness(object):
11    """The NULL server harness
12
13    Properties:
14            job
15                    The job object for this job
16    """
17
18    def __init__(self, job):
19        """
20                job
21                        The job object for this job
22        """
23        self.setup(job)
24
25
26    def setup(self, job):
27        """
28                job
29                        The job object for this job
30        """
31        self.job = job
32
33        configd = os.path.join(os.environ['AUTODIR'], 'configs')
34        if os.path.isdir(configd):
35            (name, dirs, files) = os.walk(configd).next()
36            job.config_set('kernel.default_config_set',
37                           [ configd + '/' ] + files)
38
39
40    def run_start(self):
41        """A run within this job is starting"""
42        pass
43
44
45    def run_pause(self):
46        """A run within this job is completing (expect continue)"""
47        pass
48
49
50    def run_reboot(self):
51        """A run within this job is performing a reboot
52           (expect continue following reboot)
53        """
54        pass
55
56
57    def run_abort(self):
58        """A run within this job is aborting. It all went wrong"""
59        pass
60
61
62    def run_complete(self):
63        """A run within this job is completing (all done)"""
64        pass
65
66
67    def test_status(self, status, tag):
68        """A test within this job is completing"""
69        pass
70
71
72    def test_status_detail(self, code, subdir, operation, status, tag):
73        """A test within this job is completing (detail)"""
74        pass
75
76
77def select(which, job):
78    if not which:
79        which = 'standalone'
80
81    harness_name = 'harness_%s' % which
82    harness_module = __import__(harness_name)
83    harness_instance = getattr(harness_module, harness_name)(job)
84
85    return harness_instance
86