From: wu.zhihui Date: Thu, 14 Jul 2016 06:29:02 +0000 (+0800) Subject: Use local QTIP_CentOS.qcow2 img file. X-Git-Tag: danube.1.0~321^2 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F16885%2F3;p=qtip.git Use local QTIP_CentOS.qcow2 img file. 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 --- diff --git a/func/fetchimg.py b/func/fetchimg.py index 6cae426e..88178bed 100644 --- a/func/fetchimg.py +++ b/func/fetchimg.py @@ -9,20 +9,27 @@ import os import time +IMGSTORE="/home/opnfv/imgstore" class FetchImg: def __init__(self): print 'Fetching Image!' - print 'Fetching QTIP_VM Image' @staticmethod def download(): time.sleep(2) - os.system( - 'mkdir -p Temp_Img && wget http://artifacts.opnfv.org/qtip/QTIP_CentOS.qcow2 -P Temp_Img') - + os.system('mkdir -p Temp_Img') filepath = './Temp_Img/QTIP_CentOS.qcow2' - while not os.path.isfile(filepath): - time.sleep(10) - print 'Download Completed!' + imgstorepath = IMGSTORE+"/QTIP_CentOS.qcow2" + if os.path.isfile(imgstorepath): + os.system("ln -s %s %s" % (imgstorepath, filepath)) + print "QTIP_CentOS.qcow2 exists locally. Skipping the download and using the file from IMG store" + else: + print 'Fetching QTIP_CentOS.qcow2' + os.system( + 'wget http://artifacts.opnfv.org/qtip/QTIP_CentOS.qcow2 -P Temp_Img') + + while not os.path.isfile(filepath): + time.sleep(10) + print 'Download Completed!'