Commit c34c0cfd authored by Iustin Pop's avatar Iustin Pop
Browse files

Change backend._OSSearch return values

Currently, the function backend._OSSearch() returns the (first) base dir
in which this OS can be found. Thereafter the full actual path to the OS
dir is built in the backend.OSFromDisk() function.

This patch changes this so that _OSSearch() always returns the full path
to the OS directory, and OSFromDisk uses that as returned (it will only
build it if it gets a base dir in the first place).

This patch is needed before we can abstract the _OSSearch into a generic
'look for file object' functionality that can be used for allocator
plugins search too.

Reviewed-by: ultrotter
parent 3cdef069
......@@ -979,7 +979,7 @@ def _OSSearch(name, search_path=None):
for dir_name in search_path:
t_os_dir = os.path.sep.join([dir_name, name])
if os.path.isdir(t_os_dir):
return dir_name
return t_os_dir
return None
......@@ -1073,12 +1073,12 @@ def OSFromDisk(name, base_dir=None):
"""
if base_dir is None:
base_dir = _OSSearch(name)
if base_dir is None:
raise errors.InvalidOS(name, None, "OS dir not found in search path")
os_dir = _OSSearch(name)
if os_dir is None:
raise errors.InvalidOS(name, None, "OS dir not found in search path")
else:
os_dir = os.path.sep.join([base_dir, name])
os_dir = os.path.sep.join([base_dir, name])
api_version = _OSOndiskVersion(name, os_dir)
if api_version != constants.OS_API_VERSION:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment