mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #2357: When creating a Datastore, if a wrong DISK_TYPE is specified an error is reported
This commit is contained in:
parent
666cbd697b
commit
a2dd9e9780
@ -80,7 +80,8 @@ public:
|
||||
BLOCK = 2, /** < Block-device disk */
|
||||
RBD = 3, /** < CEPH RBD disk */
|
||||
RBD_CDROM = 4, /** < CEPH RBD CDROM disk */
|
||||
GLUSTER = 5 /** < Gluster Block Device */
|
||||
GLUSTER = 5, /** < Gluster Block Device */
|
||||
NONE = 255 /** < No disk type, error situation */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -297,14 +297,17 @@ int Datastore::insert(SqlDB *db, string& error_str)
|
||||
|
||||
base_path = oss.str();
|
||||
|
||||
disk_type = Image::FILE;
|
||||
|
||||
erase_template_attribute("DISK_TYPE", s_disk_type);
|
||||
|
||||
if ( type == IMAGE_DS )
|
||||
{
|
||||
disk_type = Image::str_to_disk_type(s_disk_type);
|
||||
|
||||
if (disk_type == Image::NONE)
|
||||
{
|
||||
goto error_disk_type;
|
||||
}
|
||||
|
||||
add_template_attribute("DISK_TYPE", Image::disk_type_to_str(disk_type));
|
||||
}
|
||||
|
||||
@ -332,6 +335,10 @@ error_empty_tm:
|
||||
error_str = "No TM_MAD in template.";
|
||||
goto error_common;
|
||||
|
||||
error_disk_type:
|
||||
error_str = "Unknown DISK_TYPE in template.";
|
||||
goto error_common;
|
||||
|
||||
error_common:
|
||||
NebulaLog::log("DATASTORE", Log::ERROR, error_str);
|
||||
return -1;
|
||||
|
@ -732,7 +732,7 @@ Image::ImageType Image::str_to_type(string& str_type)
|
||||
|
||||
Image::DiskType Image::str_to_disk_type(string& s_disk_type)
|
||||
{
|
||||
Image::DiskType type = FILE;
|
||||
Image::DiskType type = NONE;
|
||||
|
||||
one_util::toupper(s_disk_type);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user