1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

B #2053: Do not return failure on recursive delete (#1250)

(cherry picked from commit 18aee6583e5646863a85a79e1538bbb56bb203d9)
This commit is contained in:
Pavel Czerný 2021-05-31 16:58:25 +02:00 committed by Ruben S. Montero
parent 5d1928f0a9
commit ff089908d1
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 11 additions and 3 deletions

View File

@ -233,6 +233,8 @@ int TemplateDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool recursive,
VirtualMachineDisks disks(true);
int tid = object->get_oid();
if (recursive)
{
static_cast<VMTemplate *>(object.get())->clone_disks(vdisks);
@ -262,7 +264,7 @@ int TemplateDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool recursive,
{
if ( img_delete.request_execute(iid, att) != SUCCESS )
{
NebulaLog::log("ReM", Log::ERROR, att.resp_msg);
NebulaLog::warn("ReM", att.resp_msg);
error_ids.insert(iid);
}
@ -270,10 +272,12 @@ int TemplateDelete::drop(std::unique_ptr<PoolObjectSQL> object, bool recursive,
if ( !error_ids.empty() )
{
att.resp_msg = "Cannot delete " + object_name(PoolObjectSQL::IMAGE) +
att.resp_msg = "Template " + to_string(tid) +
" deleted, unable to recursively delete " +
object_name(PoolObjectSQL::IMAGE) +
": " + one_util::join(error_ids.begin(), error_ids.end(), ',');
return -1;
NebulaLog::warn("ReM", att.resp_msg);
}
return 0;

View File

@ -158,6 +158,10 @@ int VirtualMachineDisk::get_image_id(int &id, int uid) const
{
id = image->get_oid();
}
else
{
return -1;
}
return 0;
}