public String getPublicIpByNetwork(Network network){ List<IPAddressVO> allocatedIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), true); for (IPAddressVO ip: allocatedIps){ if(ip.isSourceNat()){ return ip.getAddress().addr(); } } return null; }
@Override public void doInTransactionWithoutResult(TransactionStatus status) { List<IPAddressVO> ips = _ipAddressDao.listByAssociatedNetwork(network.getId(),true); //removing static nat configured on ips. for (IPAddressVO ip : ips) { ip.setSourceNat(false); _ipAddressDao.update(ip.getId(),ip); } } });
List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null); if (userIps != null && !userIps.isEmpty()) { for (IPAddressVO userIp : userIps) {
List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null); if (userIps != null && !userIps.isEmpty()) { for (IPAddressVO userIp : userIps) {
final List<IPAddressVO> ipsToRelease = _ipAddressDao.listByAssociatedNetwork(networkId, null); for (final IPAddressVO ipToRelease : ipsToRelease) { if (ipToRelease.getVpcId() == null) {
final List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(networkId, null); final List<PublicIp> publicIpsToRelease = new ArrayList<PublicIp>(); if (userIps != null && !userIps.isEmpty()) {
List<IPAddressVO> sourceNat = _ipAddressDao.listByAssociatedNetwork(guestNetwork.getId(), true); if (sourceNat.isEmpty()) { allocateSourceNat = true;
@Override public boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException { List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null); boolean success = true; // CloudStack will take a lazy approach to associate an acquired public IP to a network service provider as // it will not know what service an acquired IP will be used for. An IP is actually associated with a provider when first // rule is applied. Similarly when last rule on the acquired IP is revoked, IP is not associated with any provider // but still be associated with the account. At this point just mark IP as allocated or released. for (IPAddressVO addr : userIps) { if (addr.getState() == IpAddress.State.Allocating) { addr.setAssociatedWithNetworkId(network.getId()); markPublicIpAsAllocated(addr); } else if (addr.getState() == IpAddress.State.Releasing) { // Cleanup all the resources for ip address if there are any, and only then un-assign ip in the system if (cleanupIpResources(addr.getId(), Account.ACCOUNT_ID_SYSTEM, _accountMgr.getSystemAccount())) { _ipAddressDao.unassignIpAddress(addr.getId()); } else { success = false; s_logger.warn("Failed to release resources for ip address id=" + addr.getId()); } } } return success; }
/** * reassigns the nics to the new network from the src network. * @param srcNetworkId * @param dstNetworkId */ private void assignUserNicsToNewNetwork(long srcNetworkId, long dstNetworkId) { List<NicVO> nics = _nicDao.listByNetworkId(srcNetworkId); for (NicVO nic : nics) { if (nic.getVmType() == VirtualMachine.Type.User) { nic.setNetworkId(dstNetworkId); _nicDao.persist(nic); //update the number of active nics in both networks after migration. if (nic.getState() == Nic.State.Reserved) { _networksDao.changeActiveNicsBy(srcNetworkId, -1); _networksDao.changeActiveNicsBy(dstNetworkId, 1); } } } List<? extends IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(srcNetworkId, null); for (IPAddressVO ipAddress : publicIps) { ipAddress.setAssociatedWithNetworkId(dstNetworkId); _ipAddressDao.persist(ipAddress); } }
List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), null); List<PublicIp> publicIps = new ArrayList<PublicIp>(); if (userIps != null && !userIps.isEmpty()) {
final List<IPAddressVO> userIps = _ipAddressDao.listByAssociatedNetwork(associatedWithNetworkId, null); boolean hasSourceNat = false; if (isVPC && userIps.size() > 0 && userIps.get(0) != null) {
ips = _ipAddressDao.listByAssociatedNetwork(network.getId(), true); if (ips.isEmpty()) { s_logger.debug("Creating a source nat ip for network " + network);
final List<IPAddressVO> publicIps = _ipAddressDao.listByAssociatedNetwork(guestNetworkId, null); for (final IPAddressVO userIp : publicIps){ final PublicIp publicIp = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
if (!sharedSourceNat) { List<IPAddressVO> sourceNatIps = _ipAddressDao.listByAssociatedNetwork(network.getId(), true); if (sourceNatIps.size() == 1) { String publicIp = sourceNatIps.get(0).getAddress().addr();