Skip to content

Commit 8240bc4

Browse files
SudhansuRohit Yadav
authored andcommitted
CLOUDSTACK-9701: When host is disabled/removed,
capacity_type for local storage in op_host_capacity is still enabled (cherry picked from commit e06e3b7) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 4bacb64 commit 8240bc4

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,6 +1181,13 @@ public boolean resourceStateTransitTo(final Host host, final ResourceState.Event
11811181
final CapacityState capacityState = nextState == ResourceState.Enabled ? CapacityState.Enabled : CapacityState.Disabled;
11821182
final short[] capacityTypes = {Capacity.CAPACITY_TYPE_CPU, Capacity.CAPACITY_TYPE_MEMORY};
11831183
_capacityDao.updateCapacityState(null, null, null, host.getId(), capacityState.toString(), capacityTypes);
1184+
1185+
final StoragePoolVO storagePool = _storageMgr.findLocalStorageOnHost(host.getId());
1186+
1187+
if(storagePool != null){
1188+
final short[] capacityTypesLocalStorage = {Capacity.CAPACITY_TYPE_LOCAL_STORAGE};
1189+
_capacityDao.updateCapacityState(null, null, null, storagePool.getId(), capacityState.toString(), capacityTypesLocalStorage);
1190+
}
11841191
}
11851192
return _hostDao.updateResourceState(currentState, event, nextState, host);
11861193
}

server/src/com/cloud/storage/StorageManagerImpl.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,19 @@ public void createCapacityEntry(StoragePoolVO storagePool, short capacityType, l
997997
}
998998
}
999999
}
1000+
1001+
if (storagePool.getScope() == ScopeType.HOST) {
1002+
List<StoragePoolHostVO> stoargePoolHostVO = _storagePoolHostDao.listByPoolId(storagePool.getId());
1003+
1004+
if(stoargePoolHostVO != null && !stoargePoolHostVO.isEmpty()){
1005+
HostVO host = _hostDao.findById(stoargePoolHostVO.get(0).getHostId());
1006+
1007+
if(host != null){
1008+
capacityState = (host.getResourceState() == ResourceState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
1009+
}
1010+
}
1011+
}
1012+
10001013
if (capacities.size() == 0) {
10011014
CapacityVO capacity =
10021015
new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity,

0 commit comments

Comments
 (0)