diff --git a/Makefile.am b/Makefile.am index ab7d0b66464962fca2a8f3bc89e8e2f5189b24b9..880007db8e2b906ca930aaaf7c036e8c83fa866a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -452,6 +452,7 @@ lib/_autoconf.py: Makefile stamp-directories echo "XEN_KERNEL = '$(XEN_KERNEL)'"; \ echo "XEN_INITRD = '$(XEN_INITRD)'"; \ echo "FILE_STORAGE_DIR = '$(FILE_STORAGE_DIR)'"; \ + echo "ENABLE_FILE_STORAGE = $(ENABLE_FILE_STORAGE)"; \ echo "IALLOCATOR_SEARCH_PATH = [$(IALLOCATOR_SEARCH_PATH)]"; \ echo "KVM_PATH = '$(KVM_PATH)'"; \ echo "SOCAT_PATH = '$(SOCAT)'"; \ diff --git a/configure.ac b/configure.ac index 1876ba1f9c58bd633164d701db4bdc3974e5c39d..11a96d673ae567aa7fdb163a952efcfec760f24c 100644 --- a/configure.ac +++ b/configure.ac @@ -104,9 +104,16 @@ AC_ARG_WITH([file-storage-dir], [directory to store files for file-based backend] [ (default is /srv/ganeti/file-storage)] )], - [file_storage_dir="$withval"], - [file_storage_dir="/srv/ganeti/file-storage"]) + [[file_storage_dir="$withval"; + if test "$withval" != no; then + enable_file_storage=True + else + enable_file_storage=False + fi + ]], + [[file_storage_dir="/srv/ganeti/file-storage"; enable_file_storage="True"]]) AC_SUBST(FILE_STORAGE_DIR, $file_storage_dir) +AC_SUBST(ENABLE_FILE_STORAGE, $enable_file_storage) # --with-kvm-path=... AC_ARG_WITH([kvm-path], diff --git a/lib/backend.py b/lib/backend.py index 60182102f8456d110ea2f64c842a6b622492e4be..3e2fa9697c9e79ceeb18451182cd8ad9e5728b92 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -2255,6 +2255,8 @@ def _TransformFileStorageDir(file_storage_dir): @return: the normalized path if valid, None otherwise """ + if not constants.ENABLE_FILE_STORAGE: + _Fail("File storage disabled at configure time") cfg = _GetConfig() file_storage_dir = os.path.normpath(file_storage_dir) base_file_storage_dir = cfg.GetFileStorageDir() diff --git a/lib/bdev.py b/lib/bdev.py index 43be66aed504a2d09e13c7a17efd335e69754617..deb54f9190ffc679c553cec655be159c3b2d02d9 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -1907,9 +1907,11 @@ class FileStorage(BlockDev): DEV_MAP = { constants.LD_LV: LogicalVolume, constants.LD_DRBD8: DRBD8, - constants.LD_FILE: FileStorage, } +if constants.ENABLE_FILE_STORAGE: + DEV_MAP[constants.LD_FILE] = FileStorage + def FindDevice(dev_type, unique_id, children, size): """Search for an existing, assembled device. diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 402bfdcd0e1d91f76738a56f03fe4fa387a573e4..85555da3937b267e4fcee34ee1a719828d8d886f 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -5658,6 +5658,10 @@ class LUCreateInstance(LogicalUnit): # TODO: make the ip check more flexible and not depend on the name check raise errors.OpPrereqError("Cannot do ip checks without a name check", errors.ECODE_INVAL) + if (self.op.disk_template == constants.DT_FILE and + not constants.ENABLE_FILE_STORAGE): + raise errors.OpPrereqError("File storage disabled at configure time", + errors.ECODE_INVAL) def ExpandNames(self): """ExpandNames for CreateInstance. diff --git a/lib/constants.py b/lib/constants.py index 27ca325adce91c7a9b4d3271f3d45906ad7487a5..e5233b06ffb21fe5b4a9260f909e76f828f1a73e 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -109,6 +109,7 @@ QUEUE_DIR = DATA_DIR + "/queue" DAEMON_UTIL = _autoconf.PKGLIBDIR + "/daemon-util" ETC_HOSTS = "/etc/hosts" DEFAULT_FILE_STORAGE_DIR = _autoconf.FILE_STORAGE_DIR +ENABLE_FILE_STORAGE = _autoconf.ENABLE_FILE_STORAGE SYSCONFDIR = _autoconf.SYSCONFDIR TOOLSDIR = _autoconf.TOOLSDIR CONF_DIR = SYSCONFDIR + "/ganeti"