bug 10422: accidentally removed the code for sourceTemplate id when the the volume is created out of template. Checking it in.

status 10422: resolved fixed
This commit is contained in:
Nitin 2011-06-29 14:30:20 +05:30
parent a2bdcf5159
commit 474d666f79

View File

@ -79,94 +79,7 @@ public class ComputeCapacityListener implements Listener {
if (!(startup instanceof StartupRoutingCommand)) {
return;
}
_capacityMgr.updateCapacityForHost(server);
SearchCriteria<CapacityVO> capacityCPU = _capacityDao
.createSearchCriteria();
capacityCPU.addAnd("hostOrPoolId", SearchCriteria.Op.EQ,
server.getId());
capacityCPU.addAnd("dataCenterId", SearchCriteria.Op.EQ,
server.getDataCenterId());
capacityCPU
.addAnd("podId", SearchCriteria.Op.EQ, server.getPodId());
capacityCPU.addAnd("capacityType", SearchCriteria.Op.EQ,
CapacityVO.CAPACITY_TYPE_CPU);
List<CapacityVO> capacityVOCpus = _capacityDao.search(capacityCPU,
null);
if (capacityVOCpus != null && !capacityVOCpus.isEmpty()) {
CapacityVO CapacityVOCpu = capacityVOCpus.get(0);
long newTotalCpu = (server.getCpus().longValue()
* server.getSpeed().longValue());
if ((CapacityVOCpu.getTotalCapacity() <= newTotalCpu)
|| ((CapacityVOCpu.getUsedCapacity() + CapacityVOCpu
.getReservedCapacity()) <= newTotalCpu)) {
CapacityVOCpu.setTotalCapacity(newTotalCpu);
} else if ((CapacityVOCpu.getUsedCapacity()
+ CapacityVOCpu.getReservedCapacity() > newTotalCpu)
&& (CapacityVOCpu.getUsedCapacity() < newTotalCpu)) {
CapacityVOCpu.setReservedCapacity(0);
CapacityVOCpu.setTotalCapacity(newTotalCpu);
} else {
s_logger.debug("What? new cpu is :" + newTotalCpu
+ ", old one is " + CapacityVOCpu.getUsedCapacity()
+ "," + CapacityVOCpu.getReservedCapacity() + ","
+ CapacityVOCpu.getTotalCapacity());
}
_capacityDao.update(CapacityVOCpu.getId(), CapacityVOCpu);
} else {
CapacityVO capacity = new CapacityVO(
server.getId(),
server.getDataCenterId(),
server.getPodId(),
server.getClusterId(),
0L,
(server.getCpus().longValue()
* server.getSpeed().longValue()),
CapacityVO.CAPACITY_TYPE_CPU);
_capacityDao.persist(capacity);
}
SearchCriteria<CapacityVO> capacityMem = _capacityDao
.createSearchCriteria();
capacityMem.addAnd("hostOrPoolId", SearchCriteria.Op.EQ,
server.getId());
capacityMem.addAnd("dataCenterId", SearchCriteria.Op.EQ,
server.getDataCenterId());
capacityMem
.addAnd("podId", SearchCriteria.Op.EQ, server.getPodId());
capacityMem.addAnd("capacityType", SearchCriteria.Op.EQ,
CapacityVO.CAPACITY_TYPE_MEMORY);
List<CapacityVO> capacityVOMems = _capacityDao.search(capacityMem,
null);
if (capacityVOMems != null && !capacityVOMems.isEmpty()) {
CapacityVO CapacityVOMem = capacityVOMems.get(0);
long newTotalMem = server.getTotalMemory();
if (CapacityVOMem.getTotalCapacity() <= newTotalMem
|| (CapacityVOMem.getUsedCapacity()
+ CapacityVOMem.getReservedCapacity() <= newTotalMem)) {
CapacityVOMem.setTotalCapacity(newTotalMem);
} else if (CapacityVOMem.getUsedCapacity()
+ CapacityVOMem.getReservedCapacity() > newTotalMem
&& CapacityVOMem.getUsedCapacity() < newTotalMem) {
CapacityVOMem.setReservedCapacity(0);
CapacityVOMem.setTotalCapacity(newTotalMem);
} else {
s_logger.debug("What? new cpu is :" + newTotalMem
+ ", old one is " + CapacityVOMem.getUsedCapacity()
+ "," + CapacityVOMem.getReservedCapacity() + ","
+ CapacityVOMem.getTotalCapacity());
}
_capacityDao.update(CapacityVOMem.getId(), CapacityVOMem);
} else {
CapacityVO capacity = new CapacityVO(server.getId(),
server.getDataCenterId(), server.getPodId(), server.getClusterId(), 0L,
server.getTotalMemory(),
CapacityVO.CAPACITY_TYPE_MEMORY);
_capacityDao.persist(capacity);
}
_capacityMgr.updateCapacityForHost(server);
}