Revision 0376655e

b/lib/bootstrap.py
221 221
      time) or the normalized path to the storage directory
222 222

  
223 223
  """
224
  if not constants.ENABLE_FILE_STORAGE:
225
    return ""
226

  
227 224
  file_storage_dir = os.path.normpath(file_storage_dir)
228 225

  
229 226
  if not os.path.isabs(file_storage_dir):
230
    raise errors.OpPrereqError("The file storage directory you passed is"
231
                               " not an absolute path.", errors.ECODE_INVAL)
227
    raise errors.OpPrereqError("File storage directory '%s' is not an absolute"
228
                               " path" % file_storage_dir, errors.ECODE_INVAL)
232 229

  
233 230
  if not os.path.exists(file_storage_dir):
234 231
    try:
......
245 242
  return file_storage_dir
246 243

  
247 244

  
248
def _InitSharedFileStorage(shared_file_storage_dir):
249
  """Initialize if needed the shared file storage.
250

  
251
  @param shared_file_storage_dir: the user-supplied value
252
  @return: either empty string (if file storage was disabled at build
253
      time) or the normalized path to the storage directory
254

  
255
  """
256
  if not constants.ENABLE_SHARED_FILE_STORAGE:
257
    return ""
258

  
259
  shared_file_storage_dir = os.path.normpath(shared_file_storage_dir)
260

  
261
  if not os.path.isabs(shared_file_storage_dir):
262
    raise errors.OpPrereqError("The shared file storage directory you"
263
                               " passed is not an absolute path.",
264
                               errors.ECODE_INVAL)
265

  
266
  if not os.path.exists(shared_file_storage_dir):
267
    try:
268
      os.makedirs(shared_file_storage_dir, 0750)
269
    except OSError, err:
270
      raise errors.OpPrereqError("Cannot create file storage directory"
271
                                 " '%s': %s" % (shared_file_storage_dir, err),
272
                                 errors.ECODE_ENVIRON)
273

  
274
  if not os.path.isdir(shared_file_storage_dir):
275
    raise errors.OpPrereqError("The file storage directory '%s' is not"
276
                               " a directory." % shared_file_storage_dir,
277
                               errors.ECODE_ENVIRON)
278
  return shared_file_storage_dir
279

  
280

  
281 245
def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
282 246
                master_netdev, file_storage_dir, shared_file_storage_dir,
283 247
                candidate_pool_size, secondary_ip=None, vg_name=None,
......
379 343
                                                             curr_helper),
380 344
                                 errors.ECODE_INVAL)
381 345

  
382
  file_storage_dir = _InitFileStorage(file_storage_dir)
383
  shared_file_storage_dir = _InitSharedFileStorage(shared_file_storage_dir)
346
  if constants.ENABLE_FILE_STORAGE:
347
    file_storage_dir = _InitFileStorage(file_storage_dir)
348
  else:
349
    file_storage_dir = ""
350

  
351
  if constants.ENABLE_SHARED_FILE_STORAGE:
352
    shared_file_storage_dir = _InitFileStorage(shared_file_storage_dir)
353
  else:
354
    shared_file_storage_dir = ""
384 355

  
385 356
  if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", mac_prefix):
386 357
    raise errors.OpPrereqError("Invalid mac prefix given '%s'" % mac_prefix,

Also available in: Unified diff