Search in sources :

Example 6 with CoordinatorClientInetAddressMap

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap in project coprhd-controller by CoprHD.

the class ProtocolSocketFactoryTest method setup.

@Before
public void setup() throws Exception {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    ks = KeyStoreUtil.getViPRKeystore(coordinatorClient);
    KeyCertificatePairGenerator gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(new KeyCertificateAlgorithmValuesHolder(coordinatorClient));
    entry = gen.generateKeyCertificatePair();
    hostName = System.getenv(KeyCertificatePairGeneratorTest.LOCALHOST_IP);
    if (StringUtils.isBlank(hostName)) {
        hostName = "localhost";
    }
    webServer = new TestWebServer(entry);
    webServer.start();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) KeyCertificateAlgorithmValuesHolder(com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder) KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) Before(org.junit.Before)

Example 7 with CoordinatorClientInetAddressMap

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap in project coprhd-controller by CoprHD.

the class SSLSocketFactoryTest method setup.

@Before
public void setup() throws Exception {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    ks = KeyStoreUtil.getViPRKeystore(coordinatorClient);
    KeyCertificateAlgorithmValuesHolder values = new KeyCertificateAlgorithmValuesHolder(coordinatorClient);
    gen = new KeyCertificatePairGenerator();
    gen.setKeyCertificateAlgorithmValuesHolder(values);
    entry = gen.generateKeyCertificatePair();
    hostName = System.getenv(KeyCertificatePairGeneratorTest.LOCALHOST_IP);
    if (StringUtils.isBlank(hostName)) {
        hostName = "localhost";
    }
    webServer = new TestWebServer(entry);
    webServer.start();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) FileInputStream(java.io.FileInputStream) KeyCertificateAlgorithmValuesHolder(com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder) KeyCertificatePairGenerator(com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) Before(org.junit.Before)

Example 8 with CoordinatorClientInetAddressMap

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap in project coprhd-controller by CoprHD.

the class TrustManagerTest method setup.

@Before
public void setup() throws IOException, URISyntaxException {
    ApplicationContextUtil.initContext(System.getProperty("buildType"), ApplicationContextUtil.SECURITY_CONTEXTS);
    List<URI> uri = new ArrayList<URI>();
    uri.add(URI.create(coordinatorServer));
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    connection.build();
    coordinatorClient.setZkConnection(connection);
    CoordinatorClientInetAddressMap map = new CoordinatorClientInetAddressMap();
    map.setNodeId("standalone");
    DualInetAddress localAddress = DualInetAddress.fromAddresses("127.0.0.1", "::1");
    map.setDualInetAddress(localAddress);
    Map<String, DualInetAddress> controllerNodeIPLookupMap = new HashMap<String, DualInetAddress>();
    controllerNodeIPLookupMap.put("localhost", localAddress);
    map.setControllerNodeIPLookupMap(controllerNodeIPLookupMap);
    coordinatorClient.setInetAddessLookupMap(map);
    coordinatorClient.start();
    FileInputStream is = new FileInputStream(defaultOvfPropsLocation);
    Properties defaultProp = new Properties();
    defaultProp.load(is);
    is.close();
    is = new FileInputStream(ovfPropsLocation);
    Properties ovfProps = new Properties();
    ovfProps.load(is);
    is.close();
    CoordinatorClientImpl.setDefaultProperties(defaultProp);
    CoordinatorClientImpl.setOvfProperties(ovfProps);
    loadStoreParam = new DistributedLoadKeyStoreParam();
    loadStoreParam.setCoordinator(coordinatorClient);
}
Also used : HashMap(java.util.HashMap) DistributedLoadKeyStoreParam(com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam) ArrayList(java.util.ArrayList) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) Properties(java.util.Properties) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) FileInputStream(java.io.FileInputStream) Before(org.junit.Before)

Example 9 with CoordinatorClientInetAddressMap

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap in project coprhd-controller by CoprHD.

the class GeoSeedProviderImpl method initCoordinatorClient.

/**
 * Construct coordinator client from argument. Seed provider instance is created by cassandra
 * on demand. Not from spring context.
 *
 * @param args
 */
private void initCoordinatorClient(Map<String, String> args) throws IOException {
    // endpoints for coordinator in local site
    String coordinatorArg = args.get(COORDINATORS);
    if (coordinatorArg == null || coordinatorArg.trim().isEmpty()) {
        throw new IllegalArgumentException(COORDINATORS);
    }
    String[] coordinators = coordinatorArg.split(",", -1);
    List<URI> uri = new ArrayList<URI>(coordinators.length);
    for (String coord : coordinators) {
        if (!coord.trim().isEmpty()) {
            uri.add(URI.create(coord.trim()));
        }
    }
    ZkConnection connection = new ZkConnection();
    connection.setServer(uri);
    String siteIdFile = args.get(Constants.SITE_ID_FILE);
    connection.setSiteIdFile(siteIdFile);
    connection.build();
    CoordinatorClientImpl client = new CoordinatorClientImpl();
    client.setZkConnection(connection);
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/nodeaddrmap-var.xml");
    CoordinatorClientInetAddressMap inetAddressMap = (CoordinatorClientInetAddressMap) ctx.getBean("inetAddessLookupMap");
    if (inetAddressMap == null) {
        log.error("CoordinatorClientInetAddressMap is not initialized. Node address lookup will fail.");
    }
    // HARCODE FOR NOW
    client.setInetAddessLookupMap(inetAddressMap);
    client.start();
    coordinator = client;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ArrayList(java.util.ArrayList) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection)

Example 10 with CoordinatorClientInetAddressMap

use of com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap in project coprhd-controller by CoprHD.

the class DbSvcRunner method getCoordinator.

/**
 * Get CoordinatorClient instance
 *
 * @return
 * @throws URISyntaxException
 * @throws IOException
 */
public CoordinatorClient getCoordinator() throws URISyntaxException, IOException {
    if (coordinator == null) {
        ZkConnection zkConn = new ZkConnection();
        List<URI> uris = new ArrayList<URI>();
        uris.add(new URI("coordinator://localhost:2181"));
        zkConn.setServer(uris);
        zkConn.setTimeoutMs(10000);
        zkConn.build();
        // Suppress Sonar violation of Lazy initialization of static fields should be synchronized
        // Junit test will be called in single thread by default, it's safe to ignore this violation
        // NOSONAR ("squid:S2444")
        coordinator = new CoordinatorClientImpl();
        coordinator.setZkConnection(zkConn);
        coordinator.setSysSvcName("syssvc");
        coordinator.setSysSvcVersion("1");
        coordinator.setNodeCount(1);
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("nodeaddrmap-var.xml");
        CoordinatorClientInetAddressMap inetAddressMap = (CoordinatorClientInetAddressMap) ctx.getBean("inetAddessLookupMap");
        if (inetAddressMap == null) {
            log.error("CoordinatorClientInetAddressMap is not initialized. Node address lookup will fail.");
        }
        Map<String, DualInetAddress> controlNodes = inetAddressMap.getControllerNodeIPLookupMap();
        // HARCODE FOR NOW
        coordinator.setInetAddessLookupMap(inetAddressMap);
        DbVersionInfo dbVersionInfo = new DbVersionInfo();
        dbVersionInfo.setSchemaVersion(SVC_VERSION);
        coordinator.setDbVersionInfo(dbVersionInfo);
        coordinator.start();
    }
    return coordinator;
}
Also used : CoordinatorClientImpl(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ArrayList(java.util.ArrayList) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) URI(java.net.URI) ZkConnection(com.emc.storageos.coordinator.common.impl.ZkConnection) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo)

Aggregations

CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)22 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)13 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)9 ArrayList (java.util.ArrayList)9 URI (java.net.URI)8 HashMap (java.util.HashMap)7 FileInputStream (java.io.FileInputStream)6 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)5 Properties (java.util.Properties)5 Before (org.junit.Before)5 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)4 KeyCertificateAlgorithmValuesHolder (com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder)4 KeyCertificatePairGenerator (com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator)3 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)2 Configuration (com.emc.storageos.coordinator.common.Configuration)2 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)2 ServiceImpl (com.emc.storageos.coordinator.common.impl.ServiceImpl)2 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)2 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)2