mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
B #1512: Do not remove DRIVER from APP if datastore does not include a
DRIVER. Only set FSTYPE when relevant
This commit is contained in:
parent
b75b02e5dc
commit
aa21f31085
@ -98,14 +98,11 @@ int Image::insert(SqlDB *db, string& error_str)
|
||||
{
|
||||
int rc;
|
||||
|
||||
string path_attr;
|
||||
string type_att;
|
||||
string type_attr;
|
||||
string persistent_attr;
|
||||
string dev_prefix;
|
||||
string source_attr;
|
||||
string saved_id;
|
||||
string size_attr;
|
||||
string driver;
|
||||
string tm_mad;
|
||||
|
||||
istringstream iss;
|
||||
ostringstream oss;
|
||||
@ -120,14 +117,14 @@ int Image::insert(SqlDB *db, string& error_str)
|
||||
|
||||
// ------------ TYPE --------------------
|
||||
|
||||
erase_template_attribute("TYPE", type_att);
|
||||
erase_template_attribute("TYPE", type_attr);
|
||||
|
||||
if ( type_att.empty() == true )
|
||||
if ( type_attr.empty() == true )
|
||||
{
|
||||
type_att = ImagePool::default_type();
|
||||
type_attr = ImagePool::default_type();
|
||||
}
|
||||
|
||||
if (set_type(type_att, error_str) != 0)
|
||||
if (set_type(type_attr, error_str) != 0)
|
||||
{
|
||||
goto error_common;
|
||||
}
|
||||
@ -183,6 +180,8 @@ int Image::insert(SqlDB *db, string& error_str)
|
||||
|
||||
erase_template_attribute("PATH", path);
|
||||
erase_template_attribute("SOURCE", source);
|
||||
erase_template_attribute("FSTYPE", fs_type);
|
||||
erase_template_attribute("TM_MAD", tm_mad);
|
||||
|
||||
if (!is_saving())
|
||||
{
|
||||
@ -194,6 +193,29 @@ int Image::insert(SqlDB *db, string& error_str)
|
||||
{
|
||||
goto error_path_and_source;
|
||||
}
|
||||
|
||||
if ( path.empty() && type == Image::DATABLOCK )
|
||||
{
|
||||
if ( fs_type.empty() )
|
||||
{
|
||||
string driver;
|
||||
|
||||
fs_type = "raw"; //Default
|
||||
|
||||
get_template_attribute("DRIVER", driver);
|
||||
|
||||
one_util::tolower(driver);
|
||||
|
||||
if (driver == "qcow2" || (driver.empty() && tm_mad == "qcow2"))
|
||||
{
|
||||
fs_type = "qcow2";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fs_type = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -166,43 +166,9 @@ int ImagePool::allocate (
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Get FSTYPE
|
||||
// Set TM_MAD to infer FSTYPE if needed
|
||||
// ---------------------------------------------------------------------
|
||||
img->get_template_attribute("FSTYPE", fs_type);
|
||||
|
||||
if (!fs_type.empty())
|
||||
{
|
||||
img->fs_type = fs_type;
|
||||
}
|
||||
else
|
||||
{
|
||||
img->get_template_attribute("DRIVER", driver);
|
||||
|
||||
if (!driver.empty())
|
||||
{
|
||||
// infer fs_type from driver
|
||||
one_util::tolower(driver);
|
||||
|
||||
if (driver == "qcow2")
|
||||
{
|
||||
img->fs_type = "qcow2";
|
||||
}
|
||||
else
|
||||
{
|
||||
img->fs_type = "raw";
|
||||
}
|
||||
} else {
|
||||
// no driver, infer ds_type from tm_mad
|
||||
if (tm_mad == "qcow2")
|
||||
{
|
||||
img->fs_type = "qcow2";
|
||||
}
|
||||
else
|
||||
{
|
||||
img->fs_type = "raw";
|
||||
}
|
||||
}
|
||||
}
|
||||
img->replace_template_attribute("TM_MAD", tm_mad);
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
// Insert the Object in the pool & Register the image in the repository
|
||||
@ -234,11 +200,8 @@ int ImagePool::allocate (
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = imagem->clone_image(*oid,
|
||||
cloning_id,
|
||||
ds_data,
|
||||
extra_data,
|
||||
error_str);
|
||||
rc = imagem->clone_image(*oid, cloning_id, ds_data, extra_data,
|
||||
error_str);
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
|
@ -360,6 +360,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
string ds_data;
|
||||
string ds_mad;
|
||||
string tm_mad;
|
||||
string ds_driver;
|
||||
|
||||
bool ds_persistent_only;
|
||||
|
||||
@ -447,6 +448,8 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
ds_mad = ds->get_ds_mad();
|
||||
tm_mad = ds->get_tm_mad();
|
||||
|
||||
ds->get_template_attribute("DRIVER", ds_driver);
|
||||
|
||||
ds->to_xml(ds_data);
|
||||
|
||||
ds->unlock();
|
||||
@ -493,8 +496,11 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
|
||||
oss << size_mb;
|
||||
size_str = oss.str();
|
||||
|
||||
//Do not use DRIVER from APP but from Datastore
|
||||
tmpl->erase("DRIVER");
|
||||
//Do not use DRIVER from APP but from Datastore
|
||||
if (!ds_driver.empty() )
|
||||
{
|
||||
tmpl->erase("DRIVER");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user