Search in sources :

Example 61 with VirtualDataCenter

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

the class RemoveVdcTaskOp method updateConfigForConnectedVdc.

/**
 * Update new vdc config for all sites - exclude the site to be removed
 */
private void updateConfigForConnectedVdc() {
    // build new vdc config without operatedVdc
    List<VirtualDataCenter> newVdcList = new ArrayList<>();
    for (VirtualDataCenter vdc : getAllVdc()) {
        if (!vdc.getId().equals(operatedVdc.getId())) {
            // ignore the one to be removed
            newVdcList.add(vdc);
        }
    }
    log.info("number of vdc {} after removal", newVdcList.size());
    VdcConfigSyncParam syncParam = buildConfigParam(newVdcList);
    for (VirtualDataCenter vdc : connectedVdc) {
        if (vdc.getId().equals(myVdc.getId()) || vdc.getId().equals(operatedVdc.getId())) {
            // skip my current vdc and operated vdc
            continue;
        }
        geoClientCache.getGeoClient(vdc.getShortId()).syncVdcConfig(syncParam, vdc.getLabel());
    }
    dbClient.stopClusterGossiping();
    // set connection status to isolated if there is only one vdc in current geo system
    if (newVdcList.size() == 1) {
        if (!syncParam.getVirtualDataCenters().isEmpty()) {
            VdcConfig vdcConfig = syncParam.getVirtualDataCenters().get(0);
            vdcConfig.setConnectionStatus(ConnectionStatus.ISOLATED.toString());
            vdcConfig.setVersion(new Date().getTime());
        } else {
            log.error("Unexpected Vdc list size in sync config param");
        }
    }
    // update my local site with new config
    helper.syncVdcConfig(syncParam.getVirtualDataCenters(), null, syncParam.getVdcConfigVersion(), syncParam.getIpsecKey());
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VdcConfig(com.emc.storageos.geomodel.VdcConfig) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) Date(java.util.Date)

Example 62 with VirtualDataCenter

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

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

the class UpdateVdcTaskOp method mergeConfig.

private VdcConfigSyncParam mergeConfig(VdcPreCheckResponse operatedVdcInfo) {
    // step 2: merge the vdc config info of all sites, as the initiator
    // we should have all current vdc config info
    VdcConfigSyncParam vdcConfigList = new VdcConfigSyncParam();
    List<VdcConfig> list = vdcConfigList.getVirtualDataCenters();
    for (VirtualDataCenter vdc : getAllVdc()) {
        log.info("add {} to the merged vdc config", vdc.getShortId());
        VdcConfig vdcConfig = helper.toConfigParam(vdc);
        list.add(vdcConfig);
    }
    mergeVdcInfo(list, operatedVdc);
    return vdcConfigList;
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VdcConfig(com.emc.storageos.geomodel.VdcConfig) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 64 with VirtualDataCenter

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

the class UpdateVdcTaskOp method syncConfig.

private void syncConfig(VdcConfigSyncParam mergedVdcInfo) {
    // step 3: sync merged vdc config info to all sites in which property change triggered
    // all conf files updated after reboot.
    // the vdc to be connected will reset the db and update the network strategy when
    // startup.
    // loop all current connected VDCs with latest vdc config info, shall be moved into geoclient
    // geoclient shall responsible to retry all retryable errors, we have no need retry here
    log.info("sync vdc config to all sites, total vdc entries {}", mergedVdcInfo.getVirtualDataCenters().size());
    List<VirtualDataCenter> vdcList = getToBeSyncedVdc();
    for (VirtualDataCenter vdc : vdcList) {
        log.info("Loop vdc {}:{} to sync the latest vdc cert info", vdc.getShortId(), vdc.getApiEndpoint());
        if (vdc.getApiEndpoint() != null) {
            mergedVdcInfo.setAssignedVdcId(null);
            mergedVdcInfo.setConfigChangeType(changeType().toString());
            geoClientCache.getGeoClient(vdc.getShortId()).syncVdcConfig(mergedVdcInfo, vdc.getLabel());
            log.info("Sync vdc info succeed");
        } else {
            log.error("Fatal error: try to sync with a vdc without endpoint");
        }
    }
    // notify local vdc to apply the new vdc config info
    helper.syncVdcConfig(mergedVdcInfo.getVirtualDataCenters(), null, mergedVdcInfo.getVdcConfigVersion(), mergedVdcInfo.getIpsecKey());
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 65 with VirtualDataCenter

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

the class VdcControllerTest method testRemoveVdc.

/**
 * Remove vdc2 from vdc1
 */
// Test hanging in IDE and "gradlew test"
@Test
public void testRemoveVdc() 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 remove vdc2 {} from vdc1 {}", vdc2.getId(), vdc1.getId());
    // Start execute vdc remove
    vdc2.setConnectionStatus(VirtualDataCenter.ConnectionStatus.REMOVING);
    dbClient.updateAndReindexObject(vdc2);
    String reqId = "remove-taskid-0000";
    addTask(reqId, vdc2.getId());
    vdcController.removeVdc(vdc2, reqId, null);
    // Verify result
    Assert.assertTrue(dbClient.vdcList.size() == 1);
    VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdc1.getId());
    Assert.assertNotNull(vdc);
    Assert.assertTrue(vdc.getShortId().equals("vdc1"));
    Assert.assertNotNull(vdc.getHostCount());
    Assert.assertNotNull(vdc.getHostIPv4AddressesMap());
    Assert.assertTrue(clientManager.client.countForSyncCall == 1);
    // vdc2 should be removed
    vdc = dbClient.queryObject(VirtualDataCenter.class, vdc2.getId());
    Assert.assertNull(vdc);
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) Test(org.junit.Test)

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