mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-08 05:57:23 +03:00
Merge remote-tracking branch 'origin/master' into feature-1664
This commit is contained in:
commit
ee625402ae
@ -906,6 +906,15 @@ public:
|
||||
*/
|
||||
int get_saveas_disk_hot(int& disk_id, string& source, int& image_id);
|
||||
|
||||
/**
|
||||
* Clears the save_as attributes of the disk being (hot) saved as
|
||||
*
|
||||
* @param img_id ID of the image this disk will be saved to. Can be
|
||||
* -1 if it is not found
|
||||
* @return 0 if a disk with (HOTPLUG_)SAVE_AS was cleaned
|
||||
*/
|
||||
int cancel_saveas_disk(int& image_id);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Authorization related functions
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -687,6 +687,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose)
|
||||
TransferManager * tm = nd.get_tm();
|
||||
VirtualMachineManager * vmm = nd.get_vmm();
|
||||
|
||||
ImagePool* ipool = nd.get_ipool();
|
||||
|
||||
VirtualMachine::LcmState state = vm->get_lcm_state();
|
||||
int vid = vm->get_oid();
|
||||
|
||||
@ -735,12 +737,58 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose)
|
||||
case VirtualMachine::SHUTDOWN:
|
||||
case VirtualMachine::SHUTDOWN_POWEROFF:
|
||||
case VirtualMachine::CANCEL:
|
||||
case VirtualMachine::HOTPLUG_SNAPSHOT:
|
||||
vm->set_running_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid);
|
||||
vmm->trigger(VirtualMachineManager::CLEANUP,vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOTPLUG:
|
||||
vm->clear_attach_disk();
|
||||
|
||||
vm->set_running_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid);
|
||||
vmm->trigger(VirtualMachineManager::CLEANUP,vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOTPLUG_NIC:
|
||||
vm->clear_attach_nic();
|
||||
|
||||
vm->set_running_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid);
|
||||
vmm->trigger(VirtualMachineManager::CLEANUP,vid);
|
||||
break;
|
||||
|
||||
case VirtualMachine::HOTPLUG_SAVEAS:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_POWEROFF:
|
||||
case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
|
||||
case VirtualMachine::HOTPLUG_SNAPSHOT:
|
||||
case VirtualMachine::HOTPLUG_NIC:
|
||||
tm->trigger(TransferManager::DRIVER_CANCEL, vid);
|
||||
|
||||
int image_id;
|
||||
vm->cancel_saveas_disk(image_id);
|
||||
|
||||
// TODO: Remove potential deadlock, vm is locked and we shouldn't
|
||||
// unlock it. Maybe we could add a trigger to ImageManager
|
||||
|
||||
Image* image;
|
||||
|
||||
image = ipool->get(image_id, true);
|
||||
|
||||
if ( image != 0 )
|
||||
{
|
||||
image->set_state(Image::ERROR);
|
||||
|
||||
ipool->update(image);
|
||||
|
||||
image->unlock();
|
||||
}
|
||||
|
||||
vm->set_running_etime(the_time);
|
||||
vmpool->update_history(vm);
|
||||
|
||||
|
@ -2717,6 +2717,62 @@ int VirtualMachine::get_saveas_disk_hot(int& disk_id, string& source, int& image
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::cancel_saveas_disk(int& image_id)
|
||||
{
|
||||
vector<Attribute *> disks;
|
||||
VectorAttribute * disk;
|
||||
|
||||
int num_disks;
|
||||
|
||||
num_disks = obj_template->get("DISK", disks);
|
||||
|
||||
bool active, hot_active;
|
||||
|
||||
image_id = -1;
|
||||
|
||||
for(int i=0; i<num_disks; i++)
|
||||
{
|
||||
disk = dynamic_cast<VectorAttribute * >(disks[i]);
|
||||
|
||||
if ( disk == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
disk->vector_value("SAVE_AS_ACTIVE", active);
|
||||
disk->vector_value("HOTPLUG_SAVE_AS_ACTIVE", hot_active);
|
||||
|
||||
if (active)
|
||||
{
|
||||
disk->vector_value("SAVE_AS", image_id);
|
||||
|
||||
disk->remove("SAVE_AS_ACTIVE");
|
||||
disk->remove("SAVE_AS_SOURCE");
|
||||
disk->remove("SAVE_AS");
|
||||
|
||||
disk->replace("SAVE", "NO");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (hot_active)
|
||||
{
|
||||
disk->vector_value("HOTPLUG_SAVE_AS", image_id);
|
||||
|
||||
disk->remove("HOTPLUG_SAVE_AS_ACTIVE");
|
||||
disk->remove("HOTPLUG_SAVE_AS");
|
||||
disk->remove("HOTPLUG_SAVE_AS_SOURCE");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::set_auth_request(int uid,
|
||||
AuthRequest& ar,
|
||||
VirtualMachineTemplate *tmpl)
|
||||
|
Loading…
x
Reference in New Issue
Block a user