On Mon, Feb 28, 2011 at 01:51:04PM +0200, Apollon Oikonomopoulos wrote: > Add shared file storage handling during cluster initialization. > > Signed-off-by: Apollon Oikonomopoulos <[email protected]> > --- > lib/bootstrap.py | 40 +++++++++++++++++++++++++++++++++++++--- > lib/client/gnt_cluster.py | 3 ++- > 2 files changed, 39 insertions(+), 4 deletions(-) > > diff --git a/lib/bootstrap.py b/lib/bootstrap.py > index f1d041d..82e8817 100644 > --- a/lib/bootstrap.py > +++ b/lib/bootstrap.py > @@ -244,10 +244,43 @@ def _InitFileStorage(file_storage_dir): > return file_storage_dir > > > +def _InitSharedFileStorage(shared_file_storage_dir): > + """Initialize if needed the shared file storage. > + > + @param 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, > @@ -346,6 +379,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, > diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py > index 37a7e02..1b434ef 100644 > --- a/lib/client/gnt_cluster.py > +++ b/lib/client/gnt_cluster.py > @@ -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,
Not related to your patch, but this use of keyword arguments for non-keyword args is !good, we should fix it. LGTM, thanks. iustin
