Search in sources :

Example 6 with DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress 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 DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress 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 DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress 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 DualInetAddress

use of com.emc.storageos.coordinator.client.service.impl.DualInetAddress 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)

Example 10 with DualInetAddress

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

the class ConnectVdcTaskOp method checkNetworkTopology.

private String checkNetworkTopology(VdcPreCheckResponse vdcBeingAdded) {
    SoftwareVersion remoteVer = new SoftwareVersion(vdcBeingAdded.getSoftwareVersion());
    if (remoteVer.compareTo(netcheckMinVer) >= 0) {
        String nodeId = this.dbClient.getCoordinatorClient().getPropertyInfo().getProperty("node_id");
        log.info("Retrieving IP addresses of local node: {}, and let remote VDC {} check if we're behind a NAT", nodeId, vdcBeingAdded.getShortId());
        DualInetAddress inetAddress = this.dbClient.getCoordinatorClient().getInetAddessLookupMap().getDualInetAddress();
        String ipv4 = inetAddress.getInet4();
        String ipv6 = inetAddress.getInet6();
        log.info("Got local node's IP addresses, IPv4 = {}, IPv6 = {}", ipv4, ipv6);
        VdcNatCheckParam checkParam = new VdcNatCheckParam();
        checkParam.setIPv4Address(ipv4);
        checkParam.setIPv6Address(ipv6);
        VdcNatCheckResponse resp = geoClientCache.getGeoClient(vdcInfo).vdcNatCheck(checkParam);
        if (resp.isBehindNAT()) {
            return String.format("The remote VDC %s seen this node's IP is %s, which is different from what we think: %s or %s, we may behind a NAT", vdcBeingAdded.getShortId(), resp.getSeenIp(), ipv4, ipv6);
        }
    } else {
        log.info("Remote VDC is of version {}, lower than {}, NAT check skipped.", remoteVer, netcheckMinVer);
    }
    return null;
}
Also used : SoftwareVersion(com.emc.storageos.coordinator.client.model.SoftwareVersion) VdcNatCheckParam(com.emc.storageos.geomodel.VdcNatCheckParam) VdcNatCheckResponse(com.emc.storageos.geomodel.VdcNatCheckResponse) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Aggregations

DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)26 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)13 HashMap (java.util.HashMap)9 ZkConnection (com.emc.storageos.coordinator.common.impl.ZkConnection)8 URI (java.net.URI)8 FileInputStream (java.io.FileInputStream)6 UnknownHostException (java.net.UnknownHostException)6 ArrayList (java.util.ArrayList)6 Properties (java.util.Properties)5 Before (org.junit.Before)5 CoordinatorClientImpl (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientImpl)4 KeyCertificateAlgorithmValuesHolder (com.emc.storageos.security.keystore.impl.KeyCertificateAlgorithmValuesHolder)4 Test (org.junit.Test)4 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)3 KeyCertificatePairGenerator (com.emc.storageos.security.keystore.impl.KeyCertificatePairGenerator)3 DistributedLoadKeyStoreParam (com.emc.storageos.security.keystore.impl.DistributedLoadKeyStoreParam)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 Ignore (org.junit.Ignore)2 SoftwareVersion (com.emc.storageos.coordinator.client.model.SoftwareVersion)1