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;
}
}
}
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;
}
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());
}
Aggregations