From e89810b70d1ea53a798e807a02048e25815e6b73 Mon Sep 17 00:00:00 2001 From: juanmont Date: Wed, 5 Sep 2018 18:05:17 +0200 Subject: [PATCH] F #2228: Fixed problem with try to delete a vm from inactive state --- src/lcm/LifeCycleActions.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index a400f9ebe3..9e7ba60809 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -409,12 +409,36 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) { int vid = la.vm_id(); VirtualMachine * vm = vmpool->get(vid); + VirtualMachineTemplate quota_tmpl; + string error; if ( vm == 0 ) { return; } + int uid = vm->get_uid(); + int gid = vm->get_gid(); + + std::string memory, cpu; + + vm->get_template_attribute("MEMORY", memory); + vm->get_template_attribute("CPU", cpu); + + if ( (vm->get_state() == VirtualMachine::SUSPENDED) || + (vm->get_state() == VirtualMachine::POWEROFF) || + (vm->get_state() == VirtualMachine::STOPPED) || + (vm->get_state() == VirtualMachine::UNDEPLOYED)) + { + quota_tmpl.add("RUNNING_MEMORY", memory); + quota_tmpl.add("RUNNING_CPU", cpu); + quota_tmpl.add("RUNNING_VMS", 1); + + quota_tmpl.add("MEMORY", 0); + quota_tmpl.add("CPU", 0); + quota_tmpl.add("VMS", 0); + } + if (vm->get_state() == VirtualMachine::ACTIVE && (vm->get_lcm_state() == VirtualMachine::RUNNING || vm->get_lcm_state() == VirtualMachine::UNKNOWN)) @@ -452,6 +476,8 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) vm->set_state(VirtualMachine::ACTIVE); vm->set_state(VirtualMachine::EPILOG); + Quotas::vm_check(uid, gid, "a_tmpl, error); + vm->set_action(History::TERMINATE_ACTION, la.uid(), la.gid(), la.req_id()); @@ -471,6 +497,8 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) vm->set_state(VirtualMachine::ACTIVE); vm->set_state(VirtualMachine::EPILOG); + Quotas::vm_check(uid, gid, "a_tmpl, error); + vm->set_action(History::TERMINATE_ACTION, la.uid(), la.gid(), la.req_id());