Fail to create vm when corresponding elastic ip failed to apply on the backend

This commit is contained in:
Alena Prokharchyk 2012-01-19 14:13:27 -08:00
parent 19002a2434
commit 03cce245cf
2 changed files with 3 additions and 2 deletions

View File

@ -931,7 +931,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
//check permissions
_accountMgr.checkAccess(caller, null, true, ipOwner, network);
_accountMgr.checkAccess(caller, null, false, ipOwner, network);
DataCenter zone = _configMgr.getZone(network.getDataCenterId());

View File

@ -1184,7 +1184,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
s_logger.debug("Allocated elastic ip " + ip + ", now enabling static nat on it for vm " + vm);
try {
enableStaticNat(ip.getId(), vm.getId());
success = enableStaticNat(ip.getId(), vm.getId());
} catch (NetworkRuleConflictException ex) {
s_logger.warn("Failed to enable static nat as a part of enabling elasticIp and staticNat for vm " + vm + " in guest network " + guestNetwork + " due to exception ", ex);
success = false;
@ -1196,6 +1196,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
if (!success) {
s_logger.warn("Failed to enable static nat on elastic ip " + ip + " for the vm " + vm + ", releasing the ip...");
_networkMgr.handleElasticIpRelease(ip);
throw new CloudRuntimeException("Failed to enable static nat on elastic ip for the vm " + vm);
} else {
s_logger.warn("Succesfully enabled static nat on elastic ip " + ip + " for the vm " + vm);
}