use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class VdcConfigService method toVirtualDataCenterResponse.
private VdcPreCheckResponse toVirtualDataCenterResponse(VirtualDataCenter from, boolean hasData, SoftwareVersion remoteSoftVer, SoftwareVersion localSoftVer) {
if (from == null) {
return null;
}
Site activeSite = drUtil.getActiveSite(from.getShortId());
VdcPreCheckResponse to = new VdcPreCheckResponse();
to.setId(from.getId());
to.setConnectionStatus(from.getConnectionStatus().name());
to.setVersion(from.getVersion());
to.setShortId(from.getShortId());
to.setHostCount(activeSite.getNodeCount());
StringMap ipv4Addr = new StringMap();
ipv4Addr.putAll(activeSite.getHostIPv4AddressMap());
to.setHostIPv4AddressesMap(ipv4Addr);
StringMap ipv6Addr = new StringMap();
ipv6Addr.putAll(activeSite.getHostIPv6AddressMap());
to.setHostIPv6AddressesMap(ipv6Addr);
to.setName(from.getLabel());
to.setDescription(from.getDescription());
to.setApiEndpoint(activeSite.getVipEndPoint());
to.setSecretKey(from.getSecretKey());
to.setHasData(hasData);
to.setSoftwareVersion(localSoftVer.toString());
boolean compatible = false;
if (remoteSoftVer != null) {
compatible = helper.isCompatibleVersion(remoteSoftVer);
}
to.setCompatible(compatible);
boolean clusterStable = isClusterStable();
to.setClusterStable(clusterStable);
log.info("current cluster stable {}", clusterStable);
to.setActiveSiteId(activeSite.getUuid());
return to;
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class VdcConfigService method precheckVdcConfig.
/**
* Do more precheck
* For disconnecting a vdc, check if there is a VDC that is under disconnecting
* If yes, return the VDC under disconnecting, otherwise set the VDC (given by parameter)
* status to DISCONNECTING
*
* @param checkParam
*
* @return VdcPreCheckResponse
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/precheck2")
public VdcPreCheckResponse2 precheckVdcConfig(VdcPreCheckParam2 checkParam) {
log.info("Start vdc config precheck2 for {} ...", checkParam.getConfigChangeType());
if (service.getId().endsWith("standalone")) {
throw GeoException.fatals.remoteVDCWrongStandaloneInstall();
}
VdcConfig.ConfigChangeType type = checkParam.getConfigChangeType();
VirtualDataCenter vdc = null;
VdcPreCheckResponse2 resp2 = new VdcPreCheckResponse2();
resp2.setCompatible(true);
// BZ
// TODO Need to use a different method to update info on lock on a remote system.
// Need to use a different field (not connection status of VDC object) as a locking mechanism)
boolean precheckFailed = checkParam.isPrecheckFailed();
switch(type) {
case DISCONNECT_VDC:
log.info("Precheck2 for disconnect ops");
vdc = helper.getDisconnectingVdc();
if (checkParam.getIsAllNotReachable()) {
URI targetVdcId = checkParam.getVdcIds().get(0);
log.info("Precheck2 to check the disconnect vdc {} is reachable", targetVdcId);
VirtualDataCenter targetVdc = dbClient.queryObject(VirtualDataCenter.class, targetVdcId);
Site activeSite = drUtil.getActiveSite(targetVdc.getShortId());
resp2.setIsAllNodesNotReachable(!helper.areNodesReachable(getLocalVdc().getShortId(), activeSite.getHostIPv4AddressMap(), activeSite.getHostIPv6AddressMap(), checkParam.getIsAllNotReachable()));
break;
}
if (precheckFailed) {
log.info("Precheck2 to update reconnect precheck fail status");
String vdcState = checkParam.getDefaultVdcState();
if (StringUtils.isNotEmpty(vdcState)) {
vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.valueOf(vdcState));
dbClient.updateAndReindexObject(vdc);
}
break;
}
if (vdc == null) {
// no DISCONNECTING_VDC
log.info("Precheck2: there is no disconnecting vdc");
URI srcVdcId = checkParam.getVdcIds().get(1);
VirtualDataCenter srcVdc = dbClient.queryObject(VirtualDataCenter.class, srcVdcId);
if (srcVdc.getConnectionStatus() == VirtualDataCenter.ConnectionStatus.DISCONNECTED) {
resp2.setCompatible(false);
break;
}
// BZ
// TODO need to use a different field to set locks on concurrent VDC operation
URI id = checkParam.getVdcIds().get(0);
vdc = dbClient.queryObject(VirtualDataCenter.class, id);
vdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.DISCONNECTING);
dbClient.updateAndReindexObject(vdc);
} else {
resp2 = toVirtualDataCenterResponse2(vdc, true, null);
}
break;
case RECONNECT_VDC:
log.info("Precheck2 for reconnect ops checkParam={}", checkParam);
List<String> blackList = checkParam.getBlackList();
List<String> whiteList = checkParam.getWhiteList();
log.info("Precheck2 to check if two vdc disconnect each other");
resp2.setCompatible(true);
if (isDisconnectedEachOther(blackList, whiteList)) {
log.info("Precheck2: two vdc have disconnected each other");
resp2.setCompatible(false);
break;
}
if (precheckFailed) {
log.info("Precheck2 to update reconnect precheck fail status");
URI targetVdcId = checkParam.getVdcIds().get(0);
log.info("Precheck2 to check the disconnect vdc {} is reachable", targetVdcId);
VirtualDataCenter targetVdc = dbClient.queryObject(VirtualDataCenter.class, targetVdcId);
String vdcState = checkParam.getDefaultVdcState();
if (StringUtils.isNotEmpty(vdcState)) {
targetVdc.setConnectionStatus(VirtualDataCenter.ConnectionStatus.valueOf(vdcState));
dbClient.updateAndReindexObject(targetVdc);
}
break;
}
break;
}
log.info("Precheck2 done, resp is {}", resp2.toString());
return resp2;
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class VdcConfigHelper method areNodesReachable.
/**
* tries to connect to each node in each vdc
*
* @param vdcId - the Id of the target VDC
* @return true if all nodes of the target Vdc is reachable
*/
public boolean areNodesReachable(URI vdcId) {
if (vdcId == null) {
throw new IllegalArgumentException("The target Vdc short ID should not be null or empty");
}
VirtualDataCenter vdc = dbClient.queryObject(VirtualDataCenter.class, vdcId);
Site activeSite = drUtil.getActiveSite(vdc.getShortId());
if (areNodesReachable(vdc.getShortId(), activeSite.getHostIPv4AddressMap(), activeSite.getHostIPv6AddressMap(), false)) {
return true;
}
return false;
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class VdcConfigHelper method addStrategyOption.
public void addStrategyOption(VirtualDataCenter vdc, boolean wait) throws Exception {
String shortVdcId = vdc.getShortId();
Map<String, String> options = dbClient.getGeoStrategyOptions();
if (options.containsKey(shortVdcId)) {
// already added
return;
}
Site activeSite = drUtil.getActiveSite(vdc.getShortId());
options.put(shortVdcId, String.valueOf(activeSite.getNodeCount()));
dbClient.getGeoContext().setCassandraStrategyOptions(options, wait);
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class VdcConfigHelper method createVdcConfigInZk.
public void createVdcConfigInZk(VdcConfig vdc, String ipsecKey) {
log.info("Update Vdc info to zk {}", vdc.getShortId());
// Insert vdc info
ConfigurationImpl vdcConfig = new ConfigurationImpl();
vdcConfig.setKind(Site.CONFIG_KIND);
vdcConfig.setId(vdc.getShortId());
coordinator.persistServiceConfiguration(vdcConfig);
// insert DR active site info to ZK
Site site = new Site();
site.setUuid(vdc.getActiveSiteId());
site.setName("Default Active Site");
site.setVdcShortId(vdc.getShortId());
site.setSiteShortId(Constants.CONFIG_DR_FIRST_SITE_SHORT_ID);
site.setHostIPv4AddressMap(vdc.getHostIPv4AddressesMap());
site.setHostIPv6AddressMap(vdc.getHostIPv6AddressesMap());
site.setState(SiteState.ACTIVE);
site.setCreationTime(System.currentTimeMillis());
String vdcEndpoint = vdc.getApiEndpoint();
if (vdcEndpoint.contains(":")) {
site.setVip6(vdcEndpoint);
site.setVip(PropertyConstants.IPV4_ADDR_DEFAULT);
} else {
site.setVip(vdcEndpoint);
site.setVip6(PropertyConstants.IPV6_ADDR_DEFAULT);
}
site.setNodeCount(vdc.getHostCount());
coordinator.persistServiceConfiguration(site.toConfiguration());
ipsecConfig.setPreSharedKey(ipsecKey);
}
Aggregations