mirror of https://github.com/apache/cloudstack.git
bug 7474: implementing search for public ip address for a zone, without the filter for vlan db id.
status 7474: resolved fixed
This commit is contained in:
parent
cebf829f13
commit
9c8d8d1dc4
|
|
@ -50,6 +50,7 @@ import com.cloud.dc.HostPodVO;
|
|||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterIpAddressDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
|
|
@ -332,9 +333,14 @@ public class AlertManagerImpl implements AlertManager {
|
|||
List<DataCenterVO> datacenters = _dcDao.listAllIncludingRemoved();
|
||||
for (DataCenterVO datacenter : datacenters) {
|
||||
long dcId = datacenter.getId();
|
||||
|
||||
int totalPublicIPs = _publicIPAddressDao.countIPs(dcId, -1, false);
|
||||
int allocatedPublicIPs = _publicIPAddressDao.countIPs(dcId, -1, true);
|
||||
|
||||
//NOTE
|
||||
//What happens if we have multiple vlans? Dashboard currently shows stats
|
||||
//with no filter based on a vlan
|
||||
//ideal way would be to remove out the vlan param, and filter only on dcId
|
||||
//implementing the same
|
||||
int totalPublicIPs = _publicIPAddressDao.countIPsForDashboard(dcId, false);
|
||||
int allocatedPublicIPs = _publicIPAddressDao.countIPsForDashboard(dcId, true);
|
||||
|
||||
CapacityVO newPublicIPCapacity = new CapacityVO(null, dcId, null, allocatedPublicIPs, totalPublicIPs, CapacityVO.CAPACITY_TYPE_PUBLIC_IP);
|
||||
newCapacities.add(newPublicIPCapacity);
|
||||
|
|
|
|||
|
|
@ -42,4 +42,6 @@ public interface IPAddressDao extends GenericDao<IPAddressVO, String> {
|
|||
boolean mark(long dcId, String ip);
|
||||
|
||||
List<String> assignAcccountSpecificIps(long accountId, long longValue, Long vlanDbId, boolean sourceNat);
|
||||
|
||||
int countIPsForDashboard(long dcId, boolean onlyCountAllocated);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,10 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, String> implem
|
|||
protected final SearchBuilder<IPAddressVO> VlanDbIdSearchUnallocated;
|
||||
protected final GenericSearchBuilder<IPAddressVO, Integer> AllIpCount;
|
||||
protected final GenericSearchBuilder<IPAddressVO, Integer> AllocatedIpCount;
|
||||
|
||||
protected final GenericSearchBuilder<IPAddressVO, Integer> AllIpCountForDashboard;
|
||||
protected final GenericSearchBuilder<IPAddressVO, Integer> AllocatedIpCountForDashboard;
|
||||
|
||||
|
||||
// make it public for JUnit test
|
||||
public IPAddressDaoImpl() {
|
||||
AllFieldsSearch = createSearchBuilder();
|
||||
|
|
@ -79,6 +82,17 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, String> implem
|
|||
AllocatedIpCount.and("vlan", AllocatedIpCount.entity().getVlanId(), Op.EQ);
|
||||
AllocatedIpCount.and("allocated", AllocatedIpCount.entity().getAllocatedTime(), Op.NNULL);
|
||||
AllocatedIpCount.done();
|
||||
|
||||
AllIpCountForDashboard = createSearchBuilder(Integer.class);
|
||||
AllIpCountForDashboard.select(null, Func.COUNT, AllIpCountForDashboard.entity().getAddress());
|
||||
AllIpCountForDashboard.and("dc", AllIpCountForDashboard.entity().getDataCenterId(), Op.EQ);
|
||||
AllIpCountForDashboard.done();
|
||||
|
||||
AllocatedIpCountForDashboard = createSearchBuilder(Integer.class);
|
||||
AllocatedIpCountForDashboard.select(null, Func.COUNT, AllocatedIpCountForDashboard.entity().getAddress());
|
||||
AllocatedIpCountForDashboard.and("dc", AllocatedIpCountForDashboard.entity().getDataCenterId(), Op.EQ);
|
||||
AllocatedIpCountForDashboard.and("allocated", AllocatedIpCountForDashboard.entity().getAllocatedTime(), Op.NNULL);
|
||||
AllocatedIpCountForDashboard.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -204,6 +218,14 @@ public class IPAddressDaoImpl extends GenericDaoBase<IPAddressVO, String> implem
|
|||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countIPsForDashboard(long dcId, boolean onlyCountAllocated) {
|
||||
SearchCriteria<Integer> sc = onlyCountAllocated ? AllocatedIpCountForDashboard.create() : AllIpCountForDashboard.create();
|
||||
sc.setParameters("dc", dcId);
|
||||
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public int countIPs(long dcId, Long accountId, String vlanId, String vlanGateway, String vlanNetmask) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue