Search in sources :

Example 11 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException 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 12 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class TenantModificationTest method tenantAdminModifyUserMapping.

@Test
public void tenantAdminModifyUserMapping() throws Exception {
    TenantUpdateParam tenantUpdateParam = new TenantUpdateParam();
    UserMappingChanges changes = new UserMappingChanges();
    List<UserMappingParam> listAdd = new ArrayList<UserMappingParam>();
    UserMappingParam param = new UserMappingParam();
    param.setDomain("Not Exist");
    listAdd.add(param);
    changes.setAdd(listAdd);
    tenantUpdateParam.setUserMappingChanges(changes);
    try {
        tenantAdminClient.tenants().update(rootTenantID, tenantUpdateParam);
        Assert.fail("Tenant admin should has no permission to modify tenant's user mapping");
    } catch (ServiceErrorException see) {
        Assert.assertEquals(see.getCode(), 3000);
        Assert.assertTrue(see.getMessage().contains("Only users with SECURITY_ADMIN role can"));
    }
}
Also used : UserMappingChanges(com.emc.storageos.model.tenant.UserMappingChanges) UserMappingParam(com.emc.storageos.model.tenant.UserMappingParam) ArrayList(java.util.ArrayList) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) TenantUpdateParam(com.emc.storageos.model.tenant.TenantUpdateParam) Test(org.junit.Test)

Example 13 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class BlockStorageUtils method removeExportIfEmpty.

public static void removeExportIfEmpty(URI exportId) {
    boolean retryNeeded = false;
    int retryCount = 0;
    do {
        retryNeeded = false;
        ExportGroupRestRep export = getExport(exportId);
        if (ResourceUtils.isActive(export) && export.getVolumes().isEmpty()) {
            try {
                log.info(String.format("Attampting deletion of ExportGroup %s (%s)", export.getGeneratedName(), export.getId()));
                Task<ExportGroupRestRep> response = execute(new DeactivateBlockExport(exportId));
                addAffectedResource(response);
            } catch (ExecutionException e) {
                if (e.getCause() instanceof ServiceErrorException) {
                    ServiceErrorException svcexp = (ServiceErrorException) e.getCause();
                    if (retryCount++ < MAX_RETRY_COUNT && ServiceCode.toServiceCode(svcexp.getCode()) == ServiceCode.API_TASK_EXECUTION_IN_PROGRESS) {
                        log.info(String.format("ExportGroup %s deletion waiting on pending task execution", export.getId()));
                        retryNeeded = true;
                        try {
                            Thread.sleep(RETRY_DELAY_MSEC);
                        } catch (InterruptedException ex) {
                            log.debug("Sleep interrupted");
                        }
                    } else {
                        throw e;
                    }
                }
            }
        }
    } while (retryNeeded);
}
Also used : DeactivateBlockExport(com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport) ExportGroupRestRep(com.emc.storageos.model.block.export.ExportGroupRestRep) ExecutionException(com.emc.sa.engine.ExecutionException) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Example 14 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class CreateMultipleBlockVolumes method doExecute.

@Override
public Tasks<VolumeRestRep> doExecute() throws Exception {
    Set<String> errorMessages = Sets.newHashSet();
    Tasks<VolumeRestRep> tasks = null;
    for (CreateBlockVolumeHelper param : helpers) {
        String volumeSize = BlockStorageUtils.gbToVolumeSize(param.getSizeInGb());
        VolumeCreate create = new VolumeCreate();
        create.setVpool(param.getVirtualPool());
        create.setVarray(param.getVirtualArray());
        create.setProject(param.getProject());
        create.setName(param.getName());
        create.setSize(volumeSize);
        create.setComputeResource(param.getComputeResource());
        create.setPortGroup(param.getPortGroup());
        int numberOfVolumes = 1;
        if ((param.getCount() != null) && (param.getCount() > 1)) {
            numberOfVolumes = param.getCount();
        }
        create.setCount(numberOfVolumes);
        create.setConsistencyGroup(param.getConsistencyGroup());
        try {
            if (tasks == null) {
                tasks = getClient().blockVolumes().create(create);
            } else {
                tasks.getTasks().addAll(getClient().blockVolumes().create(create).getTasks());
            }
        } catch (ServiceErrorException ex) {
            errorMessages.add(ex.getDetailedMessage());
            logError(getMessage("CreateMultipleBlockVolumes.getTask.error", create.getName(), ex.getDetailedMessage()));
        }
    }
    if (tasks == null) {
        throw stateException("CreateMultipleBlockVolumes.illegalState.invalid", Joiner.on('\n').join(errorMessages));
    }
    return tasks;
}
Also used : VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) CreateBlockVolumeHelper(com.emc.sa.service.vipr.block.CreateBlockVolumeHelper) VolumeCreate(com.emc.storageos.model.block.VolumeCreate)

Example 15 with ServiceErrorException

use of com.emc.vipr.client.exceptions.ServiceErrorException in project coprhd-controller by CoprHD.

the class VdcApiProxyUserTest method testUpdateVdcWithProxyUser_neg.

@Test
public void testUpdateVdcWithProxyUser_neg() throws Exception {
    URI vdcId = proxyClient.vdcs().getAll().get(0).getId();
    VirtualDataCenterModifyParam modifyParam = new VirtualDataCenterModifyParam();
    modifyParam.setDescription("modified description");
    try {
        proxyClient.vdcs().update(vdcId, modifyParam);
        Assert.fail("proxy user update vdc should fail");
    } catch (ServiceErrorException se) {
        Assert.assertEquals(se.getHttpCode(), 403);
    }
}
Also used : ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) URI(java.net.URI) VirtualDataCenterModifyParam(com.emc.storageos.model.vdc.VirtualDataCenterModifyParam) Test(org.junit.Test)

Aggregations

ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)26 Test (org.junit.Test)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)5 ArrayList (java.util.ArrayList)5 UnManagedVolumeRestRep (com.emc.storageos.model.block.UnManagedVolumeRestRep)4 URI (java.net.URI)4 ViPRException (com.emc.vipr.client.exceptions.ViPRException)3 VolumeCreate (com.emc.storageos.model.block.VolumeCreate)2 ServiceErrorRestRep (com.emc.storageos.model.errorhandling.ServiceErrorRestRep)2 TenantUpdateParam (com.emc.storageos.model.tenant.TenantUpdateParam)2 UserMappingChanges (com.emc.storageos.model.tenant.UserMappingChanges)2 UserMappingParam (com.emc.storageos.model.tenant.UserMappingParam)2 ViPRClientHelper (com.emc.storageos.usermanagement.util.ViPRClientHelper)2 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)2 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)2 FlashException (controllers.util.FlashException)2 ACLUpdateBuilder (util.builders.ACLUpdateBuilder)2 ExecutionException (com.emc.sa.engine.ExecutionException)1 CreateBlockVolumeHelper (com.emc.sa.service.vipr.block.CreateBlockVolumeHelper)1 DeactivateBlockExport (com.emc.sa.service.vipr.block.tasks.DeactivateBlockExport)1