Allow disassociating sourceNat ip address when SourceNat service is not supported by corresponding network any longer (can be disabled during the network offering upgrade)

This commit is contained in:
alena 2011-11-03 11:44:57 -07:00
parent 7b51782163
commit 1fe3bc066b
2 changed files with 8 additions and 1 deletions

View File

@ -30,6 +30,7 @@ import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.IpAddress;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(description="Disassociates an ip address from the account.", responseObject=SuccessResponse.class)
@ -96,6 +97,10 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd {
}
ownerId = ip.getAccountId();
}
if (ownerId == null) {
return Account.ACCOUNT_ID_SYSTEM;
}
return ownerId;
}

View File

@ -1588,8 +1588,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (ipVO.getAllocatedToAccountId() != null) {
_accountMgr.checkAccess(caller, null, ipVO);
}
Network associatedNetwork = getNetwork(ipVO.getAssociatedWithNetworkId());
if (ipVO.isSourceNat()) {
if (isServiceSupportedByNetworkOffering(associatedNetwork.getNetworkOfferingId(), Service.SourceNat)) {
throw new IllegalArgumentException("ip address is used for source nat purposes and can not be disassociated.");
}