diff options
author | jose.lausuch <jose.lausuch@ericsson.com> | 2015-05-10 01:34:11 +0200 |
---|---|---|
committer | jose.lausuch <jose.lausuch@ericsson.com> | 2015-05-10 01:34:11 +0200 |
commit | 470bd82376f3f8ac3e213ca80d1a30d6fe499b50 (patch) | |
tree | da78929db42e4882b47ba1763388e6e4117cb459 /testcases | |
parent | 8553c686e32c0fa54affb4745e04cce6e36a98ff (diff) |
config_functest.py download functest.yaml if not present
JIRA: FUNCTEST-1
JIRA: FUNCTEST-3
Change-Id: I0f5c14597539b78915d487d0fc10283530ac04ad
Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'testcases')
-rw-r--r-- | testcases/config_functest.py | 62 |
1 files changed, 39 insertions, 23 deletions
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 |