Search in sources :

Example 51 with VirtualDataCenter

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

the class ConnectVdcTaskOp method configSync.

private void configSync(VdcConfigSyncParam mergedVdcInfo) throws Exception {
    // 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 config info", vdc.getShortId(), vdc.getApiEndpoint());
        if (vdc.getApiEndpoint() != null) {
            URI vdcId = operatedVdc.getId();
            if (vdc.getId().equals(vdcId)) {
                // vdc UUID assigned
                mergedVdcInfo.setAssignedVdcId(vdcId.toString());
                mergedVdcInfo.setGeoEncryptionKey(helper.getGeoEncryptionKey());
            } else {
                mergedVdcInfo.setAssignedVdcId(null);
                mergedVdcInfo.setGeoEncryptionKey(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");
        }
    }
    helper.addVdcToCassandraStrategyOptions(mergedVdcInfo.getVirtualDataCenters(), operatedVdc, false);
    // notify local vdc to apply the new vdc config info
    helper.syncVdcConfig(mergedVdcInfo.getVirtualDataCenters(), null, mergedVdcInfo.getVdcConfigVersion(), mergedVdcInfo.getIpsecKey());
    // update the current progress of connect vdc. the cluster would reboot later.
    updateOpStatus(ConnectionStatus.CONNECTING_SYNCED);
    helper.triggerVdcConfigUpdate(mergedVdcInfo.getVdcConfigVersion(), SiteInfo.GEO_OP_CONFIG_CHANGE);
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Example 52 with VirtualDataCenter

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

the class ConnectVdcTaskOp method preCheck.

/**
 * Check whether geo could accept the new vdc or not
 */
private VdcPreCheckResponse preCheck() {
    log.info("Starting precheck on vdc connect ...");
    // avoid to send preCheck from v2.3 or higher to v2.2 v2.1, v2.0
    if (!isRemoteVdcVersionCompatible(vdcInfo)) {
        throw GeoException.fatals.connectVdcPrecheckFail(myVdcId, "Software version from remote vdc is lower than v2.3.");
    }
    log.info("Send vdc precheck to remote vdc");
    // step 1: 2 way communication to verify if link should be permitted
    VdcPreCheckResponse vdcResp = sendVdcPrecheckRequest(vdcInfo, true);
    log.info("Check VIP of remote vdc is used as the ApiEndpoint");
    // verify if node IP address is used as the ApiEndpoint
    String virtualIP = vdcInfo.getProperty(GeoServiceJob.VDC_API_ENDPOINT);
    if (!InetAddresses.isInetAddress(virtualIP)) {
        // FQDN used
        log.info("FQDN or hostname used: {}", virtualIP);
        try {
            virtualIP = InetAddress.getByName(vdcInfo.getProperty(GeoServiceJob.VDC_API_ENDPOINT)).getHostAddress();
            // replace with real IP
            vdcInfo.setProperty(GeoServiceJob.VDC_API_ENDPOINT, virtualIP);
            log.info("virtual ip of new vdc {}", virtualIP);
        } catch (UnknownHostException e) {
            throw GeoException.fatals.invalidFQDNEndPoint(vdcInfo.getProperty(GeoServiceJob.VDC_NAME), virtualIP);
        }
    }
    if (vdcResp.getHostIPv4AddressesMap().containsValue(virtualIP) || vdcResp.getHostIPv6AddressesMap().containsValue(virtualIP)) {
        throw GeoException.fatals.wrongIPSpecification(vdcInfo.getProperty(GeoServiceJob.VDC_NAME));
    }
    log.info("Check vdc stable");
    // check if the cluster is stable
    if (!vdcResp.isClusterStable()) {
        throw GeoException.fatals.unstableVdcFailure(vdcInfo.getProperty(GeoServiceJob.VDC_NAME));
    }
    URI unstable = checkAllVdcStable(false, false);
    if (unstable != null) {
        VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, unstable);
        String vdcName = (vdc != null) ? vdc.getLabel() : "";
        throw GeoException.fatals.unstableVdcFailure(vdcName);
    }
    log.info("vdc config retrieved: vip={}, IPv4Addresses={}, IPv6Addresses={} isHasData={}", new Object[] { vdcResp.getApiEndpoint(), vdcResp.getHostIPv4AddressesMap(), vdcResp.getHostIPv6AddressesMap(), vdcResp.isHasData() });
    if (vdcResp.isHasData()) {
        throw GeoException.fatals.remoteVDCContainData();
    }
    // verify the software version compatibility
    if (!isGeoCompatible(vdcResp)) {
        throw GeoException.fatals.remoteVDCInLowerVersion();
    }
    if (hasTripleVdcVersionsInFederation(vdcResp)) {
        throw GeoException.fatals.hasTripleVDCVersionsInFederation();
    }
    if (!isCompatibleVersion(vdcResp)) {
        throw GeoException.fatals.remoteVDCIncompatibleVersion();
    }
    if (!checkNodeConnectivity(vdcResp)) {
        throw GeoException.fatals.failedToCheckConnectivity(errMsg);
    }
    return vdcResp;
}
Also used : VdcPreCheckResponse(com.emc.storageos.geomodel.VdcPreCheckResponse) UnknownHostException(java.net.UnknownHostException) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) URI(java.net.URI)

Example 53 with VirtualDataCenter

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

the class ConnectVdcTaskOp method statusUpdate.

private void statusUpdate() {
    // step 5: update vdc connection status if post check succeed at each site
    List<VirtualDataCenter> vdcList = getToBeSyncedVdc();
    // fill the check param
    VdcPostCheckParam checkParam = new VdcPostCheckParam();
    checkParam.setConfigChangeType(changeType().toString());
    checkParam.setRootTenantId(helper.getVdcRootTenantId());
    // all connected vdc
    List<URI> vdcIds = new ArrayList<>();
    for (VirtualDataCenter vdc : vdcList) {
        vdcIds.add(vdc.getId());
    }
    vdcIds.add(myVdc.getId());
    checkParam.setVdcList(vdcIds);
    log.info("status update to {}", checkParam.getVdcList());
    sendPostCheckMsg(vdcList, checkParam);
}
Also used : VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) ArrayList(java.util.ArrayList) VdcPostCheckParam(com.emc.storageos.geomodel.VdcPostCheckParam) URI(java.net.URI)

Example 54 with VirtualDataCenter

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

the class ConnectVdcTaskOp method checkNodeConnectivity.

private boolean checkNodeConnectivity(VdcPreCheckResponse vdcBeingAdded) {
    // check to make sure the current vdc can connect to all nodes on the vdc being added
    if (!helper.areNodesReachable(vdcBeingAdded.getShortId(), vdcBeingAdded.getHostIPv4AddressesMap(), vdcBeingAdded.getHostIPv6AddressesMap(), false)) {
        errMsg = String.format("Current vdc, %s, cannot reach all nodes of vdc being added", myVdc.getLabel());
        log.error(errMsg);
        return false;
    }
    // check to make sure the vdc being added can connect to the current and all other vdc's
    log.info("sending node check request to vdc: {}", vdcInfo.getProperty(GeoServiceJob.OPERATED_VDC_ID));
    VdcNodeCheckResponse vdcResp = sendVdcNodeCheckRequest(vdcInfo, connectedVdc);
    if (!vdcResp.isNodesReachable()) {
        errMsg = "vdc to be added cannot connect to all nodes of at least one of the vdcs in the federation";
        log.error(errMsg);
        return false;
    }
    // check to make sure the vdc being added can connect to the current and all other vdc's
    List<VdcConfig> vdcConfigs = new ArrayList<VdcConfig>();
    vdcConfigs.add(mergeVdcInfo(vdcBeingAdded));
    for (VirtualDataCenter other : connectedVdc) {
        if (other.getShortId().equals(myVdc.getShortId())) {
            continue;
        }
        log.info("sending node check request to vdc: {}", other.getShortId());
        vdcResp = sendVdcNodeCheckRequest(GeoServiceHelper.getVDCInfo(other), vdcConfigs);
        if (!vdcResp.isNodesReachable()) {
            errMsg = String.format("vdc, %s, cannot connect to all nodes of the vdc being added", other.getLabel());
            log.error(errMsg);
            return false;
        }
    }
    errMsg = checkNetworkTopology(vdcBeingAdded);
    if (errMsg != null && errMsg.length() > 0) {
        return false;
    }
    return true;
}
Also used : VdcNodeCheckResponse(com.emc.storageos.geomodel.VdcNodeCheckResponse) VdcConfig(com.emc.storageos.geomodel.VdcConfig) ArrayList(java.util.ArrayList) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 55 with VirtualDataCenter

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

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