Search in sources :

Example 6 with UsageStats

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;
}
Also used : QuotaOfCinder(com.emc.storageos.db.client.model.QuotaOfCinder) UsageStats(com.emc.storageos.cinder.model.UsageStats)

Aggregations

UsageStats (com.emc.storageos.cinder.model.UsageStats)6 QuotaOfCinder (com.emc.storageos.db.client.model.QuotaOfCinder)4 Project (com.emc.storageos.db.client.model.Project)3 URI (java.net.URI)2 CinderLimits (com.emc.storageos.cinder.model.CinderLimits)1 CinderUsage (com.emc.storageos.cinder.model.CinderUsage)1 UsageAndLimits (com.emc.storageos.cinder.model.UsageAndLimits)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)1 Volume (com.emc.storageos.db.client.model.Volume)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1