use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.
the class VdcConfigHelper method toConfigParam.
/**
* Build VdcConfig for a vdc for SyncVdcConfig call
*
* @param vdc
* @return
*/
public VdcConfig toConfigParam(VirtualDataCenter vdc) {
log.info("copy {} to the sync config param", vdc.getShortId());
VdcConfig vdcConfig = new VdcConfig();
Site activeSite = drUtil.getActiveSite(vdc.getShortId());
vdcConfig.setId(vdc.getId());
vdcConfig.setShortId(vdc.getShortId());
vdcConfig.setSecretKey(vdc.getSecretKey());
if ((vdc.getLabel() != null) && (!vdc.getLabel().isEmpty())) {
vdcConfig.setName(vdc.getLabel());
}
if ((vdc.getDescription() != null) && (!vdc.getDescription().isEmpty())) {
vdcConfig.setDescription(vdc.getDescription());
}
if (activeSite.getVipEndPoint() != null) {
vdcConfig.setApiEndpoint(activeSite.getVipEndPoint());
}
vdcConfig.setHostCount(activeSite.getNodeCount());
HashMap<String, String> ipv4AddrMap = new HashMap<String, String>(activeSite.getHostIPv4AddressMap());
vdcConfig.setHostIPv4AddressesMap(ipv4AddrMap);
HashMap<String, String> ipv6AddrMap = new HashMap<String, String>(activeSite.getHostIPv6AddressMap());
vdcConfig.setHostIPv6AddressesMap(ipv6AddrMap);
vdcConfig.setVersion(vdc.getVersion());
vdcConfig.setConnectionStatus(vdc.getConnectionStatus().toString());
vdcConfig.setRepStatus(vdc.getRepStatus().toString());
vdcConfig.setGeoCommandEndpoint(vdc.getGeoCommandEndpoint());
vdcConfig.setGeoDataEndpoint(vdc.getGeoDataEndpoint());
vdcConfig.setActiveSiteId(activeSite.getUuid());
return vdcConfig;
}
use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.
the class VdcConfigHelper method sendVdcNodeCheckRequest.
/**
* Send node check request to target vdc.
*
* @param sendToVdc vdc to send msg to
* @param vdcsToCheck list of vdc's with nodes to check
* @return
* @throws Exception
*/
public VdcNodeCheckResponse sendVdcNodeCheckRequest(VirtualDataCenter sendToVdc, Collection<VirtualDataCenter> vdcsToCheck) {
List<VdcConfig> virtualDataCenters = new ArrayList<VdcConfig>();
for (VirtualDataCenter vdc : vdcsToCheck) {
VdcConfig vdcConfig = new VdcConfig();
vdcConfig.setId(vdc.getId());
vdcConfig.setShortId(vdc.getShortId());
Site activeSite = drUtil.getActiveSite(vdc.getShortId());
if (activeSite.getHostIPv4AddressMap() != null && !activeSite.getHostIPv4AddressMap().isEmpty() && activeSite.isUsingIpv4()) {
HashMap<String, String> addressMap = new HashMap<String, String>(activeSite.getHostIPv4AddressMap());
vdcConfig.setHostIPv4AddressesMap(addressMap);
} else if (activeSite.getHostIPv6AddressMap() != null && !activeSite.getHostIPv6AddressMap().isEmpty()) {
HashMap<String, String> addressMap = new HashMap<String, String>(activeSite.getHostIPv6AddressMap());
vdcConfig.setHostIPv6AddressesMap(addressMap);
} else {
throw new IllegalStateException("Cannot perform node reachable check on vdc " + vdc.getShortId() + " no nodes were found on VirtualDataCenter object");
}
virtualDataCenters.add(vdcConfig);
}
return sendVdcNodeCheckRequest(sendToVdc, virtualDataCenters);
}
use of com.emc.storageos.geomodel.VdcConfig in project coprhd-controller by CoprHD.
the class VdcConfigHelper method syncVdcConfig.
public void syncVdcConfig(List<VdcConfig> newVdcConfigList, String assignedVdcId, boolean isRecover, Long vdcConfigVersion, String ipsecKey) {
boolean vdcConfigChanged = false;
// query existing vdc list from db
// The new queryByType method returns an iterative list, convert it to a "real"
// list first
List<URI> vdcIdList = new ArrayList<URI>();
for (URI vdcId : dbClient.queryByType(VirtualDataCenter.class, true)) {
vdcIdList.add(vdcId);
}
// vdc that are going to be removed from local db
for (VdcConfig config : newVdcConfigList) {
if (vdcIdList.contains(config.getId())) {
vdcIdList.remove(config.getId());
mergeVdcConfig(config, isRecover);
} else {
// not contains in vdcIdList - it is a new vdc and we should insert to db
VirtualDataCenter newVdc = fromConfigParam(config);
if (config.getId().toString().equals(assignedVdcId)) {
newVdc.setLocal(true);
}
dbClient.createObject(newVdc);
if (newVdc.getLocal()) {
VdcUtil.invalidateVdcUrnCache();
}
createVdcConfigInZk(config, ipsecKey);
vdcConfigChanged = true;
if (newVdc.getLocal()) {
drUtil.setLocalVdcShortId(newVdc.getShortId());
}
}
}
// check vdc that are going to be removed
ArrayList<String> obsoletePeers = new ArrayList<String>();
for (URI removeVdcId : vdcIdList) {
log.warn("vdc config {} is being removed", removeVdcId);
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, removeVdcId);
ConnectionStatus connStatus = vdc.getConnectionStatus();
if (!isRecover && connStatus.equals(ConnectionStatus.CONNECT_FAILED)) {
log.info("Ignore vdc record {} with status {}", removeVdcId, connStatus);
continue;
}
dbClient.markForDeletion(vdc);
Map<String, String> addressesMap = dbClient.queryHostIPAddressesMap(vdc);
if (!addressesMap.isEmpty()) {
// obsolete peers ip in cassandra system table
obsoletePeers.addAll(addressesMap.values());
log.info("add {} peers to obsolete list", addressesMap.size());
}
dbClient.removeVdcNodesFromBlacklist(vdc);
deleteVdcConfigFromZk(vdc);
vdcConfigChanged = true;
}
if (!obsoletePeers.isEmpty()) {
// update peer ip to ZK so that geodbsvc could get it
notifyDbSvcWithObsoleteCassandraPeers(Constants.GEODBSVC_NAME, obsoletePeers);
log.info("notify geodbsvc with {} obsolete cassandra peers", obsoletePeers.size());
}
if (assignedVdcId != null) {
// Persist a flag to notify geodbsvc on all the nodes in the current vdc
log.info("reset db needed, set the flag for all db to look it up");
updateDbSvcConfig(Constants.GEODBSVC_NAME, Constants.REINIT_DB, String.valueOf(true));
}
if (vdcConfigChanged) {
String action = SiteInfo.GEO_OP_CONFIG_CHANGE;
// loses connection with other nodes
if (assignedVdcId != null) {
action = SiteInfo.IPSEC_OP_ROTATE_KEY;
}
triggerVdcConfigUpdate(vdcConfigVersion, action);
}
}
Aggregations