Search in sources :

Example 1 with VirtualDataCenterInUse

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();
}
Also used : VirtualDataCenterInUse(com.emc.storageos.db.client.model.VirtualDataCenterInUse) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 2 with VirtualDataCenterInUse

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);
    }
}
Also used : VirtualDataCenterInUse(com.emc.storageos.db.client.model.VirtualDataCenterInUse) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) FatalGeoException(com.emc.storageos.security.geo.exceptions.FatalGeoException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) BindException(java.net.BindException) ConnectionException(com.netflix.astyanax.connectionpool.exceptions.ConnectionException) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) FatalGeoException(com.emc.storageos.security.geo.exceptions.FatalGeoException) Test(org.junit.Test)

Aggregations

VirtualDataCenterInUse (com.emc.storageos.db.client.model.VirtualDataCenterInUse)2 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 FatalGeoException (com.emc.storageos.security.geo.exceptions.FatalGeoException)1 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)1 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)1 BindException (java.net.BindException)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Test (org.junit.Test)1