Skip to content
Snippets Groups Projects
Commit 0376655e authored by Guido Trotter's avatar Guido Trotter
Browse files

remove bootstrap._InitSharedFileStorage


This function is a copy of bootstrap._InitFileStorage with the following
differences:
  - check constants.ENABLE_SHARED_FILE_STORAGE and not
    constants.ENABLE_FILE_STORAGE
  - use different local variable names
  - one different error string

Thus:
  - move the constant check outside of the function call
  - change error string so it's clear where the error is
  - call the same function twice

Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 2492231f
No related branches found
No related tags found
No related merge requests found
......@@ -221,14 +221,11 @@ def _InitFileStorage(file_storage_dir):
time) or the normalized path to the storage directory
"""
if not constants.ENABLE_FILE_STORAGE:
return ""
file_storage_dir = os.path.normpath(file_storage_dir)
if not os.path.isabs(file_storage_dir):
raise errors.OpPrereqError("The file storage directory you passed is"
" not an absolute path.", errors.ECODE_INVAL)
raise errors.OpPrereqError("File storage directory '%s' is not an absolute"
" path" % file_storage_dir, errors.ECODE_INVAL)
if not os.path.exists(file_storage_dir):
try:
......@@ -245,39 +242,6 @@ def _InitFileStorage(file_storage_dir):
return file_storage_dir
def _InitSharedFileStorage(shared_file_storage_dir):
"""Initialize if needed the shared file storage.
@param shared_file_storage_dir: the user-supplied value
@return: either empty string (if file storage was disabled at build
time) or the normalized path to the storage directory
"""
if not constants.ENABLE_SHARED_FILE_STORAGE:
return ""
shared_file_storage_dir = os.path.normpath(shared_file_storage_dir)
if not os.path.isabs(shared_file_storage_dir):
raise errors.OpPrereqError("The shared file storage directory you"
" passed is not an absolute path.",
errors.ECODE_INVAL)
if not os.path.exists(shared_file_storage_dir):
try:
os.makedirs(shared_file_storage_dir, 0750)
except OSError, err:
raise errors.OpPrereqError("Cannot create file storage directory"
" '%s': %s" % (shared_file_storage_dir, err),
errors.ECODE_ENVIRON)
if not os.path.isdir(shared_file_storage_dir):
raise errors.OpPrereqError("The file storage directory '%s' is not"
" a directory." % shared_file_storage_dir,
errors.ECODE_ENVIRON)
return shared_file_storage_dir
def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
master_netdev, file_storage_dir, shared_file_storage_dir,
candidate_pool_size, secondary_ip=None, vg_name=None,
......@@ -379,8 +343,15 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
curr_helper),
errors.ECODE_INVAL)
file_storage_dir = _InitFileStorage(file_storage_dir)
shared_file_storage_dir = _InitSharedFileStorage(shared_file_storage_dir)
if constants.ENABLE_FILE_STORAGE:
file_storage_dir = _InitFileStorage(file_storage_dir)
else:
file_storage_dir = ""
if constants.ENABLE_SHARED_FILE_STORAGE:
shared_file_storage_dir = _InitFileStorage(shared_file_storage_dir)
else:
shared_file_storage_dir = ""
if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", mac_prefix):
raise errors.OpPrereqError("Invalid mac prefix given '%s'" % mac_prefix,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment