Search in sources :

Example 1 with VdcConfigSyncParam

use of com.emc.storageos.geomodel.VdcConfigSyncParam 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 2 with VdcConfigSyncParam

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

the class AbstractVdcTaskOp method buildConfigParam.

/**
 * Build parameter for SyncVdcConfig call
 *
 * @param vdcList
 * @return
 */
protected VdcConfigSyncParam buildConfigParam(List<VirtualDataCenter> vdcList) {
    VdcConfigSyncParam syncParam = new VdcConfigSyncParam();
    syncParam.setVdcConfigVersion(DrUtil.newVdcConfigVersion());
    syncParam.setIpsecKey(ipsecConfig.getPreSharedKeyFromZK());
    for (VirtualDataCenter vdc : vdcList) {
        syncParam.getVirtualDataCenters().add(helper.toConfigParam(vdc));
    }
    syncParam.setConfigChangeType(changeType().toString());
    return syncParam;
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter)

Example 3 with VdcConfigSyncParam

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

the class ConnectVdcTaskOp method checkAndSync.

/**
 * Precheck if vdc connect is permitted, then sync the new vdc config to all sites
 */
private void checkAndSync(InternalApiSignatureKeyGenerator apiSignatureGenerator, KeyStore keystore) {
    String shortId = vdcInfo.getProperty(GeoServiceJob.VDC_SHORT_ID);
    String vdcName = vdcInfo.getProperty(GeoServiceJob.VDC_NAME);
    lockHelper.acquire(shortId);
    log.info("Acquired global lock, go on with connect vdc");
    geoClientCache.clearCache();
    loadVdcInfo();
    // Check & verify connection status of my current vdc
    preSteps();
    // Have the certificate for the to be added vdc
    persistVdcCert(vdcName, vdcInfo.getProperty(GeoServiceJob.VDC_CERTIFICATE_CHAIN), true, shortId);
    // precheck
    VdcPreCheckResponse operatedVdcInfo = preCheck();
    // remove root's Tenant Roles or project ownerships in local vdc
    try {
        _permissionHelper.removeRootRoleAssignmentOnTenantAndProject();
    } catch (DatabaseException dbe) {
        throw GeoException.fatals.connectVdcRemoveRootRolesFailed(dbe);
    }
    String currentVdcIpsecKey = ipsecConfig.getPreSharedKeyFromZK();
    URI newVdcId = URIUtil.uri(vdcInfo.getProperty(GeoServiceJob.OPERATED_VDC_ID));
    GeoServiceHelper.backupOperationVdc(dbClient, JobType.VDC_CONNECT_JOB, newVdcId, null);
    VirtualDataCenter newVdc = GeoServiceHelper.prepareVirtualDataCenter(newVdcId, VirtualDataCenter.ConnectionStatus.CONNECTING, VirtualDataCenter.GeoReplicationStatus.REP_NONE, vdcInfo);
    dbClient.createObject(newVdc);
    helper.createVdcConfigInZk(mergeVdcInfo(operatedVdcInfo), currentVdcIpsecKey);
    // we should use uuid as cert name in trust store, but before we persist new vdc info
    // into db, we use vdc name as cert name, after we persist new vdc into db, persist uuid
    // as cert name and remove the one which use vdc name as cert name.
    persistVdcCert(newVdc.getId().toString(), newVdc.getCertificateChain(), true, shortId);
    removeVdcCert(vdcName, shortId);
    // add new remote VDC to the list of VDC to sync
    toBeSyncedVdc.add(newVdc);
    allVdc.add(newVdc);
    connectedVdc.add(newVdc);
    VdcUtil.invalidateVdcUrnCache();
    // Now set "operatedVdc as the newly created VDC
    operatedVdc = newVdc;
    // generate the cert chain to be synced
    VdcCertListParam certListParam = genCertListParam(VdcCertListParam.CMD_ADD_CERT);
    // from now on, vdc status will be marked as CONNECT_FAILED for any failure
    failedVdcStatus = ConnectionStatus.CONNECT_FAILED;
    // sync the new certificate to all connected sites
    syncCerts(VdcCertListParam.CMD_ADD_CERT, certListParam);
    VdcConfigSyncParam mergedVdcInfo = configMerge(operatedVdcInfo, currentVdcIpsecKey);
    if (mergedVdcInfo == null) {
        log.error("merge the vdc config of all sites failed");
        throw GeoException.fatals.mergeConfigFail();
    }
    try {
        configSync(mergedVdcInfo);
    } catch (GeoException ex) {
        throw ex;
    } catch (Exception e) {
        log.error("Failed to sync vdc config to all sites e=", e);
        throw GeoException.fatals.syncConfigFail(e);
    }
// do not release the global lock here; lock is released during post processing
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VdcPreCheckResponse(com.emc.storageos.geomodel.VdcPreCheckResponse) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) VirtualDataCenter(com.emc.storageos.db.client.model.VirtualDataCenter) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) URI(java.net.URI) VdcCertListParam(com.emc.storageos.geomodel.VdcCertListParam) KeyStoreException(java.security.KeyStoreException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InvalidSoftwareVersionException(com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) UnknownHostException(java.net.UnknownHostException)

Example 4 with VdcConfigSyncParam

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

the class ConnectVdcTaskOp method configMerge.

private VdcConfigSyncParam configMerge(VdcPreCheckResponse operatedVdcInfo, String ipsecKey) {
    // step 2: merge the vdc config info of all sites, as the initiator, we should has all current vdc config info
    VdcConfigSyncParam vdcConfigList = new VdcConfigSyncParam();
    vdcConfigList.setVdcConfigVersion(DrUtil.newVdcConfigVersion());
    List<VdcConfig> list = vdcConfigList.getVirtualDataCenters();
    for (VirtualDataCenter vdc : getAllVdc()) {
        if (vdc.getShortId().equals(vdcInfo.getProperty(GeoServiceJob.VDC_SHORT_ID))) {
            continue;
        }
        log.info("add {} to the merged vdc config", vdc.getShortId());
        VdcConfig vdcConfig = helper.toConfigParam(vdc);
        list.add(vdcConfig);
    }
    VdcConfig operatedConfig = mergeVdcInfo(operatedVdcInfo);
    list.add(operatedConfig);
    vdcConfigList.setIpsecKey(ipsecKey);
    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 5 with VdcConfigSyncParam

use of com.emc.storageos.geomodel.VdcConfigSyncParam 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)

Aggregations

VdcConfigSyncParam (com.emc.storageos.geomodel.VdcConfigSyncParam)8 VirtualDataCenter (com.emc.storageos.db.client.model.VirtualDataCenter)7 VdcConfig (com.emc.storageos.geomodel.VdcConfig)4 ArrayList (java.util.ArrayList)3 VdcPreCheckResponse (com.emc.storageos.geomodel.VdcPreCheckResponse)2 GeoException (com.emc.storageos.security.geo.exceptions.GeoException)2 Date (java.util.Date)2 InvalidSoftwareVersionException (com.emc.storageos.coordinator.exceptions.InvalidSoftwareVersionException)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 VdcCertListParam (com.emc.storageos.geomodel.VdcCertListParam)1 FatalGeoException (com.emc.storageos.security.geo.exceptions.FatalGeoException)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 URI (java.net.URI)1 UnknownHostException (java.net.UnknownHostException)1 KeyStoreException (java.security.KeyStoreException)1 Certificate (java.security.cert.Certificate)1