From 4a833992ce2b6339deb96e4181bae5c1b0d4f816 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Wed, 6 Feb 2008 20:38:44 +0000 Subject: [PATCH] accept individual plc_config options --- qaapi/qa/tests/plc_configure.py | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/qaapi/qa/tests/plc_configure.py b/qaapi/qa/tests/plc_configure.py index 4857651..213abf1 100644 --- a/qaapi/qa/tests/plc_configure.py +++ b/qaapi/qa/tests/plc_configure.py @@ -9,24 +9,37 @@ class plc_configure(Test): Configure the myplc from config options in config file """ - def call(self): - + def call(self, plc_config_option=None, plc_config_value=None): + + services = ['API', 'DB', 'WWW', 'BOOT'] + plc_options = [] # Get plc configuration variables - plc_vars = [] - for attr in dir(self.config): - if attr.startswith('PLC'): - plc_vars.append(attr) + if plc_config_option is not None and \ + plc_config_value is not None: + # Set option passed in from user + plc_options.append((plc_config_option, plc_config_value)) + else: + # Use hostname and ip of host we are running on + for service in services: + host_option = 'PLC_%(service)s_HOST' % locals() + ip_option = 'PLC_%(service)s_IP' % locals() + plc_options.append((host_option, self.config.hostname)) + plc_options.append((ip_option, self.config.ip)) + # Load any other options found in config file + for attr in dir(self.config): + if attr.startswith('PLC'): + plc_options.append((attr, getattr(self.config, attr))) # Write temporary plc-config file tmpname = '/tmp/plc-config-tty-%d' % os.getpid() fileconf = open(tmpname, 'w') - for var in plc_vars: - fileconf.write('e %s\n%s\n' % (var, getattr(self.config, var))) + for (option, value) in plc_options: + fileconf.write('e %s\n%s\n' % (option, value) ) fileconf.write('w\nq\n') fileconf.close() - # Update config file - command = "/sbin/service plc mount && plc-config-tty < %(tmpname)s" % locals() + # Update plc config file + command = "plc-config-tty < %(tmpname)s" % locals() if self.config.verbose: utils.header(command) (stdout, stderr) = utils.popen(command) -- 2.43.0