Skip to content

Commit 1fe3bc0

Browse files
committed
Allow disassociating sourceNat ip address when SourceNat service is not supported by corresponding network any longer (can be disabled during the network offering upgrade)
1 parent 7b51782 commit 1fe3bc0

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎api/src/com/cloud/api/commands/DisassociateIPAddrCmd.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.cloud.event.EventTypes;
3131
import com.cloud.exception.InvalidParameterValueException;
3232
import com.cloud.network.IpAddress;
33+
import com.cloud.user.Account;
3334
import com.cloud.user.UserContext;
3435

3536
@Implementation(description="Disassociates an ip address from the account.", responseObject=SuccessResponse.class)
@@ -96,6 +97,10 @@ public long getEntityOwnerId() {
9697
}
9798
ownerId = ip.getAccountId();
9899
}
100+
101+
if (ownerId == null) {
102+
return Account.ACCOUNT_ID_SYSTEM;
103+
}
99104
return ownerId;
100105
}
101106

‎server/src/com/cloud/network/NetworkManagerImpl.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,10 @@ public boolean disassociateIpAddress(long ipAddressId) {
15881588
if (ipVO.getAllocatedToAccountId() != null) {
15891589
_accountMgr.checkAccess(caller, null, ipVO);
15901590
}
1591+
1592+
Network associatedNetwork = getNetwork(ipVO.getAssociatedWithNetworkId());
15911593

1592-
if (ipVO.isSourceNat()) {
1594+
if (isServiceSupportedByNetworkOffering(associatedNetwork.getNetworkOfferingId(), Service.SourceNat)) {
15931595
throw new IllegalArgumentException("ip address is used for source nat purposes and can not be disassociated.");
15941596
}
15951597

0 commit comments

Comments
 (0)