use of com.emc.storageos.model.dr.SiteDetailRestRep in project coprhd-controller by CoprHD.
the class DisasterRecoveryService method getSiteDetails.
/**
* Query the site details, such as transition timings, for specific standby site
*
* @param uuid site UUID
* @brief Get site details
* @return SiteActionsTime 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 })
@Path("/{uuid}/details")
public SiteDetailRestRep getSiteDetails(@PathParam("uuid") String uuid) {
log.info("Begin to get site paused time by uuid {}", uuid);
SiteDetailRestRep standbyDetails = new SiteDetailRestRep();
try {
Site standby = drUtil.getSiteFromLocalVdc(uuid);
standbyDetails.setCreationTime(new Date(standby.getCreationTime()));
Double latency = drUtil.getSiteNetworkState(uuid).getNetworkLatencyInMs();
standbyDetails.setNetworkLatencyInMs(latency);
Date lastSyncTime = drUtil.getLastSyncTime(standby);
if (lastSyncTime != null) {
standbyDetails.setLastSyncTime(lastSyncTime);
}
standbyDetails.setDataSynced(isDataSynced(standby));
ClusterInfo.ClusterState clusterState = coordinator.getControlNodesState(standby.getUuid());
if (clusterState != null) {
standbyDetails.setClusterState(clusterState.toString());
} else {
standbyDetails.setClusterState(ClusterInfo.ClusterState.UNKNOWN.toString());
}
standbyDetails.setSiteState(standby.getState().toString());
} catch (CoordinatorException e) {
log.error("Can't find site {} from ZK", uuid);
throw APIException.badRequests.siteIdNotFound();
} catch (Exception e) {
log.error("Find find site from ZK for UUID {} : {}" + uuid, e);
}
return standbyDetails;
}
use of com.emc.storageos.model.dr.SiteDetailRestRep in project coprhd-controller by CoprHD.
the class DisasterRecovery method errorDetails.
public static void errorDetails(String id) {
Boolean isError = false;
String uuid = id;
// site id doesn't exist
if (!DisasterRecoveryUtils.hasStandbySite(id)) {
SiteDetailRestRep disasterSiteTime = new SiteDetailRestRep();
uuid = "Unknown Standby site id: " + id;
render(isError, uuid, disasterSiteTime);
}
SiteRestRep siteRest = DisasterRecoveryUtils.getSite(id);
// site is in STANDBY_ERROR state
if (siteRest.getState().equals(String.valueOf(SiteState.STANDBY_ERROR))) {
SiteErrorResponse disasterSiteError = DisasterRecoveryUtils.getSiteError(id);
isError = true;
if (disasterSiteError.getCreationTime() != null) {
DateTime errorCreationTime = new DateTime(disasterSiteError.getCreationTime().getTime());
renderArgs.put("errorCreationTime", errorCreationTime);
}
DateTime siteCreationTime = new DateTime(siteRest.getCreateTime());
renderArgs.put("siteCreationTime", siteCreationTime);
if (disasterSiteError.getOperation() != null) {
String operation = disasterSiteError.getOperation();
renderArgs.put("operation", operation);
}
render(isError, uuid, disasterSiteError);
}
SiteDetailRestRep disasterSiteDetails = DisasterRecoveryUtils.getSiteDetails(id);
Boolean isActive = isActiveSiteState(Enum.valueOf(SiteState.class, siteRest.getState()));
renderArgs.put("isActive", isActive);
if (disasterSiteDetails.getLastSyncTime() != null) {
DateTime lastSyncTime = new DateTime(disasterSiteDetails.getLastSyncTime().getTime());
renderArgs.put("lastSyncTime", lastSyncTime);
}
if (disasterSiteDetails.getCreationTime() != null) {
DateTime creationTime = new DateTime(disasterSiteDetails.getCreationTime().getTime());
renderArgs.put("creationTime", creationTime);
}
render(isError, uuid, disasterSiteDetails);
}
use of com.emc.storageos.model.dr.SiteDetailRestRep in project coprhd-controller by CoprHD.
the class DisasterRecovery method create.
@Restrictions({ @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void create() {
for (SiteRestRep site : DisasterRecoveryUtils.getSites()) {
if (SiteState.STANDBY_PAUSED.toString().equals(site.getState())) {
continue;
}
SiteDetailRestRep detail = DisasterRecoveryUtils.getSiteDetails(site.getUuid());
if (!ClusterInfo.ClusterState.STABLE.toString().equals(detail.getClusterState())) {
flash.error(MessagesUtils.get(ADD_WARNING, site.getName()));
list();
}
}
DisasterRecoveryForm site = new DisasterRecoveryForm();
edit(site);
}
Aggregations