Search in sources :

Example 31 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class PropertyInfoTest method testEncodeDecode.

@Test
public void testEncodeDecode() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("node_id", "node2");
    map.put("system_connectemc_username", "username");
    map.put("version", "");
    map.put("twoEquals", "abc==abc==abc");
    PropertyInfoExt propertyInfo = new PropertyInfoExt(map);
    String encodeStr2 = propertyInfo.encodeAsString();
    Assert.assertTrue(encodeStr2.indexOf("node_id") != -1);
    Assert.assertTrue(encodeStr2.indexOf("system_connectemc_username") != -1);
    Assert.assertTrue(encodeStr2.indexOf("version") != -1);
    Assert.assertTrue(encodeStr2.indexOf("twoEquals") != -1);
    try {
        PropertyInfoExt props = PropertyInfoExt.class.newInstance().decodeFromString(encodeStr2);
        Assert.assertTrue(props.getAllProperties().get("system_connectemc_username").equals("username"));
        Assert.assertTrue(props.getAllProperties().get("version").equals(""));
        Assert.assertTrue(props.getAllProperties().get("twoEquals").equals("abc==abc==abc"));
    } catch (DecodingException e) {
        Assert.assertTrue(false);
    } catch (Exception e) {
        Assert.assertTrue(false);
    }
    PropertyInfoExt propertyInfo1 = new PropertyInfoExt(new String[] { "", "node_id=node2", "system_connectemc_username=username", "multiEquals=a=b=c" });
    String encodeStr1 = propertyInfo1.encodeAsString();
    char[] chars = encodeStr1.toCharArray();
    int len = chars.length;
    int count = 0;
    for (int i = 0; i < len; i++) {
        if (chars[i] == '=') {
            count++;
        }
    }
    Assert.assertTrue(count == 5);
}
Also used : HashMap(java.util.HashMap) PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) DecodingException(com.emc.storageos.coordinator.exceptions.DecodingException) DecodingException(com.emc.storageos.coordinator.exceptions.DecodingException) Test(org.junit.Test)

Example 32 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt in project coprhd-controller by CoprHD.

the class ProxyUserInitializer method setProperties.

private void setProperties(Map<String, String> properties) throws Exception {
    String str = new PropertyInfoExt(properties).encodeAsString();
    ConfigurationImpl config = new ConfigurationImpl();
    config.setKind(PropertyInfoExt.TARGET_PROPERTY);
    config.setId(PropertyInfoExt.TARGET_PROPERTY_ID);
    config.setConfig(PropertyInfoExt.TARGET_INFO, str);
    coordinator.persistServiceConfiguration(config);
}
Also used : PropertyInfoExt(com.emc.storageos.coordinator.client.model.PropertyInfoExt) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 33 with PropertyInfoExt

use of com.emc.storageos.coordinator.client.model.PropertyInfoExt 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

PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)33 HashMap (java.util.HashMap)7 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)5 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)4 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)4 CoordinatorClientException (com.emc.storageos.systemservices.exceptions.CoordinatorClientException)4 Test (org.junit.Test)4 Site (com.emc.storageos.coordinator.client.model.Site)3 SyssvcException (com.emc.storageos.systemservices.exceptions.SyssvcException)3 IOException (java.io.IOException)3 ConfigVersion (com.emc.storageos.coordinator.client.model.ConfigVersion)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)2 SiteParam (com.emc.storageos.model.dr.SiteParam)2 PropertyInfoRestRep (com.emc.storageos.model.property.PropertyInfoRestRep)2 PropertyMetadata (com.emc.storageos.model.property.PropertyMetadata)2 InvalidLockOwnerException (com.emc.storageos.systemservices.exceptions.InvalidLockOwnerException)2 UnknownHostException (java.net.UnknownHostException)2 ArrayList (java.util.ArrayList)2 PowerOffState (com.emc.storageos.coordinator.client.model.PowerOffState)1