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"));
}
}
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"));
}
}
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);
}
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;
}
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);
}
}
Aggregations