Revision 87bc7ca8 lib/bootstrap.py

b/lib/bootstrap.py
1 1
#
2 2
#
3 3

  
4
# Copyright (C) 2006, 2007, 2008, 2010 Google Inc.
4
# Copyright (C) 2006, 2007, 2008, 2010, 2011 Google Inc.
5 5
#
6 6
# This program is free software; you can redistribute it and/or modify
7 7
# it under the terms of the GNU General Public License as published by
......
244 244
  return file_storage_dir
245 245

  
246 246

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

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

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

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

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

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

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

  
279

  
247 280
def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
248
                master_netdev, file_storage_dir, candidate_pool_size,
249
                secondary_ip=None, vg_name=None, beparams=None,
250
                nicparams=None, ndparams=None, hvparams=None,
281
                master_netdev, file_storage_dir, shared_file_storage_dir,
282
                candidate_pool_size, secondary_ip=None, vg_name=None,
283
                beparams=None, nicparams=None, ndparams=None, hvparams=None,
251 284
                enabled_hypervisors=None, modify_etc_hosts=True,
252 285
                modify_ssh_setup=True, maintain_node_health=False,
253 286
                drbd_helper=None, uid_pool=None, default_iallocator=None,
......
346 379
                                 errors.ECODE_INVAL)
347 380

  
348 381
  file_storage_dir = _InitFileStorage(file_storage_dir)
382
  shared_file_storage_dir = _InitSharedFileStorage(shared_file_storage_dir)
349 383

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

Also available in: Unified diff