Commit 7925d409 authored by Apollon Oikonomopoulos's avatar Apollon Oikonomopoulos Committed by Iustin Pop

Shared file storage initialization code

Add shared file storage handling during cluster initialization.
Signed-off-by: default avatarApollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 4b97f902
#
#
# Copyright (C) 2006, 2007, 2008, 2010 Google Inc.
# Copyright (C) 2006, 2007, 2008, 2010, 2011 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -245,10 +245,43 @@ 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, candidate_pool_size,
secondary_ip=None, vg_name=None, beparams=None,
nicparams=None, ndparams=None, hvparams=None,
master_netdev, file_storage_dir, shared_file_storage_dir,
candidate_pool_size, secondary_ip=None, vg_name=None,
beparams=None, nicparams=None, ndparams=None, hvparams=None,
enabled_hypervisors=None, modify_etc_hosts=True,
modify_ssh_setup=True, maintain_node_health=False,
drbd_helper=None, uid_pool=None, default_iallocator=None,
......@@ -347,6 +380,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable-msg=R0913
errors.ECODE_INVAL)
file_storage_dir = _InitFileStorage(file_storage_dir)
shared_file_storage_dir = _InitSharedFileStorage(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,
......
......@@ -145,6 +145,7 @@ def InitCluster(opts, args):
mac_prefix=opts.mac_prefix,
master_netdev=master_netdev,
file_storage_dir=opts.file_storage_dir,
shared_file_storage_dir=opts.shared_file_storage_dir,
enabled_hypervisors=hvlist,
hvparams=hvparams,
beparams=beparams,
......@@ -1223,7 +1224,7 @@ commands = {
SECONDARY_IP_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
DEFAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT,
NODE_PARAMS_OPT],
NODE_PARAMS_OPT, GLOBAL_SHARED_FILEDIR_OPT],
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
'destroy': (
DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment