use of com.emc.storageos.cinder.model.UsageStats in project coprhd-controller by CoprHD.
the class ExportService method validateVolumeExpand.
private boolean validateVolumeExpand(String openstack_tenant_id, VirtualPool pool, Volume vol, long requestedSize, Project proj) {
QuotaOfCinder objQuota = null;
if (pool == null)
objQuota = getQuotaHelper().getProjectQuota(openstack_tenant_id, getUserFromContext());
else
objQuota = getQuotaHelper().getVPoolQuota(openstack_tenant_id, pool, getUserFromContext());
if (objQuota == null) {
_log.info("Unable to retrive the Quota information");
return false;
}
long totalSizeUsed = 0;
UsageStats stats = null;
if (pool != null)
stats = getQuotaHelper().getStorageStats(pool.getId(), proj.getId());
else
stats = getQuotaHelper().getStorageStats(null, proj.getId());
totalSizeUsed = stats.spaceUsed;
_log.info(String.format("ProvisionedCapacity:%s ,TotalQuota:%s , TotalSizeUsed:%s, RequestedSize:%s, VolCapacity:%s", (long) (vol.getProvisionedCapacity() / GB), objQuota.getTotalQuota(), totalSizeUsed, (long) (requestedSize / GB), (long) vol.getCapacity() / GB));
if ((objQuota.getTotalQuota() != QuotaService.DEFAULT_VOLUME_TYPE_TOTALGB_QUOTA) && (objQuota.getTotalQuota() <= (totalSizeUsed + ((long) (requestedSize / GB) - (long) (vol.getProvisionedCapacity() / GB)))))
return false;
else
return true;
}
Aggregations