Use local QTIP_CentOS.qcow2 img file. 85/16885/3
authorwu.zhihui <wu.zhihui1@zte.com.cn>
Thu, 14 Jul 2016 06:29:02 +0000 (14:29 +0800)
committerwu.zhihui <wu.zhihui1@zte.com.cn>
Fri, 15 Jul 2016 03:57:39 +0000 (11:57 +0800)
Check whether image file exists on local. If yes, use the local file.
If no, download it. The benefit is shorten the execute time of CI.

Change-Id: Ic9f9e84e85abb9b3adbc42462c136818f1c46767
Signed-off-by: wu.zhihui <wu.zhihui1@zte.com.cn>
func/fetchimg.py

index 6cae426..88178be 100644 (file)
@@ -9,20 +9,27 @@
 import os\r
 import time\r
 \r
+IMGSTORE="/home/opnfv/imgstore"\r
 \r
 class FetchImg:\r
 \r
     def __init__(self):\r
         print 'Fetching Image!'\r
-        print 'Fetching QTIP_VM Image'\r
 \r
     @staticmethod\r
     def download():\r
         time.sleep(2)\r
-        os.system(\r
-            'mkdir -p Temp_Img && wget http://artifacts.opnfv.org/qtip/QTIP_CentOS.qcow2 -P Temp_Img')\r
-\r
+        os.system('mkdir -p Temp_Img')\r
         filepath = './Temp_Img/QTIP_CentOS.qcow2'\r
-        while not os.path.isfile(filepath):\r
-            time.sleep(10)\r
-        print 'Download Completed!'\r
+        imgstorepath = IMGSTORE+"/QTIP_CentOS.qcow2"\r
+        if os.path.isfile(imgstorepath):\r
+            os.system("ln -s %s %s" % (imgstorepath, filepath))\r
+            print "QTIP_CentOS.qcow2 exists locally. Skipping the download and using the file from IMG store"\r
+        else:\r
+            print 'Fetching QTIP_CentOS.qcow2'\r
+            os.system(\r
+            'wget http://artifacts.opnfv.org/qtip/QTIP_CentOS.qcow2 -P Temp_Img')\r
+\r
+            while not os.path.isfile(filepath):\r
+                time.sleep(10)\r
+            print 'Download Completed!'\r