use of com.emc.storageos.db.client.model.VirtualDataCenterInUse in project coprhd-controller by CoprHD.
the class InternalVdcService method setVdcInUse.
@PUT
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response setVdcInUse(@PathParam("id") URI id, @QueryParam("inuse") Boolean inUse) {
ArgValidator.checkUri(id);
VirtualDataCenterInUse vdcInUse = _dbClient.queryObject(VirtualDataCenterInUse.class, id);
if (vdcInUse == null) {
vdcInUse = new VirtualDataCenterInUse();
vdcInUse.setId(id);
vdcInUse.setInUse(inUse);
_dbClient.createObject(vdcInUse);
} else {
vdcInUse.setInUse(inUse);
_dbClient.updateAndReindexObject(vdcInUse);
}
return Response.ok().build();
}
use of com.emc.storageos.db.client.model.VirtualDataCenterInUse in project coprhd-controller by CoprHD.
the class VdcControllerTest method testRemoveVdcInUsePreCheck.
/**
* Remove vdc2 from vdc1
*/
// Test hanging in IDE and "gradlew test"
@Test
public void testRemoveVdcInUsePreCheck() throws Exception {
// create a mock db with 2 existing vdc
dbClient.buildInitData(2);
VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
VirtualDataCenter vdc2 = dbClient.vdcList.get(1);
log.info("Testing precheck for removing vdc2 {} from vdc1 {}", vdc2.getId(), vdc1.getId());
VirtualDataCenterInUse vdcInUse = new VirtualDataCenterInUse();
vdcInUse.setId(vdc2.getId());
vdcInUse.setInUse(true);
dbClient.createObject(vdcInUse);
// Start execute vdc remove
try {
String reqId = "remove-taskid-0003";
addTask(reqId, vdc2.getId());
vdcController.removeVdc(vdc2, reqId, null);
Assert.assertTrue("Precheck should throw an exception", false);
} catch (Exception ex) {
log.error("precheck error ", ex);
Assert.assertTrue(ex instanceof FatalGeoException);
}
}
Aggregations