Search in sources :

Example 1 with FatalGeoException

use of com.emc.storageos.security.geo.exceptions.FatalGeoException 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)

Example 2 with FatalGeoException

use of com.emc.storageos.security.geo.exceptions.FatalGeoException in project coprhd-controller by CoprHD.

the class RemoveVdcTaskOp method updateConfigForRemovedVdc.

/**
 * Update new vdc config for the site to be remove - only include itself
 */
private void updateConfigForRemovedVdc(boolean ignoreException) {
    operatedVdc.setConnectionStatus(ConnectionStatus.ISOLATED);
    operatedVdc.setRepStatus(GeoReplicationStatus.REP_NONE);
    operatedVdc.setVersion(new Date().getTime());
    List<VirtualDataCenter> localVdcList = new ArrayList<>(1);
    localVdcList.add(operatedVdc);
    VdcConfigSyncParam syncParam = buildConfigParam(localVdcList);
    log.info("send {} to removed vdc {}", syncParam, operatedVdc.getShortId());
    try {
        geoClientCache.getGeoClient(operatedVdc.getShortId()).syncVdcConfig(syncParam, operatedVdc.getLabel());
    } catch (FatalGeoException e) {
        if (!ignoreException) {
            throw e;
        }
    }
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) Date(java.util.Date) FatalGeoException(com.emc.storageos.security.geo.exceptions.FatalGeoException)

Example 3 with FatalGeoException

use of com.emc.storageos.security.geo.exceptions.FatalGeoException in project coprhd-controller by CoprHD.

the class VdcControllerTest method testAddVdcPrecheckFailure.

// Test hanging in IDE and "gradlew test"
@Test
public void testAddVdcPrecheckFailure() throws Exception {
    // create a mock db with 2 existing vdc
    dbClient.buildInitData(2);
    VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
    vdc1.setConnectionStatus(VirtualDataCenter.ConnectionStatus.CONNECTING);
    VirtualDataCenter newVdc = newVdcForAdding("vdc2");
    log.info("Testing connect vdc2 {} to vdc1 {}", newVdc.getShortId(), vdc1.getId());
    // Start execute vdc connect
    try {
        Properties vdcInfo = GeoServiceHelper.getVDCInfo(newVdc);
        String reqId = "taskid-0003";
        addTask(reqId, vdc1.getId());
        // Start execute vdc connect
        vdcController.connectVdc(vdc1, reqId, Arrays.asList(new Object[] { vdcInfo }));
        Assert.assertTrue("Precheck should throw an exception", false);
    } catch (Exception ex) {
        log.error("precheck error ", ex);
        Assert.assertTrue(ex instanceof FatalGeoException);
    }
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) DataObject(com.emc.storageos.db.client.model.DataObject) TestGeoObject(com.emc.storageos.db.client.model.TestGeoObject) Properties(java.util.Properties) 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)

Example 4 with FatalGeoException

use of com.emc.storageos.security.geo.exceptions.FatalGeoException in project coprhd-controller by CoprHD.

the class VdcControllerTest method testRemoveVdcPreCheck.

/**
 * Remove vdc2 from vdc1
 */
// Test hanging in IDE and "gradlew test"
@Test
public void testRemoveVdcPreCheck() 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());
    // create a geo object referencing a geo visible object in vdc2
    TestGeoObject obj = new TestGeoObject();
    obj.setId(URIUtil.createId(TestGeoObject.class));
    String varrayId = URIUtil.createId(VirtualArray.class).toString();
    varrayId = varrayId.replace("vdc1", "vdc2");
    obj.setVarray(new URI(varrayId));
    dbClient.testGeoList.add(obj);
    // Start execute vdc remove
    try {
        String reqId = "remove-taskid-0002";
        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 : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) TestGeoObject(com.emc.storageos.db.client.model.TestGeoObject) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) 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

VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)4 FatalGeoException (com.emc.storageos.security.geo.exceptions.FatalGeoException)4 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)3 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)3 BindException (java.net.BindException)3 Test (org.junit.Test)3 TestGeoObject (com.emc.storageos.db.client.model.TestGeoObject)2 DataObject (com.emc.storageos.db.client.model.DataObject)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)1 VirtualDataCenterInUse (com.emc.storageos.db.client.model.VirtualDataCenterInUse)1 VdcConfigSyncParam (com.emc.storageos.geomodel.VdcConfigSyncParam)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Properties (java.util.Properties)1