@Override public boolean applyStaticNatForNetwork(long networkId, boolean continueOnError, Account caller, boolean forRevoke) { List<? extends IpAddress> staticNatIps = _ipAddressDao.listStaticNatPublicIps(networkId); List<StaticNat> staticNats = new ArrayList<StaticNat>(); for (IpAddress staticNatIp : staticNatIps) { staticNats.addAll(createStaticNatForIp(staticNatIp, caller, forRevoke)); } if (staticNats != null && !staticNats.isEmpty()) { if (forRevoke) { s_logger.debug("Found " + staticNats.size() + " static nats to disable for network id " + networkId); } try { if (!_ipAddrMgr.applyStaticNats(staticNats, continueOnError, forRevoke)) { return false; } } catch (ResourceUnavailableException ex) { s_logger.warn("Failed to create static nat rule due to ", ex); return false; } } else { s_logger.debug("Found 0 static nat rules to apply for network id " + networkId); } return true; }
@Override public boolean applyStaticNatsForNetwork(long networkId, boolean continueOnError, Account caller) { List<IPAddressVO> ips = _ipAddressDao.listStaticNatPublicIps(networkId); if (ips.isEmpty()) { s_logger.debug("There are no static nat to apply for network id=" + networkId); return true; } if (caller != null) { _accountMgr.checkAccess(caller, null, true, ips.toArray(new IPAddressVO[ips.size()])); } List<StaticNat> staticNats = new ArrayList<StaticNat>(); for (IPAddressVO ip : ips) { // Get nic IP4 address //String dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), networkId); StaticNatImpl staticNat = new StaticNatImpl(ip.getAllocatedToAccountId(), ip.getAllocatedInDomainId(), networkId, ip.getId(), ip.getVmIp(), false); staticNats.add(staticNat); } try { if (!_ipAddrMgr.applyStaticNats(staticNats, continueOnError, false)) { return false; } } catch (ResourceUnavailableException ex) { s_logger.warn("Failed to create static nat for network due to ", ex); return false; } return true; }
@Override public void doInTransactionWithoutResult(TransactionStatus status) { List<IPAddressVO> ips = _ipAddressDao.listStaticNatPublicIps(network.getId()); for (IPAddressVO ip : ips) { ip.setOneToOneNat(false); ip.setAssociatedWithVmId(null); ip.setVmIp(null); _ipAddressDao.update(ip.getId(),ip); } } });
List<? extends IpAddress> staticNatIps = _ipAddressDao.listStaticNatPublicIps(nic.getNetworkId()); for (IpAddress ip : staticNatIps) { if (ip.getVmIp() != null && ip.getVmIp().equals(nic.getIPv4Address())) {
private void reapplyPublicIps(Network networkInOldPhysicalNetwork, Network networkInNewPhysicalNet) { CallContext ctx = CallContext.current(); long callerUserId = ctx.getCallingUserId(); Account caller = ctx.getCallingAccount(); AccountVO networkAccount = _accountDao.findById(networkInNewPhysicalNet.getAccountId()); List<? extends IPAddressVO> staticNatIps = _ipAddressDao.listStaticNatPublicIps(networkInOldPhysicalNetwork.getId()); List<String> providers = _networkOfferingServiceDao.listProvidersForServiceForNetworkOffering(networkInNewPhysicalNet.getNetworkOfferingId(), Network.Service.SourceNat); boolean isSrcNatIpNeeded = providers.stream().anyMatch(provider -> provider.contains(Network.Provider.VirtualRouter.getName())); for (IPAddressVO ipAddress : staticNatIps) { if (!ipAddress.isSourceNat() || isSrcNatIpNeeded) { ipAddress.setAssociatedWithNetworkId(networkInNewPhysicalNet.getId()); _ipAddressDao.persist(ipAddress); } else { _ipAddressManager.disassociatePublicIpAddress(ipAddress.getId(), callerUserId, caller); } } _rulesMgr.applyStaticNatsForNetwork(networkInNewPhysicalNet.getId(), false, networkAccount); }
List<VspAclRule> egressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Egress); List<IPAddressVO> ips = _ipAddressDao.listStaticNatPublicIps(network.getId()); List<String> floatingIpUuids = new ArrayList<String>(); for (IPAddressVO ip : ips) {
List<IPAddressVO> staticNatIps = _ipAddressDao.listStaticNatPublicIps(network.getId()); for (IPAddressVO staticNatIp : staticNatIps) { String publicIp = staticNatIp.getAddress().addr();
List<IPAddressVO> ipAddrsOfNw = _ipAddressDao.listStaticNatPublicIps(config.getId()); for (IPAddressVO ip : ipAddrsOfNw) { if (ip.getVmIp() != null) {