Search in sources :

Example 1 with SiteRestRep

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

the class DisasterRecoveryServiceTest method testResumeStandby.

@Test
public void testResumeStandby() {
    try {
        drService.resumeStandby(primarySite.getUuid());
    } catch (APIException e) {
        assertEquals(e.getServiceCode(), ServiceCode.API_BAD_REQUEST);
    }
    try {
        drService.resumeStandby(NONEXISTENT_ID);
    } catch (APIException e) {
        assertEquals(e.getServiceCode(), ServiceCode.API_PARAMETER_INVALID);
    }
    doNothing().when(coordinator).persistServiceConfiguration(any(Configuration.class));
    doReturn(null).when(coordinator).getTargetInfo(any(String.class), eq(SiteInfo.class));
    doNothing().when(coordinator).setTargetInfo(any(String.class), any(SiteInfo.class));
    InternalSiteServiceClient internalSiteClient = mock(InternalSiteServiceClient.class);
    doReturn(internalSiteClient).when(drService).createInternalSiteServiceClient(any(Site.class));
    try {
        SiteRestRep response = drService.resumeStandby(standbySite1.getUuid());
        assertEquals(SiteState.STANDBY_PAUSED.toString(), response.getState());
    } catch (Exception e) {
        fail();
    }
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) Configuration(com.emc.storageos.coordinator.common.Configuration) InternalSiteServiceClient(com.emc.storageos.api.service.impl.resource.utils.InternalSiteServiceClient) Matchers.anyString(org.mockito.Matchers.anyString) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) Test(org.junit.Test)

Example 2 with SiteRestRep

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

the class SiteMapper method map.

public SiteRestRep map(Site from) {
    if (from == null) {
        return null;
    }
    SiteRestRep to = new SiteRestRep();
    map(from, to);
    return to;
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep)

Example 3 with SiteRestRep

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

the class SiteMapper method mapWithNetwork.

public SiteRestRep mapWithNetwork(Site from, DrUtil drUtil) {
    if (from == null) {
        return null;
    }
    SiteRestRep to = new SiteRestRep();
    map(from, to);
    NetworkHealth networkHealth = drUtil.getSiteNetworkState(from.getUuid()).getNetworkHealth();
    SiteState state = from.getState();
    // Skip network health state amid ADDING/RESUMING
    if (networkHealth != null && SiteState.STANDBY_ADDING != state && SiteState.STANDBY_RESUMING != state) {
        to.setNetworkHealth(networkHealth.toString());
    }
    // check if syssvc are up
    boolean runningState = drUtil.isSiteUp(from.getUuid());
    if (runningState && !from.getState().equals(SiteState.ACTIVE)) {
        // check if dbsvc are up
        SiteMonitorResult monitorResult = drUtil.getCoordinator().getTargetInfo(from.getUuid(), SiteMonitorResult.class);
        if (monitorResult != null && monitorResult.getDbQuorumLostSince() > 0) {
            runningState = false;
        }
    }
    to.setRunningState(runningState);
    return to;
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) SiteState(com.emc.storageos.coordinator.client.model.SiteState) SiteMonitorResult(com.emc.storageos.coordinator.client.model.SiteMonitorResult) NetworkHealth(com.emc.storageos.coordinator.client.model.SiteNetworkState.NetworkHealth)

Example 4 with SiteRestRep

use of com.emc.storageos.model.dr.SiteRestRep 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)

Example 5 with SiteRestRep

use of com.emc.storageos.model.dr.SiteRestRep 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)

Aggregations

SiteRestRep (com.emc.storageos.model.dr.SiteRestRep)21 Restrictions (controllers.deadbolt.Restrictions)7 Test (org.junit.Test)5 FlashException (controllers.util.FlashException)4 ArrayList (java.util.ArrayList)3 Site (com.emc.storageos.coordinator.client.model.Site)2 SiteState (com.emc.storageos.coordinator.client.model.SiteState)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 SiteAddParam (com.emc.storageos.model.dr.SiteAddParam)2 SiteDetailRestRep (com.emc.storageos.model.dr.SiteDetailRestRep)2 DownloadProgress (com.emc.vipr.model.sys.DownloadProgress)2 Date (java.util.Date)2 Map (java.util.Map)2 Matchers.anyString (org.mockito.Matchers.anyString)2 InternalSiteServiceClient (com.emc.storageos.api.service.impl.resource.utils.InternalSiteServiceClient)1 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)1 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)1 SiteMonitorResult (com.emc.storageos.coordinator.client.model.SiteMonitorResult)1 NetworkHealth (com.emc.storageos.coordinator.client.model.SiteNetworkState.NetworkHealth)1 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)1