Search in sources :

Example 66 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcControllerTest method testAddToSingleVdc.

/**
 * Adding vdc2 to vdc1
 */
// Test hanging in IDE and "gradlew test"
@Test
public void testAddToSingleVdc() throws Exception {
    dbClient.buildInitData(1);
    // Treat as Geo strategy options already set to remove Cassandra, preventing calling to
    // remote JMX
    dbClient.getGeoStrategyOptions().put("vdc2", "abc");
    VirtualDataCenter vdc1 = dbClient.vdcList.get(0);
    VirtualDataCenter newVdc = newVdcForAdding("vdc2");
    // dbClient.vdcList.add(newVdc);
    log.info("Testing connect vdc2 {} to vdc1 {}", newVdc.getShortId(), vdc1.getId());
    Properties vdcInfo = GeoServiceHelper.getVDCInfo(newVdc);
    String reqId = "taskid-0000";
    addTask(reqId, vdc1.getId());
    // Start execute vdc connect
    vdcController.connectVdc(vdc1, reqId, Arrays.asList(new Object[] { vdcInfo }));
    // Verify result
    URI newVDCId = null;
    Iterator<URI> vdcIter = dbClient.queryByType(VirtualDataCenter.class, true).iterator();
    while (vdcIter.hasNext()) {
        URI id = vdcIter.next();
        String vdcId = URIUtil.parseVdcIdFromURI(id.toASCIIString());
        if (vdcId.equals("vdc2")) {
            newVDCId = id;
            break;
        }
    }
    Assert.assertNotNull(newVDCId);
    VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, newVDCId);
    Assert.assertNotNull(vdc);
    Assert.assertTrue(vdc.getShortId().equals("vdc2"));
    Assert.assertNotNull(vdc.getHostCount());
    Assert.assertNotNull(vdc.getHostIPv4AddressesMap());
    Assert.assertTrue(vdc.getHostIPv4AddressesMap().size() == 1);
    Assert.assertTrue(clientManager.client.countForSyncCall == 1);
}
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) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Test(org.junit.Test)

Example 67 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter 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 68 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter 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)

Example 69 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcConfigService method updateBlackListForReconnectedVdc.

private void updateBlackListForReconnectedVdc() {
    List<URI> vdcIds = dbClient.queryByType(VirtualDataCenter.class, true);
    dbClient.clearBlackList();
    log.info("After clear, get current black list {}", dbClient.getBlacklist());
    for (URI vdcId : vdcIds) {
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
        if (vdc.getConnectionStatus() == VirtualDataCenter.ConnectionStatus.DISCONNECTED) {
            log.info("Add vdc {} with status {} to blacklist", vdc.getId(), vdc.getConnectionStatus());
            dbClient.addVdcNodesToBlacklist(vdc);
        }
    }
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Example 70 with VirtualDataCenter

use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.

the class VdcConfigService method reconnectVdc.

private void reconnectVdc(String vdcId) throws Exception {
    URI id = new URI(vdcId);
    VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, id);
    vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.CONNECTED);
    dbClient.updateAndReindexObject(vdc);
    dbClient.removeVdcNodesFromBlacklist(vdc);
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Aggregations

VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)80 URI (java.net.URI)47 ArrayList (java.util.ArrayList)20 VdcConfig (com.emc.storageos.geomodel.VdcConfig)14 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)13 Test (org.junit.Test)10 Site (com.emc.storageos.coordinator.client.model.Site)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 VdcConfigSyncParam (com.emc.storageos.geomodel.VdcConfigSyncParam)7 FatalGeoException (com.emc.storageos.security.geo.exceptions.FatalGeoException)7 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 Produces (javax.ws.rs.Produces)5 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 DataObject (com.emc.storageos.db.client.model.DataObject)4 TestGeoObject (com.emc.storageos.db.client.model.TestGeoObject)4 ConnectionException (com.netflix.astyanax.connectionpool.exceptions.ConnectionException)4 KeyStoreException (java.security.KeyStoreException)4 POST (javax.ws.rs.POST)4 Path (javax.ws.rs.Path)4