/** * Prevents associating an IP address to an allocated (unimplemented network) network, throws an Exception otherwise * @param owner Used to check if the user belongs to the Network * @param ipToAssoc IP address to be associated to a Network, can only be associated to an implemented network for Source NAT * @param network Network to which IP address is to be associated with, must not be in allocated state for Source NAT Network/IP association * @return true if IP address can be successfully associated with Source NAT network */ protected boolean isSourceNatAvailableForNetwork(Account owner, IPAddressVO ipToAssoc, Network network) { NetworkOffering offering = _networkOfferingDao.findById(network.getNetworkOfferingId()); boolean sharedSourceNat = offering.isSharedSourceNat(); boolean isSourceNat = false; if (!sharedSourceNat) { if (getExistingSourceNatInNetwork(owner.getId(), network.getId()) == null) { if (network.getGuestType() == GuestType.Isolated && network.getVpcId() == null && !ipToAssoc.isPortable()) { if (network.getState() == Network.State.Allocated) { //prevent associating an ip address to an allocated (unimplemented network). //it will cause the ip to become source nat, and it can't be disassociated later on. String msg = String.format("Network with UUID:%s is in allocated and needs to be implemented first before acquiring an IP address", network.getUuid()); throw new InvalidParameterValueException(msg); } isSourceNat = true; } } } return isSourceNat; }
final boolean sharedSourceNat = offering.isSharedSourceNat(); final DataCenter zone = _dcDao.findById(network.getDataCenterId());
CapabilityResponse sharedSourceNat = new CapabilityResponse(); sharedSourceNat.setName(Capability.SupportedSourceNatTypes.getName()); sharedSourceNat.setValue(offering.isSharedSourceNat() ? "perzone" : "peraccount"); capabilities.add(sharedSourceNat);
boolean sharedSourceNat = offering.isSharedSourceNat();