Skip to content

Commit cd37b13

Browse files
authored
vpc: prevent sourcenat ip disassociation for an active vpc (#6664)
Fixes #6663 Source NAT IP should not be disassociated from an active vpc
1 parent 814dbba commit cd37b13

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

server/src/main/java/com/cloud/network/NetworkServiceImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,11 @@ private boolean releaseIpAddressInternal(long ipAddressId) throws InsufficientAd
10751075
if (networkId != null) {
10761076
guestNetwork = getNetwork(networkId);
10771077
}
1078-
if (ipVO.isSourceNat() && guestNetwork != null && guestNetwork.getState() != Network.State.Allocated) {
1078+
Vpc vpc = null;
1079+
if (ipVO.getVpcId() != null) {
1080+
vpc = _vpcMgr.getActiveVpc(ipVO.getVpcId());
1081+
}
1082+
if (ipVO.isSourceNat() && ((guestNetwork != null && guestNetwork.getState() != Network.State.Allocated) || vpc != null)) {
10791083
throw new IllegalArgumentException("ip address is used for source nat purposes and can not be disassociated.");
10801084
}
10811085

0 commit comments

Comments
 (0)