Search in sources :

Example 1 with QuotaUpdateParam

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

the class VirtualPoolCommonForm method saveQuota.

/**
 * Saves the quota value using the provided QuotaResources (either the block or file virtual pool resources).
 *
 * @param resources
 *            the resources on which to save the quota.
 */
protected void saveQuota(QuotaResources resources) {
    URI virtualPoolId = ResourceUtils.uri(id);
    if (virtualPoolId != null) {
        QuotaUpdateParam update = new QuotaUpdateParam(isTrue(enableQuota), quota);
        resources.updateQuota(virtualPoolId, update);
    }
}
Also used : QuotaUpdateParam(com.emc.storageos.model.quota.QuotaUpdateParam) URI(java.net.URI)

Example 2 with QuotaUpdateParam

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

the class TenantModificationTest method tenantAdminModifyTenantQuota.

@Test
public void tenantAdminModifyTenantQuota() throws Exception {
    QuotaUpdateParam quotaUpdateParam = new QuotaUpdateParam();
    quotaUpdateParam.setEnable(true);
    quotaUpdateParam.setQuotaInGb(50L);
    try {
        tenantAdminClient.tenants().updateQuota(rootTenantID, quotaUpdateParam);
        Assert.fail("TenantAdmin should has no permission to change tenant's quota");
    } catch (ServiceErrorException see) {
        Assert.assertEquals(see.getCode(), 3000);
        Assert.assertTrue(see.getMessage().contains("Insufficient permissions"));
    }
}
Also used : QuotaUpdateParam(com.emc.storageos.model.quota.QuotaUpdateParam) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) Test(org.junit.Test)

Example 3 with QuotaUpdateParam

use of com.emc.storageos.model.quota.QuotaUpdateParam 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)

Aggregations

QuotaUpdateParam (com.emc.storageos.model.quota.QuotaUpdateParam)3 Test (org.junit.Test)2 QuotaInfo (com.emc.storageos.model.quota.QuotaInfo)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1 URI (java.net.URI)1