diff options
Diffstat (limited to 'yardstick/benchmark/scenarios/networking/vnf_generic.py')
-rw-r--r-- | yardstick/benchmark/scenarios/networking/vnf_generic.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py index 7ae6f08c2..aaf850c1d 100644 --- a/yardstick/benchmark/scenarios/networking/vnf_generic.py +++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py @@ -87,19 +87,22 @@ class SshManager(object): def find_relative_file(path, task_path): + """ + Find file in one of places: in abs of path or + relative to TC scenario file. In this order. + + :param path: + :param task_path: + :return str: full path to file + """ # fixme: create schema to validate all fields have been provided - try: - with open(path): + for lookup in [os.path.abspath(path), os.path.join(task_path, path)]: + try: + with open(lookup): + return lookup + except IOError: pass - return path - except IOError as e: - if e.errno != errno.ENOENT: - raise - else: - rel_path = os.path.join(task_path, path) - with open(rel_path): - pass - return rel_path + raise IOError(errno.ENOENT, 'Unable to find {} file'.format(path)) def open_relative_file(path, task_path): |