boolean removeNicSecondaryIP(final NicSecondaryIpVO ipVO, final boolean lastIp) { final long nicId = ipVO.getNicId(); final NicVO nic = _nicDao.findById(nicId); Transaction.execute(new TransactionCallbackNoReturn() { @Override public void doInTransactionWithoutResult(TransactionStatus status) { if (lastIp) { nic.setSecondaryIp(false); s_logger.debug("Setting nics secondary ip to false ..."); _nicDao.update(nicId, nic); } s_logger.debug("Revoving nic secondary ip entry ..."); _nicSecondaryIpDao.remove(ipVO.getId()); } }); return true; }
public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, NicVO nic) { NicSecondaryIpVO nicSecondaryIp = null; if (nic == null && staticNatIp.getAssociatedWithVmId() != null && staticNatIp.getVmIp() != null) { nicSecondaryIp = _nicSecondaryIpDao.findByIp4AddressAndInstanceId(staticNatIp.getAssociatedWithVmId(), staticNatIp.getVmIp()); if (nicSecondaryIp != null) { nic = _nicDao.findById(nicSecondaryIp.getNicId()); } } VspNic vspNic = (nic != null) ? buildVspNic(nic, nicSecondaryIp) : null; return buildVspStaticNat(forRevoke, staticNatIp, staticNatVlan, vspNic); }
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(); }
Long nicId = secIpVO.getNicId(); s_logger.debug("ip id = " + ipAddressId + " nic id = " + nicId);