mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
Disks not managed (TM) by opennebula cannot change persistent state
This commit is contained in:
parent
e92bd43753
commit
0fa579fd46
@ -191,6 +191,18 @@ public:
|
||||
return (persistent_img == 1);
|
||||
};
|
||||
|
||||
bool is_managed() const
|
||||
{
|
||||
bool one_managed;
|
||||
|
||||
if (get_template_attribute("OPENNEBULA_MANAGED", one_managed) == false)
|
||||
{
|
||||
one_managed = true;
|
||||
}
|
||||
|
||||
return one_managed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the PERSISTENT attribute in an image Template, if not set the
|
||||
* DEFAULT_IMAGE_PERSISTENT and DEFAULT_IMAGE_PERSISTENT_NEW are check in
|
||||
|
@ -52,6 +52,18 @@ public:
|
||||
return is_flag("PERSISTENT");
|
||||
}
|
||||
|
||||
bool is_managed() const
|
||||
{
|
||||
bool one_managed;
|
||||
|
||||
if (vector_value("OPENNEBULA_MANAGED", one_managed) == -1)
|
||||
{
|
||||
one_managed = true;
|
||||
}
|
||||
|
||||
return one_managed;
|
||||
}
|
||||
|
||||
void set_attach()
|
||||
{
|
||||
set_flag("ATTACH");
|
||||
|
@ -198,17 +198,20 @@ Request::ErrorCode VMTemplateClone::clone(int source_id, const string &name,
|
||||
goto error_images;
|
||||
}
|
||||
|
||||
ec = img_persistent.request_execute(new_img_id, true, img_att);
|
||||
|
||||
if (ec != SUCCESS)
|
||||
if ( (*disk)->is_managed() )
|
||||
{
|
||||
NebulaLog::log("ReM", Log::ERROR, failure_message(ec, img_att));
|
||||
ec = img_persistent.request_execute(new_img_id, true, img_att);
|
||||
|
||||
img_delete.request_execute(img_id, img_att);
|
||||
if (ec != SUCCESS)
|
||||
{
|
||||
NebulaLog::log("ReM",Log::ERROR,failure_message(ec,img_att));
|
||||
|
||||
att.resp_msg = "Failed to clone images: " + img_att.resp_msg;
|
||||
img_delete.request_execute(img_id, img_att);
|
||||
|
||||
goto error_images;
|
||||
att.resp_msg = "Failed to clone images: " + img_att.resp_msg;
|
||||
|
||||
goto error_images;
|
||||
}
|
||||
}
|
||||
|
||||
(*disk)->remove("IMAGE");
|
||||
|
@ -118,6 +118,15 @@ Request::ErrorCode ImagePersistent::request_execute(
|
||||
|
||||
ds_id = image->get_ds_id();
|
||||
|
||||
if ( !image->is_managed() )
|
||||
{
|
||||
att.resp_msg = "Cannot change persistent state for non-managed images";
|
||||
|
||||
image->unlock();
|
||||
|
||||
return ACTION;
|
||||
}
|
||||
|
||||
image->unlock();
|
||||
|
||||
ds = dspool->get(ds_id, true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user