Search in sources :

Example 1 with SiteDetailRestRep

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;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) ClusterInfo(com.emc.vipr.model.sys.ClusterInfo) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) SiteDetailRestRep(com.emc.storageos.model.dr.SiteDetailRestRep) Date(java.util.Date) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) UnknownHostException(java.net.UnknownHostException) Path(javax.ws.rs.Path) ZkPath(com.emc.storageos.coordinator.common.impl.ZkPath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with SiteDetailRestRep

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);
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) SiteState(com.emc.storageos.coordinator.client.model.SiteState) SiteErrorResponse(com.emc.storageos.model.dr.SiteErrorResponse) SiteDetailRestRep(com.emc.storageos.model.dr.SiteDetailRestRep) DateTime(org.joda.time.DateTime)

Example 3 with SiteDetailRestRep

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);
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) SiteDetailRestRep(com.emc.storageos.model.dr.SiteDetailRestRep) Restrictions(controllers.deadbolt.Restrictions)

Aggregations

SiteDetailRestRep (com.emc.storageos.model.dr.SiteDetailRestRep)3 SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)2 Site (com.emc.storageos.coordinator.client.model.Site)1 SiteState (com.emc.storageos.coordinator.client.model.SiteState)1 ZkPath (com.emc.storageos.coordinator.common.impl.ZkPath)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)1 SiteErrorResponse (com.emc.storageos.model.dr.SiteErrorResponse)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 ClusterInfo (com.emc.vipr.model.sys.ClusterInfo)1 Restrictions (controllers.deadbolt.Restrictions)1 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 DateTime (org.joda.time.DateTime)1