Commit ff34fb97 authored by Michele Tartara's avatar Michele Tartara
Browse files

Add a default to file-driver when unspecified over RAPI

The file-driver value, used by file-based instances, had a default value when
an instance was being created over the CLI, but not when the instance was
created through the RAPI.

This patch introduces a default value for the remote API and, while doing so,
also centralizes in a single place the definition of such a value, for both the
interfaces, in order to remove the possibility for them to be out of sync.

Fixes Issue 571.
Signed-off-by: default avatarMichele Tartara <>
Reviewed-by: default avatarKlaus Aehlig <>
parent 282c1922
......@@ -886,7 +886,7 @@ FILESTORE_DIR_OPT = cli_option("--file-storage-dir", dest="file_storage_dir",
FILESTORE_DRIVER_OPT = cli_option("--file-driver", dest="file_driver",
help="Driver to use for image files",
default="loop", metavar="<DRIVER>",
default=None, metavar="<DRIVER>",
IALLOCATOR_OPT = cli_option("-I", "--iallocator", metavar="<NAME>",
......@@ -404,6 +404,12 @@ class LUInstanceCreate(LogicalUnit):
raise errors.OpPrereqError("Invalid file driver name '%s'" %
self.op.file_driver, errors.ECODE_INVAL)
# set default file_driver if unset and required
if (not self.op.file_driver and
self.op.disk_template in [constants.DT_FILE,
self.op.file_driver = constants.FD_LOOP
if self.op.disk_template == constants.DT_FILE:
elif self.op.disk_template == constants.DT_SHARED_FILE:
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