@Override public boolean isOneToOneNat() { return _addr.isOneToOneNat(); }
@Override public List<IPAddressVO> findManagedPublicIps() { List<NetworkVO> dbNets = findManagedNetworks(null); if (dbNets == null || dbNets.isEmpty()) { s_logger.debug("Juniper managed networks is empty"); return null; } SearchBuilder<IPAddressVO> searchBuilder = _ipAddressDao.createSearchBuilder(); searchBuilder.and("sourceNat", searchBuilder.entity().isSourceNat(), Op.EQ); searchBuilder.and("network", searchBuilder.entity().getAssociatedWithNetworkId(), Op.IN); searchBuilder.and("oneToOneNat", searchBuilder.entity().isOneToOneNat(), Op.EQ); searchBuilder.and("associatedWithVmId", searchBuilder.entity().getAssociatedWithVmId(), Op.NNULL); List<Long> netIds = new ArrayList<Long>(); for (NetworkVO net : dbNets) { netIds.add(net.getId()); } SearchCriteria<IPAddressVO> sc = searchBuilder.create(); sc.setParameters("oneToOneNat", true); sc.setParameters("sourceNat", false); sc.setParameters("network", netIds.toArray()); List<IPAddressVO> publicIps = _ipAddressDao.search(sc, null); if (publicIps == null) { s_logger.debug("no public ips"); return null; } return publicIps; }
if (!ip.isOneToOneNat() && !ip.isSourceNat() && !(_firewallDao.countRulesByIpId(ip.getId()) > 0)) { if (s_logger.isDebugEnabled()) { s_logger.debug("Releasing Public IP addresses" + ip + " of vlan " + vlanDbId + " as part of Public IP" + " range release to the system pool");
if (vpcIsStaticNatProvider || !ip.isOneToOneNat()) { final PublicIp publicIp = PublicIp.createFromAddrAndVlan(ip, _vlanDao.findById(ip.getVlanId())); if ((ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating)
long networkId = ipAddress.getAssociatedWithNetworkId(); if (!ipAddress.isOneToOneNat()) { InvalidParameterValueException ex = new InvalidParameterValueException("One to one nat is not enabled for the specified ip id"); ex.addProxyObject(ipAddress.getUuid(), "ipId");
if (ip.isOneToOneNat() && ip.getRuleState() == null) { ipsStaticNat++;
} else if (ipAddr.isOneToOneNat()) { InvalidParameterValueException ex = new InvalidParameterValueException("Unable to create load balancer rule; specified sourceip id has static nat enabled"); ex.addProxyObject(ipAddr.getUuid(), "sourceIpId");
if (ip.isOneToOneNat()) { throw new InvalidParameterValueException("Can't delete account specific vlan " + vlanDbId + " as ip " + ip + " belonging to the range is used for static nat purposes. Cleanup the rules first");
if (!ipAddress.isOneToOneNat()) { // Dont allow to enable static nat if PF/LB rules exist for the IP List<FirewallRuleVO> portForwardingRules = _firewallDao.listByIpAndPurposeAndNotRevoked(ipAddress.getId(), Purpose.PortForwarding); if (portForwardingRules != null && !portForwardingRules.isEmpty()) {
if (ip.isOneToOneNat()) { throw new InvalidParameterValueException("Remove the one to one nat rule for this VM for ip " + ip.toString());
@Override public List<FirewallRuleVO> listStaticNatByVmId(long vmId) { if (VmSearch == null) { SearchBuilder<IPAddressVO> IpSearch = _ipDao.createSearchBuilder(); IpSearch.and("associatedWithVmId", IpSearch.entity().getAssociatedWithVmId(), SearchCriteria.Op.EQ); IpSearch.and("oneToOneNat", IpSearch.entity().isOneToOneNat(), SearchCriteria.Op.NNULL); VmSearch = createSearchBuilder(); VmSearch.and("purpose", VmSearch.entity().getPurpose(), Op.EQ); VmSearch.join("ipSearch", IpSearch, VmSearch.entity().getSourceIpAddressId(), IpSearch.entity().getId(), JoinBuilder.JoinType.INNER); VmSearch.done(); } SearchCriteria<FirewallRuleVO> sc = VmSearch.create(); sc.setParameters("purpose", Purpose.StaticNat); sc.setJoinParameters("ipSearch", "associatedWithVmId", vmId); return listBy(sc); }
} else if (ipVO.isOneToOneNat()) { throw new NetworkRuleConflictException("Can't do load balance on ip address: " + ipVO.getAddress());
boolean isOneToOneNat = ipAddress.isOneToOneNat(); Long associatedWithVmId = ipAddress.getAssociatedWithVmId(); Nic guestNic;
public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, VspNic vspNic) { VspStaticNat.Builder vspStaticNatBuilder = new VspStaticNat.Builder() .ipUuid(staticNatIp.getUuid()) .ipAddress(staticNatIp.getAddress().addr()) .revoke(forRevoke) .oneToOneNat(staticNatIp.isOneToOneNat()) .state(getEnumValue(staticNatIp.getState(), VspStaticNat.State.class)) .vlanUuid(staticNatVlan.getUuid()) .vlanGateway(staticNatVlan.getVlanGateway()) .vlanNetmask(staticNatVlan.getVlanNetmask()) .vlanUnderlay(NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, staticNatVlan)); if (staticNatIp.getVmIp() != null) { vspStaticNatBuilder.destinationIp(staticNatIp.getVmIp() + "/32"); } if (vspNic != null) { vspStaticNatBuilder.nic(vspNic); } return vspStaticNatBuilder.build(); }
} else if (ipAddress.isOneToOneNat()) { throw new InvalidParameterValueException("Unable to create port forwarding rule; ip id=" + ipAddrId + " has static nat enabled");
sb.and("associatedNetworkIdEq", sb.entity().getAssociatedWithNetworkId(), SearchCriteria.Op.EQ); sb.and("isSourceNat", sb.entity().isSourceNat(), SearchCriteria.Op.EQ); sb.and("isStaticNat", sb.entity().isOneToOneNat(), SearchCriteria.Op.EQ); sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ); sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
} else if (ipAddress.isSourceNat() || !ipAddress.isOneToOneNat() || ipAddress.getAssociatedWithVmId() == null) { throw new NetworkRuleConflictException("Can't do static nat on ip address: " + ipAddress.getAddress());
AllFieldsSearch.and("network", AllFieldsSearch.entity().getAssociatedWithNetworkId(), Op.EQ); AllFieldsSearch.and("associatedWithVmId", AllFieldsSearch.entity().getAssociatedWithVmId(), Op.EQ); AllFieldsSearch.and("oneToOneNat", AllFieldsSearch.entity().isOneToOneNat(), Op.EQ); AllFieldsSearch.and("sourcenetwork", AllFieldsSearch.entity().getSourceNetworkId(), Op.EQ); AllFieldsSearch.and("physicalNetworkId", AllFieldsSearch.entity().getPhysicalNetworkId(), Op.EQ);