harness_standalone.py revision c3758585e3457b7e2ae9c6f7a5645dc801b46475
1"""The standalone harness interface
2
3The default interface as required for the standalone reboot helper.
4"""
5
6__author__ = """Copyright Andy Whitcroft 2007"""
7
8from autotest_lib.client.common_lib import utils
9import os, harness, shutil
10
11class harness_standalone(harness.harness):
12    """The standalone server harness
13
14    Properties:
15            job
16                    The job object for this job
17    """
18
19    def __init__(self, job):
20        """
21                job
22                        The job object for this job
23        """
24        self.autodir = os.path.abspath(os.environ['AUTODIR'])
25        self.setup(job)
26
27        src = job.control_get()
28        dest = os.path.join(self.autodir, 'control')
29        if os.path.abspath(src) != os.path.abspath(dest):
30            shutil.copyfile(src, dest)
31            job.control_set(dest)
32
33        print 'Symlinking init scripts'
34        rc = os.path.join(self.autodir, 'tools/autotest')
35        # see if system supports event.d versus inittab
36        if os.path.exists('/etc/event.d'):
37            # NB: assuming current runlevel is default
38            initdefault = utils.system_output('/sbin/runlevel').split()[1]
39        else:
40            initdefault = utils.system_output('grep :initdefault: /etc/inittab')
41            initdefault = initdefault.split(':')[1]
42
43        try:
44            utils.system('ln -sf %s /etc/init.d/autotest' % rc)
45            utils.system('ln -sf %s /etc/rc%s.d/S99autotest' % (rc,initdefault))
46        except:
47            print "WARNING: linking init scripts failed"
48