Bugfix: the load_image.sh script will load a image with the same name 09/26009/5
authorchenjiankun <chenjiankun1@huawei.com>
Thu, 15 Dec 2016 06:02:50 +0000 (06:02 +0000)
committerchenjiankun <chenjiankun1@huawei.com>
Thu, 22 Dec 2016 11:33:38 +0000 (11:33 +0000)
JIRA: YARDSTICK-471

Currently, if we execute the load_image.sh and the openstack already
have this image in the cloud,this script will load another image with
the same name.
This will make yardstick run error.
So I clean this related images before loading.

Change-Id: If5b985ef9b2e890aa10453810fac36867d320a06
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
api/resources/env_action.py
tests/ci/clean_images.sh
tests/ci/yardstick-verify
yardstick/common/constants.py

index fa0f95d..c2c93f1 100644 (file)
@@ -195,6 +195,8 @@ def _prepare_env_daemon():
     # update the external_network
     _source_file(rc_file)
 
+    _clean_images()
+
     _load_images()
 
 
@@ -251,6 +253,14 @@ def _append_external_network(rc_file):
                 raise
 
 
+def _clean_images():
+    cmd = [config.CLEAN_IMAGES_SCRIPT]
+    p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+                         cwd=config.YARDSTICK_REPOS_DIR)
+    output = p.communicate()[0]
+    logger.debug('The result is: %s', output)
+
+
 def _load_images():
     cmd = [config.LOAD_IMAGES_SCRIPT]
     p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
index 5d66128..fa4a54d 100755 (executable)
@@ -27,3 +27,10 @@ cleanup()
 
     openstack flavor delete yardstick-flavor &> /dev/null || true
 }
+
+main()
+{
+    cleanup
+}
+
+main
index 46b32cc..f9d98a4 100755 (executable)
@@ -320,8 +320,6 @@ main()
 
     source $YARDSTICK_REPO_DIR/tests/ci/clean_images.sh
 
-    cleanup
-
     trap "error_exit" EXIT SIGTERM
 
     source $YARDSTICK_REPO_DIR/tests/ci/load_images.sh
index 443b3e8..6993c41 100644 (file)
@@ -31,6 +31,8 @@ RELENG_DIR = '/home/opnfv/repos/releng'
 
 OS_FETCH_SCRIPT = 'utils/fetch_os_creds.sh'
 
+CLEAN_IMAGES_SCRIPT = 'tests/ci/clean_images.sh'
+
 LOAD_IMAGES_SCRIPT = 'tests/ci/load_images.sh'
 
 OPENSTACK_RC_FILE = os.path.join(YARDSTICK_CONFIG_DIR, 'openstack.creds')