bug 13282: release elastic IP of the vm on vmStop

status 13282: resolved fixed
This commit is contained in:
Alena Prokharchyk 2012-01-25 15:03:16 -08:00
parent 184ac11d96
commit 4dec3c890a

View File

@ -2780,6 +2780,16 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
@Override
public void finalizeStop(VirtualMachineProfile<UserVmVO> profile, StopAnswer answer) {
//release elastic IP here
IPAddressVO ip = _ipAddressDao.findByAssociatedVmId(profile.getId());
if (ip != null && ip.getElastic()) {
UserContext ctx = UserContext.current();
try {
_rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true);
} catch (Exception ex) {
s_logger.warn("Failed to disable static nat and release elastic ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex);
}
}
}
public String generateRandomPassword() {