Fix breakage introduced by commit 8044bf655
[ganeti-local] / lib / jstore.py
index a4e51fc..f61a79c 100644 (file)
@@ -21,7 +21,6 @@
 
 """Module implementing the job queue handling."""
 
-import os
 import errno
 
 from ganeti import constants
@@ -37,17 +36,12 @@ def _ReadNumericFile(file_name):
 
   """
   try:
-    fd = open(file_name, "r")
-  except IOError, err:
+    return int(utils.ReadFile(file_name))
+  except EnvironmentError, err:
     if err.errno in (errno.ENOENT, ):
       return None
     raise
 
-  try:
-    return int(fd.read(128))
-  finally:
-    fd.close()
-
 
 def ReadSerial():
   """Read the serial file.
@@ -79,13 +73,8 @@ def InitAndVerifyQueue(must_lock):
            locking mode.
 
   """
-  # Make sure our directories exists
-  for path in (constants.QUEUE_DIR, constants.JOB_QUEUE_ARCHIVE_DIR):
-    try:
-      os.mkdir(path, 0700)
-    except OSError, err:
-      if err.errno not in (errno.EEXIST, ):
-        raise
+  dirs = [(d, constants.JOB_QUEUE_DIRS_MODE) for d in constants.JOB_QUEUE_DIRS]
+  utils.EnsureDirs(dirs)
 
   # Lock queue
   queue_lock = utils.FileLock.Open(constants.JOB_QUEUE_LOCK_FILE)