diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index df5645804d..c5954fa367 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -644,6 +644,16 @@ public: return previous_history->reason; }; + /** + * Returns the action that closed the current history record. The hasHisto + * function MUST be called before this one. + * @return the action that closed the current history record + */ + const History::VMAction get_action() const + { + return history->action; + }; + /** * Returns the action that closed the history record in the previous host * @return the action that closed the history record in the previous host diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 92f6ebfe29..e46b48a877 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -665,6 +665,32 @@ void VirtualMachineDeploy::request_execute(xmlrpc_c::paramList const& paramList, return; } + // ------------------------------------------------------------------------ + // Authorize request + // ------------------------------------------------------------------------ + + auth = vm_authorization(id, 0, 0, att, &host_perms, 0, auth_op); + + if (auth == false) + { + return; + } + + if ((vm = get_vm(id, att)) == 0) + { + return; + } + + if (vm->hasHistory() && + (vm->get_action() == History::STOP_ACTION || + vm->get_action() == History::UNDEPLOY_ACTION || + vm->get_action() == History::UNDEPLOY_HARD_ACTION)) + { + ds_id = vm->get_ds_id(); + } + + vm->unlock(); + // ------------------------------------------------------------------------ // Get information about the system DS to use (tm_mad) // ------------------------------------------------------------------------