Search in sources :

Example 1 with SiteList

use of com.emc.storageos.model.dr.SiteList 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);
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteList(com.emc.storageos.model.dr.SiteList) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with SiteList

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

the class InternalSiteServiceClient method getSiteList.

public SiteList getSiteList() {
    WebResource rRoot = createRequest(SITE_INTERNAL_LIST);
    ClientResponse resp = null;
    resp = addSignature(rRoot).get(ClientResponse.class);
    SiteList response = resp.getEntity(SiteList.class);
    return response;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) SiteList(com.emc.storageos.model.dr.SiteList) WebResource(com.sun.jersey.api.client.WebResource)

Example 3 with SiteList

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

the class DisasterRecoveryService method isLocalSiteRemoved.

/**
 *  Check if Local Site Removed
 *
 * @brief Check if local site is removed
 * @return result that indicates whether local site is removed
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/islocalsiteremoved")
public SiteRemoved isLocalSiteRemoved() {
    SiteRemoved response = new SiteRemoved();
    Site localSite = drUtil.getLocalSite();
    if (SiteState.ACTIVE == localSite.getState()) {
        return response;
    }
    for (Site remoteSite : drUtil.listSites()) {
        if (remoteSite.getUuid().equals(localSite.getUuid())) {
            continue;
        }
        try (InternalSiteServiceClient client = new InternalSiteServiceClient(remoteSite, coordinator, apiSignatureGenerator)) {
            SiteList sites = client.getSiteList();
            if (!isActiveSite(remoteSite.getUuid(), sites)) {
                continue;
            }
            if (isSiteContainedBy(localSite.getUuid(), sites)) {
                return response;
            } else {
                log.info("According returned result from current active site {}, local site {} has been removed", remoteSite.getUuid(), localSite.getUuid());
                response.setIsRemoved(true);
                return response;
            }
        } catch (Exception e) {
            log.warn("Error happened when fetching site list from site {}", remoteSite.getUuid(), e);
            continue;
        }
    }
    return response;
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) SiteList(com.emc.storageos.model.dr.SiteList) SiteRemoved(com.emc.storageos.model.dr.SiteRemoved) InternalSiteServiceClient(com.emc.storageos.api.service.impl.resource.utils.InternalSiteServiceClient) 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 4 with SiteList

use of com.emc.storageos.model.dr.SiteList 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;
}
Also used : SiteList(com.emc.storageos.model.dr.SiteList) Site(com.emc.storageos.coordinator.client.model.Site) SiteInfo(com.emc.storageos.coordinator.client.model.SiteInfo) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

SiteList (com.emc.storageos.model.dr.SiteList)4 Site (com.emc.storageos.coordinator.client.model.Site)3 SiteInfo (com.emc.storageos.coordinator.client.model.SiteInfo)2 GET (javax.ws.rs.GET)2 Produces (javax.ws.rs.Produces)2 InternalSiteServiceClient (com.emc.storageos.api.service.impl.resource.utils.InternalSiteServiceClient)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 SiteRemoved (com.emc.storageos.model.dr.SiteRemoved)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 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 WebResource (com.sun.jersey.api.client.WebResource)1 UnknownHostException (java.net.UnknownHostException)1 ArrayList (java.util.ArrayList)1 Path (javax.ws.rs.Path)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1