mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8285: check and update IP capacity states based on allocation state
- Backend should update if state was diabled and now has changed
- UI's fetch latest does not actually fetch latest
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 985a61652e)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
cc9461bdb8
commit
e1827fc696
|
|
@ -364,16 +364,16 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
|
|||
int totalVlans = _dcDao.countZoneVlans(dcId, false);
|
||||
int allocatedVlans = _dcDao.countZoneVlans(dcId, true);
|
||||
|
||||
CapacityState vlanCapacityState = (capacityState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
|
||||
if (capacities.size() == 0) {
|
||||
CapacityVO newVlanCapacity = new CapacityVO(null, dcId, null, null, allocatedVlans, totalVlans, Capacity.CAPACITY_TYPE_VLAN);
|
||||
if (capacityState == AllocationState.Disabled) {
|
||||
newVlanCapacity.setCapacityState(CapacityState.Disabled);
|
||||
}
|
||||
newVlanCapacity.setCapacityState(vlanCapacityState);
|
||||
_capacityDao.persist(newVlanCapacity);
|
||||
} else if (!(capacities.get(0).getUsedCapacity() == allocatedVlans && capacities.get(0).getTotalCapacity() == totalVlans)) {
|
||||
} else if (!(capacities.get(0).getUsedCapacity() == allocatedVlans && capacities.get(0).getTotalCapacity() == totalVlans && capacities.get(0).getCapacityState() == vlanCapacityState)) {
|
||||
CapacityVO capacity = capacities.get(0);
|
||||
capacity.setUsedCapacity(allocatedVlans);
|
||||
capacity.setTotalCapacity(totalVlans);
|
||||
capacity.setCapacityState(vlanCapacityState);
|
||||
_capacityDao.update(capacity.getId(), capacity);
|
||||
}
|
||||
|
||||
|
|
@ -402,19 +402,18 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
|
|||
allocatedIPs = _publicIPAddressDao.countIPsForNetwork(dcId, true, VlanType.DirectAttached);
|
||||
}
|
||||
|
||||
CapacityState ipCapacityState = (capacityState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
|
||||
if (capacities.size() == 0) {
|
||||
CapacityVO newPublicIPCapacity = new CapacityVO(null, dcId, podId, null, allocatedIPs, totalIPs, capacityType);
|
||||
if (capacityState == AllocationState.Disabled) {
|
||||
newPublicIPCapacity.setCapacityState(CapacityState.Disabled);
|
||||
}
|
||||
newPublicIPCapacity.setCapacityState(ipCapacityState);
|
||||
_capacityDao.persist(newPublicIPCapacity);
|
||||
} else if (!(capacities.get(0).getUsedCapacity() == allocatedIPs && capacities.get(0).getTotalCapacity() == totalIPs)) {
|
||||
} else if (!(capacities.get(0).getUsedCapacity() == allocatedIPs && capacities.get(0).getTotalCapacity() == totalIPs && capacities.get(0).getCapacityState() == ipCapacityState)) {
|
||||
CapacityVO capacity = capacities.get(0);
|
||||
capacity.setUsedCapacity(allocatedIPs);
|
||||
capacity.setTotalCapacity(totalIPs);
|
||||
capacity.setCapacityState(ipCapacityState);
|
||||
_capacityDao.update(capacity.getId(), capacity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CapacityChecker extends ManagedContextTimerTask {
|
||||
|
|
|
|||
|
|
@ -2390,11 +2390,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
Long zoneId = cmd.getZoneId();
|
||||
Long podId = cmd.getPodId();
|
||||
Long clusterId = cmd.getClusterId();
|
||||
Boolean fetchLatest = cmd.getFetchLatest();
|
||||
|
||||
if (clusterId != null) {
|
||||
throw new InvalidParameterValueException("Currently clusterId param is not suppoerted");
|
||||
}
|
||||
zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
|
||||
|
||||
if (fetchLatest != null && fetchLatest) {
|
||||
_alertMgr.recalculateCapacity();
|
||||
}
|
||||
List<SummedCapacity> summedCapacities = new ArrayList<SummedCapacity>();
|
||||
|
||||
if (zoneId == null && podId == null) {// Group by Zone, capacity type
|
||||
|
|
|
|||
|
|
@ -927,39 +927,32 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||
}
|
||||
|
||||
s_logger.debug("Total over provisioned capacity of the pool " + storagePool.getName() + " id: " + storagePool.getId() + " is " + totalOverProvCapacity);
|
||||
CapacityState capacityState = CapacityState.Enabled;
|
||||
if (storagePool.getScope() == ScopeType.ZONE) {
|
||||
DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId());
|
||||
AllocationState allocationState = dc.getAllocationState();
|
||||
capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
|
||||
} else {
|
||||
if (storagePool.getClusterId() != null) {
|
||||
ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId());
|
||||
if (cluster != null) {
|
||||
AllocationState allocationState = _configMgr.findClusterAllocationState(cluster);
|
||||
capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (capacities.size() == 0) {
|
||||
CapacityVO capacity =
|
||||
new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity,
|
||||
capacityType);
|
||||
|
||||
if (storagePool.getScope() == ScopeType.ZONE) {
|
||||
DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId());
|
||||
AllocationState allocationState = dc.getAllocationState();
|
||||
CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
|
||||
capacity.setCapacityState(capacityState);
|
||||
} else {
|
||||
if (storagePool.getClusterId() != null) {
|
||||
ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId());
|
||||
if (cluster != null) {
|
||||
AllocationState allocationState = _configMgr.findClusterAllocationState(cluster);
|
||||
CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
|
||||
capacity.setCapacityState(capacityState);
|
||||
}
|
||||
}
|
||||
}
|
||||
capacity.setCapacityState(capacityState);
|
||||
_capacityDao.persist(capacity);
|
||||
} else {
|
||||
CapacityVO capacity = capacities.get(0);
|
||||
boolean update = false;
|
||||
if (capacity.getTotalCapacity() != totalOverProvCapacity) {
|
||||
if (capacity.getTotalCapacity() != totalOverProvCapacity || allocated != 0L || capacity.getCapacityState() != capacityState) {
|
||||
capacity.setTotalCapacity(totalOverProvCapacity);
|
||||
update = true;
|
||||
}
|
||||
if (allocated != 0) {
|
||||
capacity.setUsedCapacity(allocated);
|
||||
update = true;
|
||||
}
|
||||
if (update) {
|
||||
capacity.setCapacityState(capacityState);
|
||||
_capacityDao.update(capacity.getId(), capacity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,20 +183,12 @@
|
|||
});
|
||||
},
|
||||
capacity: function(data) {
|
||||
var latestData = null;
|
||||
if (window.fetchLatestflag == 1) {
|
||||
latestData = {
|
||||
|
||||
fetchLatest: true
|
||||
}
|
||||
data.fetchLastest = true;
|
||||
} else {
|
||||
latestData = {
|
||||
fetchLatest: false
|
||||
}
|
||||
data.fetchLastest = false;
|
||||
}
|
||||
|
||||
window.fetchLatestflag = 0;
|
||||
|
||||
dataFns.alerts(data);
|
||||
},
|
||||
|
||||
|
|
@ -252,7 +244,7 @@
|
|||
$.ajax({
|
||||
url: createURL('listCapacity'),
|
||||
data: {
|
||||
fetchLatest: false,
|
||||
fetchLatest: data.fetchLatest,
|
||||
sortBy: 'usage',
|
||||
page: 0,
|
||||
pageSize: (pageSize > 8? 8: pageSize)
|
||||
|
|
|
|||
Loading…
Reference in New Issue