use of com.emc.storageos.coordinator.client.model.SiteInfo in project coprhd-controller by CoprHD.
the class DisasterRecoveryServiceTest method testGetAllStandby.
@Test
public void testGetAllStandby() throws Exception {
List<Site> sites = new ArrayList<>();
sites.add(standbySite1);
sites.add(standbySite2);
sites.add(standbySite3);
doReturn(sites).when(drUtil).listSites();
doReturn(new SiteInfo()).when(coordinator).getTargetInfo(any(String.class), eq(SiteInfo.class));
SiteList responseList = drService.getSites();
assertNotNull(responseList.getSites());
assertEquals(3, responseList.getSites().size());
compareSiteResponse(responseList.getSites().get(0), standbySite1);
compareSiteResponse(responseList.getSites().get(1), standbySite2);
}
use of com.emc.storageos.coordinator.client.model.SiteInfo in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method retryOperation.
/**
* Query the latest error message & Retry the Last operation for specific standby site
*
* @param uuid site UUID
* @brief Query the latest error message & Retry the Last operation for specific standby site
* @return updated standby site representation
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.RESTRICTED_SECURITY_ADMIN, Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/{uuid}/retry")
public SiteRestRep retryOperation(@PathParam("uuid") String uuid) {
log.info("Begin to get site error by uuid {}", uuid);
Site standby;
try {
standby = drUtil.getSiteFromLocalVdc(uuid);
} catch (CoordinatorException e) {
log.error("Can't find site {} from ZK", uuid);
throw APIException.badRequests.siteIdNotFound();
}
if (!standby.getState().equals(SiteState.STANDBY_ERROR)) {
log.error("site {} is in state {}, should be STANDBY_ERROR", uuid, standby.getState());
throw APIException.badRequests.operationOnlyAllowedOnErrorSite(standby.getName(), standby.getState().toString());
}
if (!standby.getLastState().equals(SiteState.STANDBY_PAUSING) && !standby.getLastState().equals(SiteState.STANDBY_RESUMING) && !standby.getLastState().equals(SiteState.STANDBY_FAILING_OVER)) {
log.error("site {} lastState was {}, retry is only supported for Pause, Resume and Failover", uuid, standby.getLastState());
throw APIException.badRequests.operationRetryOnlyAllowedOnLastState(standby.getName(), standby.getLastState().toString());
}
// Reuse the current action required
Site localSite = drUtil.getLocalSite();
SiteInfo siteInfo = coordinator.getTargetInfo(localSite.getUuid(), SiteInfo.class);
String drOperation = siteInfo.getActionRequired();
// Check that last action matches retry action
if (!drOperation.equals(standby.getLastState().getDRAction())) {
log.error("Active site last operation was {}, retry is only supported if no other operations have been performed", drOperation);
throw APIException.internalServerErrors.retryStandbyPrecheckFailed(standby.getName(), standby.getLastState().toString(), String.format("Another DR operation %s has been run on Active site. Only the latest operation can be retried. " + "This is an unrecoverable Error, please remove site and deploy a new one.", drOperation));
}
InterProcessLock lock = drUtil.getDROperationLock();
try {
coordinator.startTransaction();
standby.setState(standby.getLastState());
// Failover requires setting old active site to last state as well.
if (standby.getState() == SiteState.STANDBY_FAILING_OVER) {
for (Site site : drUtil.listSites()) {
if (site.getLastState() == SiteState.ACTIVE_FAILING_OVER) {
site.setState(SiteState.ACTIVE_FAILING_OVER);
coordinator.persistServiceConfiguration(site.toConfiguration());
}
}
}
coordinator.persistServiceConfiguration(standby.toConfiguration());
log.info("Notify all sites for reconfig");
long vdcTargetVersion = DrUtil.newVdcConfigVersion();
for (Site site : drUtil.listSites()) {
String siteUuid = site.getUuid();
if (site.getLastState() == SiteState.STANDBY_RESUMING) {
SiteInfo siteTargetInfo = coordinator.getTargetInfo(siteUuid, SiteInfo.class);
String resumeSiteOperation = siteTargetInfo.getActionRequired();
if (resumeSiteOperation.equals(SiteInfo.DR_OP_CHANGE_DATA_REVISION)) {
long dataRevision = vdcTargetVersion;
drUtil.updateVdcTargetVersion(siteUuid, resumeSiteOperation, vdcTargetVersion, dataRevision);
continue;
}
}
log.info("Set dr operation {} on site {}", drOperation, siteUuid);
drUtil.updateVdcTargetVersion(siteUuid, drOperation, vdcTargetVersion);
}
coordinator.commitTransaction();
return siteMapper.map(standby);
} catch (Exception e) {
log.error("Error retrying site operation for site {}", uuid, e);
coordinator.discardTransaction();
auditDisasterRecoveryOps(OperationTypeEnum.RETRY_STANDBY_OP, AuditLogManager.AUDITLOG_FAILURE, null, standby);
InternalServerErrorException retryStandbyOpFailedException = APIException.internalServerErrors.retryStandbyOpFailed(standby.getName(), e.getMessage());
throw retryStandbyOpFailedException;
} finally {
try {
lock.release();
} catch (Exception ignore) {
log.error(String.format("Lock release failed when retrying standby site last op: %s", uuid));
}
}
}
use of com.emc.storageos.coordinator.client.model.SiteInfo in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method getSites.
/**
* Get all sites including standby and active
*
* @brief Get all standby and active sites of local VDC
* @return site list contains all sites with detail information
*/
@GET
@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 })
public SiteList getSites() {
log.info("Begin to list all standby sites of local VDC");
SiteList standbyList = new SiteList();
for (Site site : drUtil.listSites()) {
standbyList.getSites().add(siteMapper.mapWithNetwork(site, drUtil));
}
SiteInfo siteInfo = coordinator.getTargetInfo(coordinator.getSiteId(), SiteInfo.class);
standbyList.setConfigVersion(siteInfo.getVdcConfigVersion());
return standbyList;
}
use of com.emc.storageos.coordinator.client.model.SiteInfo in project coprhd-controller by CoprHD.
the class VdcConfigService method getIpsecProperties.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/ipsec-properties")
public PropertyInfoRestRep getIpsecProperties() throws Exception {
log.info("getting ipsec properties.");
Map<String, String> ipsecProps = new HashMap();
ipsecProps.put(IPSEC_KEY, ipsecConfig.getPreSharedKey());
SiteInfo siteInfo = coordinator.getTargetInfo(SiteInfo.class);
String vdcConfigVersion = String.valueOf(siteInfo.getVdcConfigVersion());
ipsecProps.put(VDC_CONFIG_VERSION, vdcConfigVersion);
log.info("ipsec key: " + ipsecConfig.getPreSharedKey() + ", vdc config version: " + vdcConfigVersion);
return new PropertyInfoRestRep(ipsecProps);
}
Aggregations