use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method getStandbyConfig.
/**
* Get standby site configuration
*
* @brief Get standby site configuration
* @return SiteConfigRestRep standby site configuration.
*/
@GET
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN, Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
@Path("/localconfig")
public SiteConfigRestRep getStandbyConfig() {
log.info("Begin to get standby config");
String siteId = coordinator.getSiteId();
SecretKey key = apiSignatureGenerator.getSignatureKey(SignatureKeyType.INTERVDC_API);
Site site = drUtil.getSiteFromLocalVdc(siteId);
SiteConfigRestRep siteConfigRestRep = new SiteConfigRestRep();
siteConfigRestRep.setUuid(siteId);
siteConfigRestRep.setVip(site.getVip());
siteConfigRestRep.setVip6(site.getVip6());
siteConfigRestRep.setSecretKey(new String(Base64.encodeBase64(key.getEncoded()), Charset.forName("UTF-8")));
siteConfigRestRep.setHostIPv4AddressMap(site.getHostIPv4AddressMap());
siteConfigRestRep.setHostIPv6AddressMap(site.getHostIPv6AddressMap());
siteConfigRestRep.setDbSchemaVersion(coordinator.getCurrentDbSchemaVersion());
siteConfigRestRep.setFreshInstallation(isFreshInstallation());
siteConfigRestRep.setClusterStable(isClusterStable());
siteConfigRestRep.setNodeCount(site.getNodeCount());
siteConfigRestRep.setState(site.getState().toString());
try {
siteConfigRestRep.setSoftwareVersion(coordinator.getTargetInfo(RepositoryInfo.class).getCurrentVersion().toString());
} catch (Exception e) {
log.error("Fail to get software version {}", e);
}
log.info("Return result: {}", siteConfigRestRep);
return siteConfigRestRep;
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method precheckForFailover.
void precheckForFailover() {
Site standby = drUtil.getLocalSite();
String standbyUuid = standby.getUuid();
String standbyName = standby.getName();
// show be only standby
if (drUtil.isActiveSite()) {
throw APIException.badRequests.operationNotAllowedOnActiveSite();
}
// all syssvc should be up
if (!drUtil.isAllSyssvcUp(standbyUuid)) {
log.info("Not all syssvc is running at site {}", standby.getName());
throw APIException.internalServerErrors.failoverPrecheckFailed(standby.getName(), String.format("Site %s is not stable, one or more syssvc is not running", standby.getName()));
}
// Make sure that the local ZK has been reconfigured to participant
// This DOES NOT implies that the active site is unreachable, notably when the local site is manually paused
String coordinatorMode = drUtil.getLocalCoordinatorMode();
log.info("Local coordinator mode is {}", coordinatorMode);
if (coordinatorMode == null || !drUtil.isParticipantNode(coordinatorMode)) {
log.info("Active site is available now, can't do failover");
throw APIException.internalServerErrors.failoverPrecheckFailed(standbyName, "Active site is available now, can't do failover");
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method prepareSiteConfigParam.
/**
* Prepare all sites related info for synchronizing them from master to be added or resumed standby site
*
* @param standbySites All standby sites
* @param ipsecKey The cluster ipsec key
* @param targetStandbyUUID The uuid of the target standby
* @param targetStandbyDataRevision The data revision of the target standby
* @return SiteConfigParam all the sites configuration
*/
private SiteConfigParam prepareSiteConfigParam(List<Site> standbySites, String ipsecKey, String targetStandbyUUID, long targetStandbyDataRevision, long vdcConfigVersion, SecretKey secretKey) {
log.info("Preparing to sync sites info among to be added/resumed standby site...");
Site active = drUtil.getActiveSite();
SiteConfigParam configParam = new SiteConfigParam();
SiteParam activeSite = new SiteParam();
siteMapper.map(active, activeSite);
activeSite.setIpsecKey(ipsecKey);
log.info(" active site info:{}", activeSite.toString());
configParam.setActiveSite(activeSite);
List<SiteParam> standbySitesParam = new ArrayList<>();
for (Site standby : standbySites) {
SiteParam standbyParam = new SiteParam();
siteMapper.map(standby, standbyParam);
standbyParam.setSecretKey(new String(Base64.encodeBase64(secretKey.getEncoded()), Charset.forName("UTF-8")));
if (standby.getUuid().equals(targetStandbyUUID)) {
log.info("Set data revision for site {} to {}", standby.getUuid(), targetStandbyDataRevision);
standbyParam.setDataRevision(targetStandbyDataRevision);
}
standbySitesParam.add(standbyParam);
log.info(" standby site info:{}", standbyParam.toString());
}
configParam.setStandbySites(standbySitesParam);
configParam.setVdcConfigVersion(vdcConfigVersion);
// Need set stanby's NTP same as primary, so standby time is consistent with primary after reboot
// It's because time inconsistency between primary and standby will cause db rebuild issue: COP-17965
PropertyInfoExt targetPropInfo = coordinator.getTargetInfo(PropertyInfoExt.class);
String ntpServers = targetPropInfo.getProperty(NTPSERVERS);
log.info(" active site ntp servers: {}", ntpServers);
configParam.setNtpServers(ntpServers);
return configParam;
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method initStandby.
/**
* Initialize a to-be added/resumed target standby
* a) re-set all the latest site related info (persisted in ZK) in the target standby
* b) vdc properties would be changed accordingly
* c) the target standby reboot
* d) re-set zk/db data during the target standby reboot
* e) the target standby would connect with active and sync all the latest ZK&DB data.
*
* Scenarios:
* a) For adding standby site scenario (External API), the current site will be demoted from active to standby during the process
* b) For resuming standby site scenario (Internal API), the current site's original data will be cleaned by setting new data revision.
* It is now only used for resuming long paused (> 5 days) standby site
*
* @param configParam
* @return
*/
@PUT
@Path("/internal/initstandby")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response initStandby(SiteConfigParam configParam) {
try {
SiteParam activeSiteParam = configParam.getActiveSite();
ipsecConfig.setPreSharedKey(activeSiteParam.getIpsecKey());
log.info("Clean up all obsolete site configurations");
String activeSiteId = activeSiteParam.getUuid();
Set<String> standbySiteIds = new HashSet<>();
for (SiteParam standby : configParam.getStandbySites()) {
standbySiteIds.add(standby.getUuid());
}
for (Site siteToRemove : drUtil.listSites()) {
String siteId = siteToRemove.getUuid();
if (activeSiteId.equals(siteId) || standbySiteIds.contains(siteId)) {
continue;
}
drUtil.removeSite(siteToRemove);
}
coordinator.addSite(activeSiteParam.getUuid());
Site activeSite = new Site();
siteMapper.map(activeSiteParam, activeSite);
activeSite.setVdcShortId(drUtil.getLocalVdcShortId());
coordinator.persistServiceConfiguration(activeSite.toConfiguration());
Long dataRevision = null;
// Add other standby sites
for (SiteParam standby : configParam.getStandbySites()) {
Site site = new Site();
siteMapper.map(standby, site);
site.setVdcShortId(drUtil.getLocalVdcShortId());
coordinator.persistServiceConfiguration(site.toConfiguration());
coordinator.addSite(standby.getUuid());
if (standby.getUuid().equals(coordinator.getSiteId())) {
dataRevision = standby.getDataRevision();
log.info("Set data revision to {}", dataRevision);
}
log.info("Persist standby site {} to ZK", standby.getVip());
}
if (dataRevision == null) {
throw new IllegalStateException("Illegal request on standby site. No data revision in request");
}
String ntpServers = configParam.getNtpServers();
PropertyInfoExt targetPropInfo = coordinator.getTargetInfo(PropertyInfoExt.class);
if (ntpServers != null && !ntpServers.equals(targetPropInfo.getProperty(NTPSERVERS))) {
targetPropInfo.addProperty(NTPSERVERS, ntpServers);
coordinator.setTargetInfo(targetPropInfo);
log.info("Set ntp servers to {}", ntpServers);
}
drUtil.updateVdcTargetVersion(coordinator.getSiteId(), SiteInfo.DR_OP_CHANGE_DATA_REVISION, configParam.getVdcConfigVersion(), dataRevision);
return Response.status(Response.Status.ACCEPTED).build();
} catch (Exception e) {
log.error("Internal error for updating coordinator on standby", e);
throw APIException.internalServerErrors.configStandbyFailed(e.getMessage());
}
}
use of com.emc.storageos.coordinator.client.model.Site in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method validateAddParam.
protected void validateAddParam(SiteAddParam param, List<Site> existingSites) {
String siteName = param.getName();
if (!validSiteName(siteName)) {
throw APIException.internalServerErrors.addStandbyPrecheckFailed(String.format("Site name should not be empty or longer than %d characters.", SITE_NAME_LENGTH_LIMIT));
}
String siteVip = param.getVip();
InetAddress address = null;
try {
address = InetAddress.getByName(siteVip);
} catch (UnknownHostException e) {
throw APIException.internalServerErrors.addStandbyPrecheckFailed("Could not resolve target standby site virtual IP. Please check name service.");
}
if (address.getHostAddress().contains(":")) {
param.setVip(DualInetAddress.normalizeInet6Address(address.getHostAddress()));
} else {
param.setVip(address.getHostAddress());
}
log.info("Target standby site ip is {}", param.getVip());
for (Site site : existingSites) {
if (site.getName().equals(siteName)) {
throw APIException.internalServerErrors.addStandbyPrecheckFailed("Duplicate site name");
}
// COP-18954 Skip stability check for paused sites
if (site.getState().equals(SiteState.STANDBY_PAUSED)) {
continue;
}
ClusterInfo.ClusterState state = coordinator.getControlNodesState(site.getUuid());
if (state != ClusterInfo.ClusterState.STABLE) {
log.info("Site {} is not stable {}", site.getUuid(), state);
throw APIException.internalServerErrors.addStandbyPrecheckFailed(String.format("Currently site %s is not stable", site.getName()));
}
}
}
Aggregations