-remove unnecessary code
[tests.git] / qaapi / qa / modules / plc / configure.py
1
2 import os, sys
3 import traceback
4 from qa.Test import Test
5 from qa import utils
6
7 class configure(Test):
8     """
9     Configure the myplc from config options in config file
10     """
11
12     def call(self, system_type, root_dir):
13         tmpname = '/tmp/plc-cinfig-tty-%d' % os.getpid()
14         fileconf = open(tmpname, 'w')
15         for var in [ 'PLC_NAME',
16                      'PLC_ROOT_PASSWORD',
17                      'PLC_ROOT_USER',
18                      'PLC_MAIL_ENABLED',
19                      'PLC_MAIL_SUPPORT_ADDRESS',
20                      'PLC_DB_HOST',
21                      'PLC_API_HOST',
22                      'PLC_WWW_HOST',
23                      'PLC_BOOT_HOST',
24                      'PLC_NET_DNS1',
25                      'PLC_NET_DNS2']:
26             fileconf.write('e %s\n%s\n' % (var, self.config[var]))
27         fileconf.write('w\nq\n')
28         fileconf.close()
29
30         full_command = ""
31         if system_type in ['vserv', 'vserver']:
32             full_command += " vserver %(root_dir)s exec "
33         elif system_type in ['chroot']:
34             full_commnd += " chroot %(root_dir)s "
35         else:
36             raise Exception, "Invalid system type %(sytem_type)s" % locals()
37
38         full_command = full_command + " plc-config-tty < %(tmpname)s" % locals()                
39         (stdout, stderr) = utils.popen(full_command)
40         (stdout, stderr) = utils.popen("rm %s" % tmpname)
41
42         return 1