@Override public boolean isPortable() { return _addr.isPortable(); }
for (final IPAddressVO ipToRelease : ipsToRelease) { if (ipToRelease.getVpcId() == null) { if (!ipToRelease.isPortable()) { final IPAddressVO ip = _ipAddrMgr.markIpAsUnavailable(ipToRelease.getId()); assert ip != null : "Unable to mark the ip address id=" + ipToRelease.getId() + " as unavailable.";
if (ip.isPortable()) { releasePortableIpAddress(addrId);
s_logger.debug("Releasing ips for vpc id=" + vpcId + " as a part of vpc cleanup"); for (final IPAddressVO ipToRelease : ipsToRelease) { if (ipToRelease.isPortable()) {
/** * 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; }
@Override public IPAddressVO doInTransaction(TransactionStatus status) { if (updateIpResourceCount(ip)) { _resourceLimitMgr.decrementResourceCount(_ipAddressDao.findById(addrId).getAllocatedToAccountId(), ResourceType.public_ip); } // Save usage event if (ip.getAllocatedToAccountId() != null && ip.getAllocatedToAccountId() != Account.ACCOUNT_ID_SYSTEM) { VlanVO vlan = _vlanDao.findById(ip.getVlanId()); String guestType = vlan.getVlanType().toString(); if (!isIpDedicated(ip)) { String eventType = ip.isPortable() ? EventTypes.EVENT_PORTABLE_IP_RELEASE : EventTypes.EVENT_NET_IP_RELEASE; UsageEventUtils.publishUsageEvent(eventType, ip.getAllocatedToAccountId(), ip.getDataCenterId(), addrId, ip.getAddress().addr(), ip.isSourceNat(), guestType, ip.getSystem(), ip.getClass().getName(), ip.getUuid()); } } return _ipAddressDao.markAsUnavailable(addrId); } });
return false; } else if (ipAddress.isPortable()) { s_logger.info("Portable IP " + ipAddress.getUuid() + " is not associated with the network yet " + " so associate IP with the network " + networkId); if (ipAddress.isPortable()) {