@DB @Override public void releasePodIp(Long id) throws CloudRuntimeException { // Verify input parameters DataCenterIpAddressVO ipVO = _privateIPAddressDao.findById(id); if (ipVO == null) { throw new CloudRuntimeException("Unable to find ip address by id:" + id); } if (ipVO.getTakenAt() == null) { s_logger.debug("Ip Address with id= " + id + " is not allocated, so do nothing."); throw new CloudRuntimeException("Ip Address with id= " + id + " is not allocated, so do nothing."); } // Verify permission DataCenter zone = _entityMgr.findById(DataCenter.class, ipVO.getDataCenterId()); Account caller = CallContext.current().getCallingAccount(); if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getId())) { throw new CloudRuntimeException("Cannot perform this operation, " + "Zone is currently disabled" + "zoneId=" + ipVO.getDataCenterId()); } try { _privateIPAddressDao.releasePodIpAddress(id); } catch (Exception e) { new CloudRuntimeException(e.getMessage()); } }
AllFieldsSearch.and("dc", AllFieldsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); AllFieldsSearch.and("pod", AllFieldsSearch.entity().getPodId(), SearchCriteria.Op.EQ); AllFieldsSearch.and("instance", AllFieldsSearch.entity().getInstanceId(), SearchCriteria.Op.EQ); AllAllocatedIpCountForDc.and("data_center_id", AllAllocatedIpCountForDc.entity().getDataCenterId(), SearchCriteria.Op.EQ); AllAllocatedIpCountForDc.and("removed", AllAllocatedIpCountForDc.entity().getTakenAt(), SearchCriteria.Op.NNULL); AllAllocatedIpCountForDc.done();