@Override public List<String> getSecondaryIpAddressesForNic(long nicId) { SearchCriteria<NicSecondaryIpVO> sc = AllFieldsSearch.create(); sc.setParameters("nicId", nicId); List<NicSecondaryIpVO> results = search(sc, null); List<String> ips = new ArrayList<String>(results.size()); for (NicSecondaryIpVO result : results) { if (StringUtils.isNotBlank(result.getIp4Address())) { ips.add(result.getIp4Address()); } if (StringUtils.isNotBlank(result.getIp6Address())) { ips.add(result.getIp6Address()); } } return ips; }
private VspNic buildVspNic(String uuid, String macAddress, String ip, long networkId, NicSecondaryIpVO nicSecondaryIp) { VspNic.Builder vspNicBuilder = new VspNic.Builder() .uuid(uuid) .macAddress(macAddress) .useStaticIp(true) .ip(ip); if (nicSecondaryIp != null) { vspNicBuilder.secondaryIpUuid(nicSecondaryIp.getUuid()).secondaryIpAddress(nicSecondaryIp.getIp4Address()); } Network network = _networkDao.findById(networkId); NetworkOffering networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId()); return vspNicBuilder.build(); }
public NicSecondaryIpDaoImpl() { super(); AllFieldsSearch = createSearchBuilder(); AllFieldsSearch.and("instanceId", AllFieldsSearch.entity().getVmId(), Op.EQ); AllFieldsSearch.and("network", AllFieldsSearch.entity().getNetworkId(), Op.EQ); AllFieldsSearch.and("address", AllFieldsSearch.entity().getIp4Address(), Op.LIKE); AllFieldsSearch.and("ip6address", AllFieldsSearch.entity().getIp6Address(), Op.LIKE); AllFieldsSearch.and("nicId", AllFieldsSearch.entity().getNicId(), Op.EQ); AllFieldsSearch.done(); IpSearch = createSearchBuilder(String.class); IpSearch.select(null, Func.DISTINCT, IpSearch.entity().getIp4Address()); IpSearch.and("network", IpSearch.entity().getNetworkId(), Op.EQ); IpSearch.and("address", IpSearch.entity().getIp4Address(), Op.NNULL); IpSearch.done(); CountByNicId = createSearchBuilder(Long.class); CountByNicId.select(null, Func.COUNT, null); CountByNicId.and("nic", CountByNicId.entity().getNicId(), SearchCriteria.Op.EQ); CountByNicId.done(); }
s_logger.debug("Calling secondary ip " + secIpVO.getIp4Address() + " release "); if (dc.getNetworkType() == NetworkType.Advanced && network.getGuestType() == Network.GuestType.Isolated) { String secondaryIp = secIpVO.getIp4Address(); List<FirewallRuleVO> fwRulesList = _firewallDao.listByNetworkAndPurpose(network.getId(), Purpose.PortForwarding); final IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(secIpVO.getNetworkId(), secIpVO.getIp4Address()); if (ip != null) { Transaction.execute(new TransactionCallbackNoReturn() {
throw new InvalidParameterValueException("VM ip " + vmGuestIp + " address not belongs to the vm"); dstIp = nicSecIp.getIp4Address();