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();
}
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();
}
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);
}
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;
}
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;
}
Aggregations