Search in sources :

Example 1 with SiteActive

use of com.emc.storageos.model.dr.SiteActive in project coprhd-controller by CoprHD.

the class DisasterRecoveryService method checkIsActive.

/**
 * Check if current site is active site
 *
 * @brief Check if current site is active
 * @return SiteActive true if current site is active else false
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/active")
public SiteActive checkIsActive() {
    log.info("Begin to check if site Active or Standby");
    SiteActive isActiveSite = new SiteActive();
    try {
        Site localSite = drUtil.getLocalSite();
        isActiveSite.setIsActive(localSite.getState() == SiteState.ACTIVE);
        isActiveSite.setLocalSiteName(localSite.getName());
        isActiveSite.setLocalUuid(localSite.getUuid());
        isActiveSite.setIsMultiSite(drUtil.isMultisite());
        return isActiveSite;
    } catch (Exception e) {
        log.error("Can't get site is Active or Standby");
        throw APIException.badRequests.siteIdNotFound();
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteActive(com.emc.storageos.model.dr.SiteActive) 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)

Example 2 with SiteActive

use of com.emc.storageos.model.dr.SiteActive in project coprhd-controller by CoprHD.

the class DisasterRecovery method switchover.

@FlashException("list")
@Restrictions({ @Restrict("SECURITY_ADMIN"), @Restrict("RESTRICTED_SECURITY_ADMIN") })
public static void switchover(String id) {
    String standby_name = null;
    String standby_vip = null;
    String active_name = null;
    Boolean isSwitchover = false;
    // Get active site details
    SiteRestRep activesite = DisasterRecoveryUtils.getActiveSite();
    active_name = activesite == null ? "N/A" : activesite.getName();
    SiteRestRep result = DisasterRecoveryUtils.getSite(id);
    if (result != null) {
        // Check Switchover or Failover
        SiteActive currentSite = DisasterRecoveryUtils.checkActiveSite();
        if (currentSite.getIsActive() == true) {
            DisasterRecoveryUtils.doSwitchover(id);
            isSwitchover = true;
        } else {
            DisasterRecoveryUtils.doFailover(id);
            isSwitchover = false;
        }
        standby_name = result.getName();
        standby_vip = result.getVipEndpoint();
    }
    String site_uuid = id;
    maintenance(active_name, standby_name, standby_vip, site_uuid, isSwitchover);
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) SiteActive(com.emc.storageos.model.dr.SiteActive) FlashException(controllers.util.FlashException) Restrictions(controllers.deadbolt.Restrictions)

Aggregations

SiteActive (com.emc.storageos.model.dr.SiteActive)2 Site (com.emc.storageos.coordinator.client.model.Site)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 SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)1 Restrictions (controllers.deadbolt.Restrictions)1 FlashException (controllers.util.FlashException)1 UnknownHostException (java.net.UnknownHostException)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1