From 2872a949cc751c950ec6cc28de2154bc4693d330 Mon Sep 17 00:00:00 2001 From: Manuel Franceschini <manuel.franceschini@gmail.com> Date: Thu, 20 Mar 2008 15:55:17 +0000 Subject: [PATCH] Modify cluster-init to create file-storage-dir This patch adds three things: - it normalizes the file storage directory path passed to gnt-cluster init - if the file-storage-path doesn't exist on the master node, ganeti tries to create it - adds additional check if the passed file-storage-dir is not a directory Reviewed-by: iustinp --- lib/cmdlib.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 5cf3b775d..96736b7a3 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -478,14 +478,23 @@ class LUInitCluster(LogicalUnit): if vgstatus: raise errors.OpPrereqError("Error: %s" % vgstatus) + self.op.file_storage_dir = os.path.normpath(self.op.file_storage_dir) + if not os.path.isabs(self.op.file_storage_dir): raise errors.OpPrereqError("The file storage directory you have is" " not an absolute path.") if not os.path.exists(self.op.file_storage_dir): - raise errors.OpPrereqError("Default file storage directory '%s' does " - "not exist. Please create." % - self.op.file_storage_dir) + try: + os.makedirs(self.op.file_storage_dir, 0750) + except OSError, err: + raise errors.OpPrereqError("Cannot create file storage directory" + " '%s': %s" % + (self.op.file_storage_dir, err)) + + if not os.path.isdir(self.op.file_storage_dir): + raise errors.OpPrereqError("The file storage directory '%s' is not" + " a directory." % self.op.file_storage_dir) if not re.match("^[0-9a-z]{2}:[0-9a-z]{2}:[0-9a-z]{2}$", self.op.mac_prefix): -- GitLab