mirror of https://github.com/apache/cloudstack.git
bug 11114: when release static nat as a part of vm expunge, do searchIncludingRemoved in nics table as the nics are marked as Removed before static nat is released
status 11114: resolved fixed
This commit is contained in:
parent
98386a6c00
commit
e76a8d7f8a
|
|
@ -215,4 +215,6 @@ public interface NetworkManager extends NetworkService {
|
|||
boolean applyStaticNats(List<? extends StaticNat> staticNats, boolean continueOnError) throws ResourceUnavailableException;
|
||||
|
||||
String getIpInNetwork(long vmId, long networkId);
|
||||
|
||||
String getIpInNetworkIncludingRemoved(long vmId, long networkId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2641,7 +2641,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
@Override
|
||||
public String getIpInNetwork(long vmId, long networkId) {
|
||||
Nic guestNic = getNicInNetwork(vmId, networkId);
|
||||
assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with ipAddress or ip4 address is null?";
|
||||
assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with ipAddress or ip4 address is null";
|
||||
return guestNic.getIp4Address();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIpInNetworkIncludingRemoved(long vmId, long networkId) {
|
||||
Nic guestNic = getNicInNetworkIncludingRemoved(vmId, networkId);
|
||||
assert (guestNic != null && guestNic.getIp4Address() != null) : "Vm doesn't belong to network associated with ipAddress or ip4 address is null";
|
||||
return guestNic.getIp4Address();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1096,7 +1096,14 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
//create new static nat rule
|
||||
// Get nic IP4 address
|
||||
String dstIp = _networkMgr.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
|
||||
String dstIp;
|
||||
if (forRevoke) {
|
||||
dstIp = _networkMgr.getIpInNetworkIncludingRemoved(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
} else {
|
||||
dstIp = _networkMgr.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
|
||||
}
|
||||
|
||||
StaticNatImpl staticNat = new StaticNatImpl(sourceIp.getAccountId(), sourceIp.getDomainId(), networkId, sourceIpId, dstIp, forRevoke);
|
||||
staticNats.add(staticNat);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue