Convert os api version file name to a constant
authorGuido Trotter <ultrotter@google.com>
Fri, 2 Oct 2009 10:26:24 +0000 (11:26 +0100)
committerGuido Trotter <ultrotter@google.com>
Mon, 5 Oct 2009 09:39:20 +0000 (10:39 +0100)
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Olivier Tharan <olive@google.com>

lib/backend.py
lib/constants.py

index 24825c4..75457e3 100644 (file)
@@ -1598,17 +1598,17 @@ def _OSOndiskAPIVersion(name, os_dir):
       data holding either the vaid versions or an error message
 
   """
-  api_file = os.path.sep.join([os_dir, "ganeti_api_version"])
+  api_file = os.path.sep.join([os_dir, constants.OS_API_FILE])
 
   try:
     st = os.stat(api_file)
   except EnvironmentError, err:
-    return False, ("Required file 'ganeti_api_version' file not"
-                   " found under path %s: %s" % (os_dir, _ErrnoOrStr(err)))
+    return False, ("Required file '%s' not found under path %s: %s" %
+                   (constants.OS_API_FILE, os_dir, _ErrnoOrStr(err)))
 
   if not stat.S_ISREG(stat.S_IFMT(st.st_mode)):
-    return False, ("File 'ganeti_api_version' file at %s is not"
-                   " a regular file" % os_dir)
+    return False, ("File '%s' in %s is not a regular file" %
+                   (constants.OS_API_FILE, os_dir))
 
   try:
     api_versions = utils.ReadFile(api_file).splitlines()
index 0278cfe..636832b 100644 (file)
@@ -328,6 +328,8 @@ OS_SCRIPT_RENAME = 'rename'
 OS_SCRIPTS = frozenset([OS_SCRIPT_CREATE, OS_SCRIPT_IMPORT,
                         OS_SCRIPT_EXPORT, OS_SCRIPT_RENAME])
 
+OS_API_FILE = 'ganeti_api_version'
+
 # ssh constants
 SSH_INITD_SCRIPT = _autoconf.SSH_INITD_SCRIPT
 SSH_CONFIG_DIR = "/etc/ssh/"