From: jose.lausuch Date: Sat, 9 May 2015 23:34:11 +0000 (+0200) Subject: config_functest.py download functest.yaml if not present X-Git-Tag: 0.2~2041 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=470bd82376f3f8ac3e213ca80d1a30d6fe499b50;p=functest-xtesting.git config_functest.py download functest.yaml if not present JIRA: FUNCTEST-1 JIRA: FUNCTEST-3 Change-Id: I0f5c14597539b78915d487d0fc10283530ac04ad Signed-off-by: jose.lausuch --- diff --git a/testcases/config_functest.py b/testcases/config_functest.py index 7a74fbd5..dd9af063 100644 --- a/testcases/config_functest.py +++ b/testcases/config_functest.py @@ -13,30 +13,7 @@ from git import Repo actions = ['start', 'check', 'clean'] -with open('functest.yaml') as f: - functest_yaml = yaml.safe_load(f) -f.close() -logger.info("Downloading functest.yaml...") -yaml_url = 'https://git.opnfv.org/cgit/functest/plain/testcases/functest.yaml' -if not download_url(yaml_url,"./"): - logger.error("Unable to download the configuration file functest.yaml") - exit(-1) - -""" global variables """ -HOME = os.environ['HOME']+"/" -FUNCTEST_BASE_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_functest") -RALLY_REPO_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_repo") -RALLY_TEST_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally") -RALLY_INSTALLATION_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_inst") -BENCH_TESTS_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_scn") -VPING_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_vping") -ODL_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_odl") -IMAGE_URL = functest_yaml.get("general").get("openstack").get("image_url") -IMAGE_DISK_FORMAT = functest_yaml.get("general").get("openstack").get("image_disk_format") -IMAGE_NAME = functest_yaml.get("general").get("openstack").get("image_name") -IMAGE_FILE_NAME = IMAGE_URL.rsplit('/')[-1] -IMAGE_DOWNLOAD_PATH = FUNCTEST_BASE_DIR + IMAGE_FILE_NAME parser = argparse.ArgumentParser() parser.add_argument("action", help="Possible actions are: '{d[0]}|{d[1]}|{d[2]}' ".format(d=actions)) @@ -60,6 +37,45 @@ logger.addHandler(ch) +yaml_url = 'https://git.opnfv.org/cgit/functest/plain/testcases/functest.yaml' +name = yaml_url.rsplit('/')[-1] +dest = "./" + name +if not os.path.exists(dest): + logger.info("Downloading functest.yaml...") + try: + response = urllib2.urlopen(yaml_url) + except (urllib2.HTTPError, urllib2.URLError): + logger.error("Error in fetching %s" %yaml_url) + exit(-1) + with open(dest, 'wb') as f: + f.write(response.read()) + logger.info("functest.yaml stored in %s" % dest) +else: + logger.info("functest.yaml found in %s" % dest) + +with open('functest.yaml') as f: + functest_yaml = yaml.safe_load(f) +f.close() + + +""" global variables """ +HOME = os.environ['HOME']+"/" +FUNCTEST_BASE_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_functest") +RALLY_REPO_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_repo") +RALLY_TEST_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally") +RALLY_INSTALLATION_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_inst") +BENCH_TESTS_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_rally_scn") +VPING_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_vping") +ODL_DIR = HOME + functest_yaml.get("general").get("directories").get("dir_odl") +IMAGE_URL = functest_yaml.get("general").get("openstack").get("image_url") +IMAGE_DISK_FORMAT = functest_yaml.get("general").get("openstack").get("image_disk_format") +IMAGE_NAME = functest_yaml.get("general").get("openstack").get("image_name") +IMAGE_FILE_NAME = IMAGE_URL.rsplit('/')[-1] +IMAGE_DOWNLOAD_PATH = FUNCTEST_BASE_DIR + IMAGE_FILE_NAME + + + + def config_functest_start(): """ Start the functest environment installation