From 5df3c416fe893b777e5b6b3ce783a63e5e0cdbf4 Mon Sep 17 00:00:00 2001 From: Vincent Pelletier <vincent@nexedi.com> Date: Tue, 24 Apr 2012 13:41:51 +0200 Subject: [PATCH] Delete all partitions, including ones not following current naming scheme. Fixes upgrade path from older erp5testnode version. --- erp5/util/testnode/SlapOSControler.py | 11 +++++++---- erp5/util/testnode/__init__.py | 5 ++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/erp5/util/testnode/SlapOSControler.py b/erp5/util/testnode/SlapOSControler.py index 8a2e11e982..ade1ce2e9b 100644 --- a/erp5/util/testnode/SlapOSControler.py +++ b/erp5/util/testnode/SlapOSControler.py @@ -74,16 +74,19 @@ class SlapOSControler(object): os.mkdir(software_root) os.chmod(software_root, 0750) instance_root = config['instance_root'] + if os.path.exists(instance_root): + # delete old paritions which may exists in order to not get its data + # (ex. MySQL db content) from previous testnode's runs + # In order to be able to change partition naming scheme, do this at + # instance_root level (such change happened already, causing problems). + shutil.rmtree(instance_root) + os.mkdir(instance_root) for i in range(0, MAX_PARTIONS): # create partition and configure computer # XXX: at the moment all partitions do share same virtual interface address # this is not a problem as usually all services are on different ports partition_reference = '%s-%s' %(config['partition_reference'], i) partition_path = os.path.join(instance_root, partition_reference) - if os.path.exists(partition_path): - # delete old paritions which may exists in order to not get its data (ex. MySQL db content) - # from previous testnode's runs - shutil.rmtree(partition_path) os.mkdir(partition_path) os.chmod(partition_path, 0750) computer.updateConfiguration(xml_marshaller.xml_marshaller.dumps({ diff --git a/erp5/util/testnode/__init__.py b/erp5/util/testnode/__init__.py index 359c1b881d..94b9e3476a 100644 --- a/erp5/util/testnode/__init__.py +++ b/erp5/util/testnode/__init__.py @@ -90,9 +90,8 @@ def main(*args): CONFIG['proxy_database'] = os.path.join(slapos_directory, 'proxy.db') CONFIG['slapos_config'] = slapos_config = os.path.join(slapos_directory, 'slapos.cfg') - for d in software_root, instance_root: - if not os.path.lexists(d): - os.mkdir(d) + if not os.path.lexists(software_root): + os.mkdir(software_root) CONFIG['master_url'] = 'http://%s:%s' % (CONFIG['proxy_host'], CONFIG['proxy_port']) open(slapos_config, 'w').write(pkg_resources.resource_string( -- 2.30.9