diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 24bad507c4..8c4eb22809 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -497,6 +497,7 @@ void LifeCycleManager::shutdown_action(const LCMAction& la, bool hard) void LifeCycleManager::undeploy_action(const LCMAction& la, bool hard) { int vid = la.vm_id(); + unsigned int port; VirtualMachine * vm = vmpool->get(vid,true); if ( vm == 0 ) @@ -531,6 +532,14 @@ void LifeCycleManager::undeploy_action(const LCMAction& la, bool hard) vmm->trigger(VMMAction::SHUTDOWN,vid); } + VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS"); + + if ( graphics != 0 && (graphics->vector_value("PORT", port) == 0)) + { + graphics->remove("PORT"); + clpool->release_vnc_port(vm->get_cid(), port); + } + vmpool->update_history(vm); vmpool->update(vm); diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index 43f741d864..58d83b3a17 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -924,7 +924,15 @@ void LifeCycleManager::epilog_success_action(int vid) vm->set_etime(the_time); vm->set_vm_info(); + + VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS"); + if ( graphics != 0 && (graphics->vector_value("PORT", port) == 0)) + { + graphics->remove("PORT"); + clpool->release_vnc_port(vm->get_cid(), port); + } + vmpool->update_history(vm); vmpool->update(vm); @@ -933,13 +941,6 @@ void LifeCycleManager::epilog_success_action(int vid) hpool->del_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci); - const VectorAttribute * graphics = vm->get_template_attribute("GRAPHICS"); - - if ( graphics != 0 && (graphics->vector_value("PORT", port) == 0)) - { - clpool->release_vnc_port(vm->get_cid(), port); - } - //---------------------------------------------------- dm->trigger(action,vid);