use of com.emc.storageos.db.client.model.VirtualDataCenter 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
}
use of com.emc.storageos.db.client.model.VirtualDataCenter 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;
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class ReconnectVdcTaskOp method getWhiteList.
private List<String> getWhiteList() {
List<String> whiteList = new ArrayList();
List<URI> ids = dbClient.queryByType(VirtualDataCenter.class, true);
for (URI id : ids) {
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, id);
if (vdc.getConnectionStatus() == ConnectionStatus.CONNECTED) {
Collection<String> addresses = dbClient.queryHostIPAddressesMap(vdc).values();
whiteList.addAll(addresses);
}
}
return whiteList;
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class UpdateVdcTaskOp method preCheck.
private VdcPreCheckResponse preCheck() {
log.info("Starting precheck on vdc update ...");
// avoid to send preCheck from v2.3 or higher to v2.2 v2.1, v2.0
if (!isRemoteVdcVersionCompatible(vdcInfo)) {
throw GeoException.fatals.updateVdcPrecheckFail("Software version from remote vdc is lower than v2.3.");
}
// BZ:
// TODO It appears that this code assumes that update node is a remote node.
// we need to modify it to make it simpler when updated node is local.
log.info("Send vdc precheck to remote vdc");
VdcPreCheckResponse vdcResp = sendVdcPrecheckRequest(vdcInfo, false);
log.info("Check vdc stable");
// check if the cluster is stable
URI unstable = checkAllVdcStable(false, true);
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: {}, {} {}", new Object[] { vdcResp.getApiEndpoint(), vdcResp.getHostIPv4AddressesMap(), vdcResp.getHostIPv6AddressesMap() });
return vdcResp;
}
use of com.emc.storageos.db.client.model.VirtualDataCenter in project coprhd-controller by CoprHD.
the class VdcControllerTest method newVdcForAdding.
/**
* New Vdc object for adding
*
* @return
*/
private VirtualDataCenter newVdcForAdding(String shortId) {
VirtualDataCenter vdc = new VirtualDataCenter();
URI vdcId = URIUtil.createVirtualDataCenterId(shortId);
String vdcShortId = shortId;
vdc.setShortId(vdcShortId);
vdc.setId(vdcId);
vdc.setVersion(2L);
vdc.setLocal(false);
vdc.setApiEndpoint("127.0.0.2");
vdc.setHostCount(1);
vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.CONNECTING);
vdc.setRepStatus(VirtualDataCenter.GeoReplicationStatus.REP_NONE);
vdc.setCertificateChain(TEST_CERT);
return vdc;
}
Aggregations