Search in sources :

Example 1 with QuotaInfo

use of com.emc.storageos.model.quota.QuotaInfo in project coprhd-controller by CoprHD.

the class TenantsService method getQuota.

private QuotaInfo getQuota(TenantOrg tenant) {
    QuotaInfo quotaInfo = new QuotaInfo();
    double capacity = CapacityUtils.getTenantCapacity(_dbClient, tenant.getId());
    quotaInfo.setQuotaInGb(tenant.getQuota());
    quotaInfo.setEnabled(tenant.getQuotaEnabled());
    quotaInfo.setCurrentCapacityInGb((long) Math.ceil(capacity / CapacityUtils.GB));
    quotaInfo.setLimitedResource(DbObjectMapper.toNamedRelatedResource(tenant));
    return quotaInfo;
}
Also used : QuotaInfo(com.emc.storageos.model.quota.QuotaInfo)

Example 2 with QuotaInfo

use of com.emc.storageos.model.quota.QuotaInfo in project coprhd-controller by CoprHD.

the class VirtualPoolCommonForm method loadQuota.

/**
 * Loads the quota information from the provide QuotaResources (either the block or file virtual pool resources).
 *
 * @param resources
 *            the resources from which to load the quota.
 */
protected void loadQuota(QuotaResources resources) {
    URI virtualPoolId = ResourceUtils.uri(id);
    if (virtualPoolId != null) {
        QuotaInfo quotaInfo = resources.getQuota(virtualPoolId);
        if (quotaInfo != null) {
            enableQuota = quotaInfo.getEnabled();
            quota = quotaInfo.getQuotaInGb();
        }
    }
}
Also used : QuotaInfo(com.emc.storageos.model.quota.QuotaInfo) URI(java.net.URI)

Example 3 with QuotaInfo

use of com.emc.storageos.model.quota.QuotaInfo in project coprhd-controller by CoprHD.

the class Projects method edit.

@FlashException(value = "list", keep = true)
public static void edit(String id) {
    ProjectRestRep viprProject = ProjectUtils.getProject(id);
    if (viprProject == null) {
        flash.error(MessagesUtils.get(UNKNOWN, id));
        list();
    }
    QuotaInfo quota = null;
    if (Security.isTenantAdmin()) {
        quota = ProjectUtils.getQuota(id);
    }
    if (viprProject != null) {
        ProjectForm project = new ProjectForm().from(viprProject, quota);
        project.aclEntries = AclEntryForm.loadAclEntryForms(ProjectUtils.getACLs(id));
        addRenderArgs();
        render(project);
    } else {
        flash.error(MessagesUtils.get("projects.unknown", id));
        list();
    }
}
Also used : QuotaInfo(com.emc.storageos.model.quota.QuotaInfo) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep) FlashException(controllers.util.FlashException)

Example 4 with QuotaInfo

use of com.emc.storageos.model.quota.QuotaInfo in project coprhd-controller by CoprHD.

the class TenantModificationTest method securityAdminModifyTenantQuota.

@Test
public void securityAdminModifyTenantQuota() throws Exception {
    QuotaInfo original = secAdminClient.tenants().getQuota(rootTenantID);
    QuotaUpdateParam quotaUpdateParam = new QuotaUpdateParam();
    quotaUpdateParam.setEnable(true);
    quotaUpdateParam.setQuotaInGb(50L);
    secAdminClient.tenants().updateQuota(rootTenantID, quotaUpdateParam);
    // restore quota
    quotaUpdateParam.setEnable(original.getEnabled());
    quotaUpdateParam.setQuotaInGb(original.getQuotaInGb());
    secAdminClient.tenants().updateQuota(rootTenantID, quotaUpdateParam);
// should no exception
}
Also used : QuotaInfo(com.emc.storageos.model.quota.QuotaInfo) QuotaUpdateParam(com.emc.storageos.model.quota.QuotaUpdateParam) Test(org.junit.Test)

Example 5 with QuotaInfo

use of com.emc.storageos.model.quota.QuotaInfo in project coprhd-controller by CoprHD.

the class ProjectService method getQuota.

private QuotaInfo getQuota(Project project) {
    QuotaInfo quotaInfo = new QuotaInfo();
    double capacity = CapacityUtils.getProjectCapacity(_dbClient, project.getId());
    quotaInfo.setQuotaInGb(project.getQuota());
    quotaInfo.setEnabled(project.getQuotaEnabled());
    quotaInfo.setCurrentCapacityInGb((long) Math.ceil(capacity / CapacityUtils.GB));
    quotaInfo.setLimitedResource(DbObjectMapper.toNamedRelatedResource(project));
    return quotaInfo;
}
Also used : QuotaInfo(com.emc.storageos.model.quota.QuotaInfo)

Aggregations

QuotaInfo (com.emc.storageos.model.quota.QuotaInfo)7 FlashException (controllers.util.FlashException)2 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)1 QuotaUpdateParam (com.emc.storageos.model.quota.QuotaUpdateParam)1 URI (java.net.URI)1 Test (org.junit.Test)1