Search in sources :

Example 1 with VdcPreCheckResponse2

use of com.emc.storageos.geomodel.VdcPreCheckResponse2 in project coprhd-controller by CoprHD.

the class VdcConfigService method toVirtualDataCenterResponse2.

private VdcPreCheckResponse2 toVirtualDataCenterResponse2(VirtualDataCenter from, boolean hasData, SoftwareVersion softVer) {
    if (from == null) {
        return null;
    }
    VdcPreCheckResponse2 to = new VdcPreCheckResponse2();
    to.setId(from.getId());
    to.setCompatible(helper.isCompatibleVersion(softVer));
    boolean clusterStable = isClusterStable();
    to.setClusterStable(clusterStable);
    log.info("current cluster stable {}", clusterStable);
    return to;
}
Also used : VdcPreCheckResponse2(com.emc.storageos.geomodel.VdcPreCheckResponse2)

Example 2 with VdcPreCheckResponse2

use of com.emc.storageos.geomodel.VdcPreCheckResponse2 in project coprhd-controller by CoprHD.

the class VdcConfigService method precheckVdcConfig.

/**
 * Do more precheck
 * For disconnecting a vdc, check if there is a VDC that is under disconnecting
 * If yes, return the VDC under disconnecting, otherwise set the VDC (given by parameter)
 * status to DISCONNECTING
 *
 * @param checkParam
 *
 * @return VdcPreCheckResponse
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/precheck2")
public VdcPreCheckResponse2 precheckVdcConfig(VdcPreCheckParam2 checkParam) {
    log.info("Start vdc config precheck2 for {} ...", checkParam.getConfigChangeType());
    if (service.getId().endsWith("standalone")) {
        throw GeoException.fatals.remoteVDCWrongStandaloneInstall();
    }
    VdcConfig.ConfigChangeType type = checkParam.getConfigChangeType();
    VirtualDataCenter vdc = null;
    VdcPreCheckResponse2 resp2 = new VdcPreCheckResponse2();
    resp2.setCompatible(true);
    // BZ
    // TODO Need to use a different method to update info on lock on a remote system.
    // Need to use a different field (not connection status of VDC object) as a locking mechanism)
    boolean precheckFailed = checkParam.isPrecheckFailed();
    switch(type) {
        case DISCONNECT_VDC:
            log.info("Precheck2 for disconnect ops");
            vdc = helper.getDisconnectingVdc();
            if (checkParam.getIsAllNotReachable()) {
                URI targetVdcId = checkParam.getVdcIds().get(0);
                log.info("Precheck2 to check the disconnect vdc {} is reachable", targetVdcId);
                VirtualDataCenter targetVdc = dbClient.queryObject(VirtualDataCenter.class, targetVdcId);
                Site activeSite = drUtil.getActiveSite(targetVdc.getShortId());
                resp2.setIsAllNodesNotReachable(!helper.areNodesReachable(getLocalVdc().getShortId(), activeSite.getHostIPv4AddressMap(), activeSite.getHostIPv6AddressMap(), checkParam.getIsAllNotReachable()));
                break;
            }
            if (precheckFailed) {
                log.info("Precheck2 to update reconnect precheck fail status");
                String vdcState = checkParam.getDefaultVdcState();
                if (StringUtils.isNotEmpty(vdcState)) {
                    vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.valueOf(vdcState));
                    dbClient.updateAndReindexObject(vdc);
                }
                break;
            }
            if (vdc == null) {
                // no DISCONNECTING_VDC
                log.info("Precheck2: there is no disconnecting vdc");
                URI srcVdcId = checkParam.getVdcIds().get(1);
                VirtualDataCenter srcVdc = dbClient.queryObject(VirtualDataCenter.class, srcVdcId);
                if (srcVdc.getConnectionStatus() == VirtualDataCenter.ConnectionStatus.DISCONNECTED) {
                    resp2.setCompatible(false);
                    break;
                }
                // BZ
                // TODO need to use a different field to set locks on concurrent VDC operation
                URI id = checkParam.getVdcIds().get(0);
                vdc = dbClient.queryObject(VirtualDataCenter.class, id);
                vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.DISCONNECTING);
                dbClient.updateAndReindexObject(vdc);
            } else {
                resp2 = toVirtualDataCenterResponse2(vdc, true, null);
            }
            break;
        case RECONNECT_VDC:
            log.info("Precheck2 for reconnect ops checkParam={}", checkParam);
            List<String> blackList = checkParam.getBlackList();
            List<String> whiteList = checkParam.getWhiteList();
            log.info("Precheck2 to check if two vdc disconnect each other");
            resp2.setCompatible(true);
            if (isDisconnectedEachOther(blackList, whiteList)) {
                log.info("Precheck2: two vdc have disconnected each other");
                resp2.setCompatible(false);
                break;
            }
            if (precheckFailed) {
                log.info("Precheck2 to update reconnect precheck fail status");
                URI targetVdcId = checkParam.getVdcIds().get(0);
                log.info("Precheck2 to check the disconnect vdc {} is reachable", targetVdcId);
                VirtualDataCenter targetVdc = dbClient.queryObject(VirtualDataCenter.class, targetVdcId);
                String vdcState = checkParam.getDefaultVdcState();
                if (StringUtils.isNotEmpty(vdcState)) {
                    targetVdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.valueOf(vdcState));
                    dbClient.updateAndReindexObject(targetVdc);
                }
                break;
            }
            break;
    }
    log.info("Precheck2 done, resp is {}", resp2.toString());
    return resp2;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) VdcConfig(com.emc.storageos.geomodel.VdcConfig) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) VdcPreCheckResponse2(com.emc.storageos.geomodel.VdcPreCheckResponse2) URI(java.net.URI) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Example 3 with VdcPreCheckResponse2

use of com.emc.storageos.geomodel.VdcPreCheckResponse2 in project coprhd-controller by CoprHD.

the class AbstractVdcTaskOp method isTargetVdcReachable.

/**
 * Make sure the vdc is reachable from any of the
 * connected VDCs
 */
protected boolean isTargetVdcReachable(int nodeCheckTimeout_ms) {
    log.info("Checking to see if the vdc {} is reachable from connected VDCs", operatedVdc.getShortId());
    // Go through the connected list
    for (VirtualDataCenter vdc : connectedVdc) {
        if (vdc.getConnectionStatus() == VirtualDataCenter.ConnectionStatus.DISCONNECTED) {
            // skip the disconnected VDC
            continue;
        }
        if (vdc.getId().equals(operatedVdc.getId())) {
            // skip the VDC to be disconnected
            continue;
        }
        if (vdc.getLocal()) {
            Site activeSite = drUtil.getActiveSite(operatedVdc.getShortId());
            if (helper.areNodesReachable(vdc.getShortId(), activeSite.getHostIPv4AddressMap(), activeSite.getHostIPv6AddressMap(), true)) {
                return true;
            }
            continue;
        }
        // non-local vdcs
        VdcPreCheckParam2 checkParam2 = new VdcPreCheckParam2();
        checkParam2.setConfigChangeType(VdcConfig.ConfigChangeType.DISCONNECT_VDC);
        List<URI> vdcIds = new ArrayList(1);
        vdcIds.add(operatedVdc.getId());
        checkParam2.setVdcIds(vdcIds);
        checkParam2.setIsAllNotReachable(true);
        try {
            VdcPreCheckResponse2 resp2 = sendVdcPrecheckRequest2(vdc, checkParam2, nodeCheckTimeout_ms);
            if (!resp2.getIsAllNodesNotReachable()) {
                errMsg = String.format("The vdc %s to be disconnected is still reachable from %s", operatedVdc.getShortId(), vdc.getShortId());
                log.error(errMsg);
                return true;
            }
        } catch (Exception e) {
            log.error("Failed to check the operatedVdc {} on the vdc {} e=", new Object[] { operatedVdc.getShortId(), vdc.getShortId(), e });
            continue;
        }
    }
    return false;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) VdcPreCheckResponse2(com.emc.storageos.geomodel.VdcPreCheckResponse2) 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)

Example 4 with VdcPreCheckResponse2

use of com.emc.storageos.geomodel.VdcPreCheckResponse2 in project coprhd-controller by CoprHD.

the class ReconnectVdcTaskOp method checkReconnectingVdc.

private void checkReconnectingVdc() {
    VdcPreCheckParam2 param = new VdcPreCheckParam2();
    param.setConfigChangeType(changeType());
    Map<String, List<String>> blackLists = dbClient.getBlacklist();
    List<String> blackList = new ArrayList();
    Collection<List<String>> lists = blackLists.values();
    for (List<String> list : lists) {
        blackList = list;
        // since all lists are same, so we only need the first one
        break;
    }
    param.setBlackList(blackList);
    List<String> whiteList = getWhiteList();
    param.setWhiteList(whiteList);
    List<URI> ids = new ArrayList(1);
    ids.add(myVdc.getId());
    param.setVdcIds(ids);
    log.info("checkReconnectingVdc param={}", param);
    VdcPreCheckResponse2 resp2 = null;
    try {
        resp2 = sendVdcPrecheckRequest2(operatedVdc, param, NODE_CHECK_TIMEOUT);
    } catch (Exception ex) {
        log.error("Precheck the reconnected vdc {} failed: {}", operatedVdc.getShortId(), ex);
        throw ex;
    }
    if (resp2.getCompatible() == false) {
        log.error("Precheck the reconnected vdc {} failed", operatedVdc.getShortId());
        throw GeoException.fatals.reconnectVdcIncompatible();
    }
    log.info("The precheck reconnect vdc {} is passed", operatedVdc.getShortId());
}
Also used : ArrayList(java.util.ArrayList) VdcPreCheckResponse2(com.emc.storageos.geomodel.VdcPreCheckResponse2) ArrayList(java.util.ArrayList) List(java.util.List) VdcPreCheckParam2(com.emc.storageos.geomodel.VdcPreCheckParam2) URI(java.net.URI) GeoException(com.emc.storageos.security.geo.exceptions.GeoException)

Example 5 with VdcPreCheckResponse2

use of com.emc.storageos.geomodel.VdcPreCheckResponse2 in project coprhd-controller by CoprHD.

the class DisconnectVdcTaskOp method checkDisconnectingConcurrency.

private void checkDisconnectingConcurrency() {
    // Reject the disconnect request if there is any vdc that is under disconnecting
    // check local db first
    VirtualDataCenter disconnectingVdc = helper.getDisconnectingVdc();
    if (disconnectingVdc != null) {
        log.error("There is already a VDC {} under disconnecting", disconnectingVdc.getId());
        throw GeoException.fatals.disconnectVdcConcurrentCheckFail(disconnectingVdc.getLabel());
    }
    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;
        }
        VdcPreCheckParam2 param = new VdcPreCheckParam2();
        param.setConfigChangeType(changeType());
        List<URI> vdcIds = new ArrayList(2);
        vdcIds.add(operatedVdc.getId());
        vdcIds.add(myVdc.getId());
        param.setVdcIds(vdcIds);
        log.info("'disconnect vdc' precheck2 paramerte={}", param);
        VdcPreCheckResponse2 resp2 = null;
        try {
            resp2 = sendVdcPrecheckRequest2(vdc, param, DEFAULT_NODE_CHECK_TIMEOUT);
        } catch (Exception ex) {
            log.error("Precheck the reconnected vdc {} failed: {}", operatedVdc.getShortId(), ex);
            notifyPrecheckFailed();
            throw ex;
        }
        if (resp2.getId() != null) {
            log.error("There is already a VDC {} under disconnecting", disconnectingVdc);
            notifyPrecheckFailed();
            throw GeoException.fatals.disconnectVdcConcurrentCheckFail(disconnectingVdc.getLabel());
        }
        if (resp2.getCompatible() == false) {
            log.error("The local vdc {} has been disconnected", myVdcId);
            throw GeoException.fatals.disconnectVdcInvalidStatus(myVdc.getLabel());
        }
    }
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) VdcPreCheckResponse2(com.emc.storageos.geomodel.VdcPreCheckResponse2) VdcPreCheckParam2(com.emc.storageos.geomodel.VdcPreCheckParam2) URI(java.net.URI) GeoException(com.emc.storageos.security.geo.exceptions.GeoException)

Aggregations

VdcPreCheckResponse2 (com.emc.storageos.geomodel.VdcPreCheckResponse2)5 URI (java.net.URI)4 VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)3 VdcPreCheckParam2 (com.emc.storageos.geomodel.VdcPreCheckParam2)3 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)3 ArrayList (java.util.ArrayList)3 Site (com.emc.storageos.coordinator.client.model.Site)2 VdcConfig (com.emc.storageos.geomodel.VdcConfig)1 FatalGeoException (com.emc.storageos.security.geo.exceptions.FatalGeoException)1 KeyStoreException (java.security.KeyStoreException)1 CertificateException (java.security.cert.CertificateException)1 List (java.util.List)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1