Search in sources :

Example 6 with SiteRestRep

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

the class DisasterRecovery method checkFailoverProgress.

public static void checkFailoverProgress(String uuid) {
    SiteRestRep siteRest = DisasterRecoveryUtils.getSite(uuid);
    renderJSON(siteRest);
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep)

Example 7 with SiteRestRep

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

the class DisasterRecovery method itemsJson.

private static void itemsJson(List<String> uuids) {
    List<SiteRestRep> standbySites = new ArrayList<SiteRestRep>();
    for (String uuid : uuids) {
        SiteRestRep standbySite = DisasterRecoveryUtils.getSite(uuid);
        if (standbySite != null) {
            standbySites.add(standbySite);
        }
    }
    performItemsJson(standbySites, new JsonItemOperation());
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) ArrayList(java.util.ArrayList)

Example 8 with SiteRestRep

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

the class DisasterRecovery method listJson.

public static void listJson() {
    List<DisasterRecoveryDataTable.StandByInfo> disasterRecoveries = Lists.newArrayList();
    for (SiteRestRep siteConfig : DisasterRecoveryUtils.getSites()) {
        disasterRecoveries.add(new StandByInfo(siteConfig));
    }
    renderJSON(DataTablesSupport.createJSON(disasterRecoveries, params));
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) StandByInfo(models.datatable.DisasterRecoveryDataTable.StandByInfo)

Example 9 with SiteRestRep

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

the class DisasterRecoveryUtils method getStandbySites.

public static List<SiteRestRep> getStandbySites() {
    List<SiteRestRep> sites = getViprClient().site().listAllSites().getSites();
    Iterator<SiteRestRep> iterator = sites.iterator();
    while (iterator.hasNext()) {
        SiteRestRep site = iterator.next();
        if (site.getState().toUpperCase().equals(String.valueOf(SiteState.ACTIVE))) {
            iterator.remove();
        }
    }
    return sites;
}
Also used : SiteRestRep(com.emc.storageos.model.dr.SiteRestRep)

Example 10 with SiteRestRep

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

the class DisasterRecoveryServiceTest method testAddStandby.

@Test
public void testAddStandby() {
    // prepare parameters for adding standby
    String name = "new-added-standby";
    String desc = "standby-site-1-description";
    String vip = "10.247.101.112";
    String username = "root";
    String password = "password";
    String uuid = "new-added-standby-site-1";
    String version = "vipr-2.4.0.0.100";
    HashMap<String, String> hostIPv4AddressMap = new HashMap<String, String>();
    hostIPv4AddressMap.put("vipr1", "10.247.101.111");
    SiteConfigRestRep config = new SiteConfigRestRep();
    config.setUuid(uuid);
    config.setVip(vip);
    config.setHostIPv4AddressMap(hostIPv4AddressMap);
    config.setHostIPv6AddressMap(new HashMap<String, String>());
    com.emc.vipr.client.core.Site site = mock(com.emc.vipr.client.core.Site.class);
    doReturn(config).when(site).getStandbyConfig();
    // mock a ViPRCoreClient with specific UUID
    ViPRCoreClient mockViPRCoreClient = mock(ViPRCoreClient.class);
    doReturn(mockViPRCoreClient).when(drService).createViPRCoreClient(vip, username, password);
    doReturn(site).when(mockViPRCoreClient).site();
    // mock a ViPRSystemClient with specific UUID
    doReturn(mockViPRSystemClient(version)).when(drService).createViPRSystemClient(vip, username, password);
    // mock a local VDC
    List<Configuration> allConfigs = new ArrayList<>();
    allConfigs.add(standbySite1.toConfiguration());
    allConfigs.add(standbySite2.toConfiguration());
    allConfigs.add(primarySite.toConfiguration());
    doReturn(allConfigs).when(coordinator).queryAllConfiguration(String.format("%s/vdc1", Site.CONFIG_KIND));
    doReturn(standbySite1.toConfiguration()).when(coordinator).queryConfiguration(String.format("%s/vdc1", Site.CONFIG_KIND), standbySite1.getUuid());
    doReturn(standbySite2.toConfiguration()).when(coordinator).queryConfiguration(String.format("%s/vdc1", Site.CONFIG_KIND), standbySite2.getUuid());
    // mock new added site
    Site newAdded = new Site();
    newAdded.setUuid(uuid);
    newAdded.setVip(vip);
    newAdded.getHostIPv4AddressMap().put("vipr1", "1.1.1.1");
    newAdded.setState(SiteState.ACTIVE);
    doReturn(newAdded.toConfiguration()).when(coordinator).queryConfiguration(String.format("%s/vdc1", Site.CONFIG_KIND), newAdded.getUuid());
    doReturn(new PropertyInfoExt()).when(coordinator).getTargetInfo(PropertyInfoExt.class);
    // mock checking and validating methods
    doNothing().when(drService).precheckForSiteNumber();
    doNothing().when(drService).precheckForStandbyAdd(any(SiteConfigRestRep.class), any(ViPRCoreClient.class));
    doNothing().when(drService).validateAddParam(any(SiteAddParam.class), any(List.class));
    doReturn(standbySite1).when(drUtil).getActiveSite();
    doReturn(secretKey).when(apiSignatureGeneratorMock).getSignatureKey(SignatureKeyType.INTERVDC_API);
    // assemble parameters, add standby
    SiteAddParam params = new SiteAddParam();
    params.setName(name);
    params.setDescription(desc);
    params.setVip(vip);
    params.setUsername(username);
    params.setPassword(password);
    SiteRestRep rep = drService.addStandby(params);
    // verify the REST response
    assertEquals(name, rep.getName());
    assertEquals(desc, rep.getDescription());
    assertEquals(vip, rep.getVipEndpoint());
}
Also used : Site(com.emc.storageos.coordinator.client.model.Site) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) SiteRestRep(com.emc.storageos.model.dr.SiteRestRep) Configuration(com.emc.storageos.coordinator.common.Configuration) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) SiteAddParam(com.emc.storageos.model.dr.SiteAddParam) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) SiteConfigRestRep(com.emc.storageos.model.dr.SiteConfigRestRep) SiteList(com.emc.storageos.model.dr.SiteList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Test(org.junit.Test)

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