CLOUDSTACK-9701: When host is disabled/removed,

capacity_type for local storage in op_host_capacity
is still enabled
This commit is contained in:
Sudhansu 2016-12-23 16:01:21 +05:30
parent ed2f573160
commit e06e3b7cd4
2 changed files with 20 additions and 0 deletions

View File

@ -1181,6 +1181,13 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
final CapacityState capacityState = nextState == ResourceState.Enabled ? CapacityState.Enabled : CapacityState.Disabled; final CapacityState capacityState = nextState == ResourceState.Enabled ? CapacityState.Enabled : CapacityState.Disabled;
final short[] capacityTypes = {Capacity.CAPACITY_TYPE_CPU, Capacity.CAPACITY_TYPE_MEMORY}; final short[] capacityTypes = {Capacity.CAPACITY_TYPE_CPU, Capacity.CAPACITY_TYPE_MEMORY};
_capacityDao.updateCapacityState(null, null, null, host.getId(), capacityState.toString(), capacityTypes); _capacityDao.updateCapacityState(null, null, null, host.getId(), capacityState.toString(), capacityTypes);
final StoragePoolVO storagePool = _storageMgr.findLocalStorageOnHost(host.getId());
if(storagePool != null){
final short[] capacityTypesLocalStorage = {Capacity.CAPACITY_TYPE_LOCAL_STORAGE};
_capacityDao.updateCapacityState(null, null, null, storagePool.getId(), capacityState.toString(), capacityTypesLocalStorage);
}
} }
return _hostDao.updateResourceState(currentState, event, nextState, host); return _hostDao.updateResourceState(currentState, event, nextState, host);
} }

View File

@ -965,6 +965,19 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
} }
} }
} }
if (storagePool.getScope() == ScopeType.HOST) {
List<StoragePoolHostVO> stoargePoolHostVO = _storagePoolHostDao.listByPoolId(storagePool.getId());
if(stoargePoolHostVO != null && !stoargePoolHostVO.isEmpty()){
HostVO host = _hostDao.findById(stoargePoolHostVO.get(0).getHostId());
if(host != null){
capacityState = (host.getResourceState() == ResourceState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
}
}
}
if (capacities.size() == 0) { if (capacities.size() == 0) {
CapacityVO capacity = CapacityVO capacity =
new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity, new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity,