From c26dabd715e3f8f5f8fe3bd04180801f513d6614 Mon Sep 17 00:00:00 2001
From: Guido Trotter <ultrotter@google.com>
Date: Wed, 3 Oct 2007 11:21:14 +0000
Subject: [PATCH] Make parameter os_dir mandatory for _OSOndiskversion.

First part of the OS search path cleanup. _OSOndiskversion is only ever called
once, and with that argument set, so let's make it mandatory.

Reviewed-by: iustinp
---
 lib/backend.py | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/lib/backend.py b/lib/backend.py
index a5391f92c..fdf72dd85 100644
--- a/lib/backend.py
+++ b/lib/backend.py
@@ -882,28 +882,16 @@ def _ErrnoOrStr(err):
   return detail
 
 
-def _OSOndiskVersion(name, os_dir=None):
+def _OSOndiskVersion(name, os_dir):
   """Compute and return the api version of a given OS.
 
   This function will try to read the api version of the os given by
   the 'name' parameter and residing in the 'os_dir' directory.
 
-  By default if os_dir is not given it will search for a matching name in all
-  the constants.OS_SEARCH_PATH directories. 
-
   Return value will be either an integer denoting the version or None in the
   case when this is not a valid OS name.
 
   """
-  if os_dir is None:
-    for base_dir in constants.OS_SEARCH_PATH:
-      t_os_dir = os.path.sep.join([base_dir, name])
-      if os.path.isdir(t_os_dir):
-        os_dir = t_os_dir
-        break
-  
-  if os_dir is None:
-    raise errors.InvalidOS(name, "OS dir not found in search path")
 
   api_file = os.path.sep.join([os_dir, "ganeti_api_version"])
 
@@ -994,7 +982,7 @@ def OSFromDisk(name, os_dir=None):
   if os_dir is None:
     raise errors.InvalidOS(name, "OS dir not found in search path")
 
-  api_version = _OSOndiskVersion(name, os_dir=os_dir)
+  api_version = _OSOndiskVersion(name, os_dir)
 
   if api_version != constants.OS_API_VERSION:
     raise errors.InvalidOS(name, "API version mismatch (found %s want %s)"
-- 
GitLab