mirror of https://github.com/apache/cloudstack.git
hostid and poolid may overlap, fixed deletePoolStats
This commit is contained in:
parent
415b973b92
commit
2bcd7a13d4
|
|
@ -28,7 +28,6 @@ public interface CapacityDao extends GenericDao<CapacityVO, Long> {
|
|||
void clearStorageCapacities();
|
||||
CapacityVO findByHostIdType(Long hostId, short capacityType);
|
||||
void clearNonStorageCapacities2();
|
||||
List<CapacityVO> findByHostorPoolId(Long hostorPoolId);
|
||||
List<Long> orderClustersInZoneOrPodByHostCapacities(long id, int requiredCpu, long requiredRam, short capacityTypeForOrdering, boolean isZone);
|
||||
List<Long> listHostsWithEnoughCapacity(int requiredCpu, long requiredRam, Long clusterId, String hostType);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,15 +147,7 @@ public class CapacityDaoImpl extends GenericDaoBase<CapacityVO, Long> implements
|
|||
sc.setParameters("hostId", hostId);
|
||||
sc.setParameters("type", capacityType);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.List<CapacityVO> findByHostorPoolId(Long hostorPoolId){
|
||||
SearchCriteria<CapacityVO> sc = _hostOrPoolIdSearch.create();
|
||||
sc.setParameters("hostId", hostorPoolId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> orderClustersInZoneOrPodByHostCapacities(long id, int requiredCpu, long requiredRam, short capacityTypeForOrdering, boolean isZone){
|
||||
|
|
|
|||
|
|
@ -1199,7 +1199,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
sPool.setUuid(null);
|
||||
_storagePoolDao.update(id, sPool);
|
||||
_storagePoolDao.remove(id);
|
||||
deleteHostorPoolStats(id);
|
||||
deletePoolStats(id);
|
||||
return true;
|
||||
} else {
|
||||
// 1. Check if the pool has associated volumes in the volumes table
|
||||
|
|
@ -1249,7 +1249,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
sPool.setStatus(StoragePoolStatus.Removed);
|
||||
_storagePoolDao.update(id, sPool);
|
||||
_storagePoolDao.remove(id);
|
||||
deleteHostorPoolStats(id);
|
||||
deletePoolStats(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1259,14 +1259,14 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
|||
}
|
||||
|
||||
@DB
|
||||
private boolean deleteHostorPoolStats(Long hostorPoolId) {
|
||||
private boolean deletePoolStats(Long poolId) {
|
||||
|
||||
List<CapacityVO> capacities = _capacityDao.findByHostorPoolId(hostorPoolId);
|
||||
CapacityVO capacity1 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE);
|
||||
CapacityVO capacity2 = _capacityDao.findByHostIdType(poolId, CapacityVO.CAPACITY_TYPE_STORAGE_ALLOCATED);
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
txn.start();
|
||||
for (CapacityVO capacity : capacities) {
|
||||
_capacityDao.remove(capacity.getId());
|
||||
}
|
||||
_capacityDao.remove(capacity1.getId());
|
||||
_capacityDao.remove(capacity2.getId());
|
||||
txn.commit();
|
||||
return true;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue