1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00

bug #295: Images are disabled if have to be written in the repo

This commit is contained in:
Ruben S. Montero 2010-08-01 17:44:58 +02:00
parent 42bf46e21a
commit 971031f326
2 changed files with 64 additions and 25 deletions

View File

@ -89,11 +89,11 @@ module OpenNebula
if !OpenNebula.is_error?(result)
# Disable the Image for a safe overwriting
# image.disable
image.disable
result = move(source, image['SOURCE'])
# image.enable
image.enable
end
return result

View File

@ -904,6 +904,8 @@ error_common:
void VirtualMachine::release_disk_images()
{
string iid;
string saveas;
int saveas_id;
int num_disks;
vector<Attribute const * > disks;
@ -939,12 +941,49 @@ void VirtualMachine::release_disk_images()
continue;
}
if (img->release_image() == true)
img->release_image();
// -------------- DISABLE THIS IMAGE IF OVERWRITTEN --------------------
saveas = disk->vector_value("SAVE_AS");
saveas_id = -1;
if ( !saveas.empty() )
{
ipool->update(img);
if (saveas == id)
{
img->enable(false);
}
else
{
saveas_id = atoi(saveas.c_str())
}
}
// ----------------------- UPDATE IMAGE --------------------------------
ipool->update(img);
img->unlock();
// ------------------- DISABLE IMAGE TO BE SAVED -----------------------
if (saveas_id != -1)
{
img = ipool->get(saveas_id,true);
if ( img == 0 )
{
continue;
}
img->enable(false);
ipool->update(img);
img->unlock();
}
}
}