From d99794049945774edc4f8e936f3a31fe9ab134e0 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 27 Sep 2010 13:02:49 +0200 Subject: [PATCH] tmp config files gathered in a per-plc subdir like conf.onetest1 --- system/TestMain.py | 2 +- system/TestPlc.py | 49 ++++++++++++++++++++++++++++++---------- system/config_default.py | 2 +- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/system/TestMain.py b/system/TestMain.py index 5035a2f..fb743f7 100755 --- a/system/TestMain.py +++ b/system/TestMain.py @@ -340,7 +340,7 @@ steps refer to a method in TestPlc or to a step_* module if self.options.interactive: prompting=True while prompting: - msg="Run step %s on %s [r](un)/d(ry_run)/s(kip)/q(uit) ? "%(stepname,plcname) + msg="%d Run step %s on %s [r](un)/d(ry_run)/s(kip)/q(uit) ? "%(plc_counter,stepname,plcname) answer=raw_input(msg).strip().lower() or "r" answer=answer[0] if answer in ['s','n']: # skip/no/next diff --git a/system/TestPlc.py b/system/TestPlc.py index 0e88444..109aae3 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -96,6 +96,8 @@ class TestPlc: # better use of time: do this now that the nodes are taking off 'plcsh_stress_test', SEP, 'install_sfa', 'configure_sfa', 'cross_configure_sfa', 'import_sfa', 'start_sfa', SEPSFA, +# xxx tmp - working on focusing on one side only +# 'configure_sfi@1', 'add_sfa@1', 'update_sfa', 'view_sfa', SEPSFA, 'configure_sfi', 'add_sfa', 'update_sfa', 'view_sfa', SEPSFA, 'nodes_ssh_debug', 'nodes_ssh_boot', 'check_slice', 'check_initscripts', SEPSFA, 'check_slice_sfa', 'delete_sfa', 'stop_sfa', SEPSFA, @@ -110,7 +112,7 @@ class TestPlc: 'clean_leases', 'list_leases', SEP, 'populate' , SEP, 'list_all_qemus', 'list_qemus', 'kill_qemus', SEP, - 'plcclean_sfa', 'dbclean_sfa', 'uninstall_sfa', 'clean_sfi', SEP, + 'plcclean_sfa', 'dbclean_sfa', 'logclean_sfa', 'uninstall_sfa', 'clean_sfi', SEP, 'db_dump' , 'db_restore', SEP, 'standby_1 through 20',SEP, ] @@ -1089,16 +1091,45 @@ class TestPlc: print "REMEMBER TO RUN import_sfa AGAIN" return True + def logclean_sfa(self): + self.run_in_guest("rm -rf /var/log/sfa_access.log /var/log/sfa_import_plc.log /var/log/sfa.daemon") + return True + def uninstall_sfa(self): "uses rpm to uninstall sfa - ignore result" self.run_in_guest("rpm -e sfa sfa-sfatables sfa-client sfa-plc") self.run_in_guest("rm -rf /var/lib/sfa") return True + ### + def confdir(self): + dirname="conf.%s"%self.plc_spec['name'] + if not os.path.isdir(dirname): + utils.system("mkdir -p %s"%dirname) + if not os.path.isdir(dirname): + raise "Cannot create config dir for plc %s"%self.name() + return dirname + + def conffile(self,filename): + return "%s/%s"%(self.confdir(),filename) + def confsubdir(self,dirname,clean): + subdirname="%s/%s"%(self.confdir(),dirname) + if clean: + utils.system("rm -rf %s"%subdirname) + if not os.path.isdir(subdirname): + utils.system("mkdir -p %s"%subdirname) + if not os.path.isdir(subdirname): + raise "Cannot create config subdir %s for plc %s"%(dirname,self.name()) + return subdirname + + def conffile_clean (self,filename): + filename=self.conffile(filename) + return utils.system("rm -rf %s"%filename)==0 + ### def configure_sfa(self): "run sfa-config-tty" - tmpname='%s.sfa-config-tty'%(self.name()) + tmpname=self.conffile("sfa-config-tty") fileconf=open(tmpname,'w') for var in [ 'SFA_REGISTRY_ROOT_AUTH', 'SFA_INTERFACE_HRN', @@ -1120,7 +1151,6 @@ class TestPlc: fileconf.close() utils.system('cat %s'%tmpname) self.run_in_guest_piped('cat %s'%tmpname,'sfa-config-tty') - utils.system('rm %s'%tmpname) return True def aggregate_xml_line(self): @@ -1137,11 +1167,11 @@ class TestPlc: # of course with a single plc, other_plcs is an empty list if not other_plcs: return True - agg_fname="%s-agg.xml"%self.name() + agg_fname=self.conffile("agg.xml") file(agg_fname,"w").write("%s\n" % \ " ".join([ plc.aggregate_xml_line() for plc in other_plcs ])) utils.header ("(Over)wrote %s"%agg_fname) - reg_fname="%s-reg.xml"%self.name() + reg_fname=self.conffile("reg.xml") file(reg_fname,"w").write("%s\n" % \ " ".join([ plc.registry_xml_line() for plc in other_plcs ])) utils.header ("(Over)wrote %s"%reg_fname) @@ -1162,10 +1192,7 @@ class TestPlc: def configure_sfi(self): sfa_spec=self.plc_spec['sfa'] "sfi client configuration" - dir_name=".sfi" - if os.path.exists(dir_name): - utils.system('rm -rf %s'%dir_name) - utils.system('mkdir %s'%dir_name) + dir_name=self.confsubdir("dot-sfi",clean=True) file_name=dir_name + os.sep + sfa_spec['piuser'] + '.pkey' fileconf=open(file_name,'w') fileconf.write (self.plc_spec['keys'][0]['private']) @@ -1212,12 +1239,10 @@ class TestPlc: fileconf.write(slice_rspec) fileconf.write('\n') fileconf.close() - location = "root/" + location = "root/.sfi" remote="/vservers/%s/%s"%(self.vservername,location) self.test_ssh.copy_abs(dir_name, remote, recursive=True) - #utils.system('cat %s'%tmpname) - utils.system('rm -rf %s'%dir_name) return True def clean_sfi (self): diff --git a/system/config_default.py b/system/config_default.py index 5f6be25..2745788 100644 --- a/system/config_default.py +++ b/system/config_default.py @@ -183,7 +183,7 @@ done def slices (options,index): return [ { 'slice_fields': {'name':'%s_pslc%d'%(login_base(index),i), 'instantiation':'plc-instantiated', - 'url':'http://foo.com', + 'url':'http://foo%d.com'%index, 'description':'testslice number %d'%i, 'max_nodes':2, }, -- 2.43.0