Search in sources :

Example 21 with VirtualDataCenter

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

the class VdcConfigHelper method areNodesReachable.

/**
 * tries to connect to each node in each vdc
 *
 * @param vdcId - the Id of the target VDC
 * @return true if all nodes of the target Vdc is reachable
 */
public boolean areNodesReachable(URI vdcId) {
    if (vdcId == null) {
        throw new IllegalArgumentException("The target Vdc short ID should not be null or empty");
    }
    VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
    Site activeSite = drUtil.getActiveSite(vdc.getShortId());
    if (areNodesReachable(vdc.getShortId(), activeSite.getHostIPv4AddressMap(), activeSite.getHostIPv6AddressMap(), false)) {
        return true;
    }
    return false;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 22 with VirtualDataCenter

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

the class VdcConfigHelper method getDisconnectedVirtualDataCenter.

private VirtualDataCenter getDisconnectedVirtualDataCenter(VdcPostCheckParam checkParam) {
    List<URI> vdcIds = checkParam.getVdcList();
    if (vdcIds.size() != 1) {
        String errMsg = String.format("There are more than one disconnected VDCs:%s", vdcIds.toString());
        throw new IllegalArgumentException(errMsg);
    }
    URI vdcId = vdcIds.get(0);
    VirtualDataCenter disconnectedVdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
    if (disconnectedVdc == null) {
        throw GeoException.fatals.disconnectVdcFailed(vdcId, new Exception("The disconnected vdc can't be found"));
    }
    return disconnectedVdc;
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI) KeyStoreException(java.security.KeyStoreException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) SecurityException(com.emc.storageos.security.exceptions.SecurityException) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException)

Example 23 with VirtualDataCenter

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

the class VdcConfigHelper method addVdcToCassandraStrategyOptions.

public void addVdcToCassandraStrategyOptions(List<VdcConfig> vdcConfigs, VirtualDataCenter vdc, boolean wait) throws Exception {
    log.info("add vdc {} to strategy options");
    for (VdcConfig vdcCfg : vdcConfigs) {
        if (vdcCfg.getId().equals(vdc.getId())) {
            log.info("find the vdc cfg {}", vdcCfg);
            // update the VirtualDataCenter object of the vdc
            mergeVdcConfig(vdcCfg);
            vdc = dbClient.queryObject(VirtualDataCenter.class, vdc.getId());
            addStrategyOption(vdc, wait);
            break;
        }
    }
}
Also used : VdcConfig(com.emc.storageos.geomodel.VdcConfig) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 24 with VirtualDataCenter

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

the class AbstractVdcTaskOp method updateVdcStatus.

/*
     * 
     * This function only used for reconnect and disconnect
     * Input parameter should be CONNECTED or DISCONNECTED
     * 
     * @param isSyncOperatedVdc, only used for reconnect operation to sync operated vdc, it will trigger a node repair.
     */
protected void updateVdcStatus(VirtualDataCenter.ConnectionStatus status, boolean isSyncOperatedVdc) {
    updateOpStatus(status);
    VdcConfig.ConfigChangeType configChangeType;
    log.info("the connection status is {}", status);
    switch(status) {
        case CONNECTED:
            configChangeType = VdcConfig.ConfigChangeType.RECONNECT_VDC;
            break;
        case DISCONNECTED:
            configChangeType = VdcConfig.ConfigChangeType.DISCONNECT_VDC;
            break;
        default:
            throw FatalGeoException.fatals.vdcWrongStatus(status.toString());
    }
    for (VirtualDataCenter vdc : allVdc) {
        if (vdc.getId().equals(operatedVdc.getId()) && (configChangeType == VdcConfig.ConfigChangeType.RECONNECT_VDC)) {
            vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.CONNECTED);
            break;
        }
    }
    VdcConfigSyncParam syncParam = buildConfigParam(allVdc);
    syncParam.setAssignedVdcId(operatedVdc.getId().toString());
    List<VirtualDataCenter> vdcsToBeSynced = new ArrayList<>();
    if (isSyncOperatedVdc) {
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, operatedVdc.getId());
        vdcsToBeSynced.add(vdc);
        log.info("Update vdc config for operated vdc {}", operatedVdc);
    } else {
        vdcsToBeSynced = getToBeSyncedVdc();
        if (doesContainOperatedVdc()) {
            log.info("Remove operatedVdc {} from the list {}", operatedVdc, vdcsToBeSynced);
            vdcsToBeSynced = removeOperatedVdc(vdcsToBeSynced);
        }
        log.info("Update vdc status {} to connected vdcs={}", operatedVdc, vdcsToBeSynced);
    }
    sendSyncVdcConfigMsg(vdcsToBeSynced, syncParam);
}
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)

Example 25 with VirtualDataCenter

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

the class AbstractVdcTaskOp method notifyPrecheckFailed.

protected void notifyPrecheckFailed() {
    if (operatedVdc == null) {
        return;
    }
    for (VirtualDataCenter vdc : connectedVdc) {
        if (operatedVdc.getId().equals(vdc.getId()) || myVdcId.equals(vdc.getId().toString())) {
            // Don't check on the vdc to be disconnected and myself
            continue;
        }
        try {
            // BZ
            // TODO need to have a different REST call to modify state of a remote VDC; PrecheckRequest2 should be used to check remote
            // VDC.
            // TODO need to have a different locking mecanism to set lock against concurrent VDC operations.
            VdcPreCheckParam2 param = new VdcPreCheckParam2();
            param.setConfigChangeType(changeType());
            List<URI> ids = new ArrayList(1);
            ids.add(operatedVdc.getId());
            param.setVdcIds(ids);
            param.setPrecheckFailed(true);
            param.setDefaultVdcState(operatedVdcStatus.toString());
            sendVdcPrecheckRequest2(vdc, param, DEFAULT_NODE_CHECK_TIMEOUT);
        } catch (Exception ex) {
            log.error("Failed to notify vdc : {} that recheckFaled ", vdc.getShortId());
        }
    }
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) VdcPreCheckParam2(com.emc.storageos.geomodel.VdcPreCheckParam2) URI(java.net.URI) KeyStoreException(java.security.KeyStoreException) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) CertificateException(java.security.cert.CertificateException) FatalGeoException(com.emc.storageos.security.geo.exceptions.FatalGeoException)

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