From 4818983762f8424072fb088dbbe7c8a7c6b99570 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Fri, 23 May 2008 07:10:48 +0000 Subject: [PATCH] former option -i split into -N and -P for setting nodes and plcs IP addresses separately + clean_initscripts --- system/TestApiserver.py | 2 ++ system/TestMain.py | 12 ++++++++---- system/TestPlc.py | 14 +++++++++++++- system/config_1vnodes.py | 6 +++--- system/config_1vservers.py | 12 ++++++------ 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/system/TestApiserver.py b/system/TestApiserver.py index e95b94b..1a82408 100644 --- a/system/TestApiserver.py +++ b/system/TestApiserver.py @@ -17,6 +17,8 @@ server_methods = [ ('GetNodes' , []), ('AddNodeGroup' , True), ('AddNodeToNodeGroup' , True), ('AddInitScript' , True), + ('DeleteInitScript', True), + ('GetInitScripts', True), ('AddSite' , True), ('AddSiteAddress' , True), ('DeleteSite' , True), diff --git a/system/TestMain.py b/system/TestMain.py index 1960457..e9c14e8 100755 --- a/system/TestMain.py +++ b/system/TestMain.py @@ -45,7 +45,7 @@ build-url defaults to the last value used, as stored in arg-build-url, or %s config defaults to the last value used, as stored in arg-config, or %r -ips defaults to the last value used, as stored in arg-ips, +node-ips and plc-ips defaults to the last value used, as stored in arg-node-ips and arg-plc-ips, default is to use IP scanning steps refer to a method in TestPlc or to a step_* module === @@ -66,9 +66,12 @@ steps refer to a method in TestPlc or to a step_* module help="Run all default steps") parser.add_option("-l","--list",action="store_true",dest="list_steps", default=False, help="List known steps") - parser.add_option("-i","--ip",action="callback", callback=TestMain.optparse_list, dest="ips", + parser.add_option("-N","--nodes",action="callback", callback=TestMain.optparse_list, dest="node_ips", nargs=1,type="string", - help="Specify the set of IP addresses to use in vserver mode (disable scanning)") + help="Specify the set of IP addresses to use for nodes (scanning disabled)") + parser.add_option("-P","--plcs",action="callback", callback=TestMain.optparse_list, dest="plc_ips", + nargs=1,type="string", + help="Specify the set of IP addresses to use for plcs (scanning disabled)") parser.add_option("-1","--small",action="store_true",dest="small_test",default=False, help="run a small test -- typically only one node") parser.add_option("-d","--dbname",action="store",dest="dbname",default=None, @@ -104,7 +107,8 @@ steps refer to a method in TestPlc or to a step_* module # handle defaults and option persistence for (recname,filename,default) in ( ('build_url','arg-build-url',TestMain.default_build_url) , - ('ips','arg-ips',[]) , + ('node_ips','arg-node-ips',[]) , + ('plc_ips','arg-plc-ips',[]) , ('config','arg-config',TestMain.default_config) , ('arch_rpms_url','arg-arch-rpms-url',"") , ) : diff --git a/system/TestPlc.py b/system/TestPlc.py index 1c3cb7c..6160262 100644 --- a/system/TestPlc.py +++ b/system/TestPlc.py @@ -72,7 +72,8 @@ class TestPlc: 'check_initscripts', 'check_tcp',SEP, 'force_gather_logs', 'force_kill_qemus', 'force_record_tracker','force_free_tracker' ] other_steps = [ 'stop_all_vservers','fresh_install', 'cache_rpm', 'stop', SEP, - 'clean_sites', 'clean_nodes', 'clean_slices', 'clean_keys', SEP, + 'clean_initscripts', 'clean_sites', 'clean_nodes', + 'clean_slices', 'clean_keys', SEP, 'show_boxes', 'list_all_qemus', 'list_qemus', SEP, 'db_dump' , 'db_restore', ' cleanup_tracker', 'standby_1 through 20' @@ -556,6 +557,17 @@ class TestPlc: self.apiserver.AddInitScript(self.auth_root(),initscript['initscript_fields']) return True + def clean_initscripts (self): + for initscript in self.plc_spec['initscripts']: + initscript_name = initscript['initscript_fields']['name'] + print('Attempting to delete %s in plc %s'%(initscript_name,self.plc_spec['name'])) + try: + self.apiserver.DeleteInitScript(self.auth_root(),initscript_name) + print initscript_name,'deleted' + except: + print 'deletion went wrong - probably did not exist' + return True + def slices (self): return self.do_slices() diff --git a/system/config_1vnodes.py b/system/config_1vnodes.py index a37ef1f..4fdb5d3 100644 --- a/system/config_1vnodes.py +++ b/system/config_1vnodes.py @@ -22,9 +22,9 @@ def config (plcs, options): all_nodenames = test_mapper.node_names() maps = [] for nodename in all_nodenames: - if len(options.ips) != 0: - ip=options.ips[0] - options.ips=options.ips[1:] + if len(options.node_ips) != 0: + ip=options.node_ips[0] + options.node_ips=options.node_ips[1:] (hostname,ip,mac)=test_pool.locate(ip) else: (hostname,ip,mac) = test_pool.next_free() diff --git a/system/config_1vservers.py b/system/config_1vservers.py index 5e515de..98e9de6 100644 --- a/system/config_1vservers.py +++ b/system/config_1vservers.py @@ -12,16 +12,16 @@ def config (plcs,options): test_pool = TestPool (onelab_plcs_pool,options) - if len(options.ips) != 0: - utils.header('Using user-provided IPS:\nips=%r'%options.ips) - options.ips.reverse() + if len(options.plc_ips) != 0: + utils.header('Using user-provided IPS:\nplc_ips=%r'%options.plc_ips) + options.plc_ips.reverse() plc_counter=0 for plc in plcs: try: - if len(options.ips) != 0: - ip=options.ips[0] - options.ips=options.ips[1:] + if len(options.plc_ips) != 0: + ip=options.plc_ips[0] + options.plc_ips=options.plc_ips[1:] (hostname,ip,mac)=test_pool.locate(ip) utils.header("Using user-provided %s %s for plc %s"%( hostname,ip,plc['name'])) -- 2.43.0