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

Bug #3716: Check if VM is imported for unsupported actions

(cherry picked from commit 3a3647a91ddfb42a6e46375547441a2beeeffd09)
This commit is contained in:
Carlos Martín 2015-03-30 17:59:08 +02:00
parent 0d43d9daac
commit d33ce04a33

View File

@ -481,6 +481,8 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
AuthRequest::Operation op = auth_op;
History::VMAction action;
VirtualMachine * vm;
// Compatibility with 3.8
if (action_st == "cancel")
{
@ -515,6 +517,29 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
if ((vm = get_vm(id, att)) == 0)
{
return;
}
if (vm->isImported() && (
action == History::DELETE_RECREATE_ACTION ||
action == History::UNDEPLOY_ACTION ||
action == History::UNDEPLOY_HARD_ACTION ||
action == History::STOP_ACTION))
{
oss << "Action \"" << action_st << "\" is not supported for imported VMs";
failure_response(ACTION,
request_error(oss.str(),""),
att);
vm->unlock();
return;
}
vm->unlock();
switch (action)
{
case History::SHUTDOWN_ACTION:
@ -901,6 +926,16 @@ void VirtualMachineMigrate::request_execute(xmlrpc_c::paramList const& paramList
return;
}
if (vm->isImported())
{
failure_response(ACTION,
request_error("Migration is not supported for imported VMs",""),
att);
vm->unlock();
return;
}
// Check we are not migrating to the same host
c_hid = vm->get_hid();