Search in sources :

Example 6 with VdcConfigSyncParam

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

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

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

the class UpdateVdcTaskOp method checkAndSync.

/**
 * Precheck if vdc update is permitted, then sync the vdc config to all sites to
 * update an existing vdc
 */
public void checkAndSync() {
    lockHelper.acquire(operatedVdc.getShortId());
    geoClientCache.clearCache();
    loadVdcInfo();
    if (StringUtils.isNotEmpty(updateInfo.getProperty(GeoServiceJob.VDC_CERTIFICATE_CHAIN)) && (operatedVdc.getId().compareTo(myVdc.getId()) != 0)) {
        String errMsg = "could not update key certchain from remote VDC.";
        log.error(errMsg);
        throw GeoException.fatals.updateVdcPrecheckFail(errMsg);
    }
    VdcPreCheckResponse operatedVdcInfo = preCheck();
    GeoServiceHelper.backupOperationVdc(dbClient, GeoServiceJob.JobType.VDC_UPDATE_JOB, operatedVdcInfo.getId(), params.toString());
    failedVdcStatus = ConnectionStatus.UPDATE_FAILED;
    updateOperatedVdc();
    operatedVdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.UPDATING);
    dbClient.updateAndReindexObject(operatedVdc);
    loadVdcInfo();
    VdcConfigSyncParam mergedVdcInfo = mergeConfig(operatedVdcInfo);
    if (mergedVdcInfo == null) {
        log.error("merge the vdc config of all sites failed");
        throw GeoException.fatals.mergeConfigFail();
    }
    try {
        syncConfig(mergedVdcInfo);
    } catch (GeoException ex) {
        throw ex;
    } catch (Exception e) {
        log.error("Failed to sync vdc config to all sites : {}", e);
        throw GeoException.fatals.syncConfigFail(e);
    }
    String cert = updateInfo.getProperty(GeoServiceJob.VDC_CERTIFICATE_CHAIN);
    if (StringUtils.isNotEmpty(cert)) {
        VdcCertListParam certListParam = genCertOperationParam(VdcCertListParam.CMD_UPDATE_CERT);
        syncCerts(VdcCertListParam.CMD_UPDATE_CERT, certListParam);
        // set key and cert in local keystore
        Boolean selfsigned = (Boolean) params.get(1);
        byte[] key = (byte[]) params.get(2);
        Certificate[] certchain = (Certificate[]) params.get(3);
        helper.setKeyCertchain(selfsigned, key, certchain);
    }
    // lock is released in error handling code if an exception is thrown before we get
    // here. note that since there is no post processing for update, there is no way
    // to know if the sync operation is complete; lock must be released here before
    // sync is done.
    lockHelper.release(operatedVdc.getShortId());
}
Also used : VdcConfigSyncParam(com.emc.storageos.geomodel.VdcConfigSyncParam) VdcPreCheckResponse(com.emc.storageos.geomodel.VdcPreCheckResponse) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) GeoException(com.emc.storageos.security.geo.exceptions.GeoException) Certificate(java.security.cert.Certificate)

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