public Node connect(String identifier, Map<ConnectionConstants, String> params) { InetAddress address; Integer port; try { address = InetAddress.getByName(params.get(ConnectionConstants.ADDRESS)); } catch (Exception e) { logger.error("Unable to resolve " + params.get(ConnectionConstants.ADDRESS), e); return null; } try { port = Integer.parseInt(params.get(ConnectionConstants.PORT)); if (port == 0) { port = DEFAULT_OVSDB_PORT; } } catch (Exception e) { port = DEFAULT_OVSDB_PORT; } try { OvsdbClient client = connectionLib.connect(address, port); return handleNewConnection(identifier, client); } catch (InterruptedException e) { logger.error("Thread was interrupted during connect", e); } catch (ExecutionException e) { logger.error("ExecutionException in handleNewConnection for identifier " + identifier, e); } return null; }
public OvsdbClient connect(InstanceIdentifier<Node> iid, OvsdbNodeAugmentation ovsdbNode) throws UnknownHostException, ConnectException { LOG.info("Connecting to {}", SouthboundUtil.connectionInfoToString(ovsdbNode.getConnectionInfo())); // TODO handle case where we already have a connection // TODO use transaction chains to handle ordering issues between disconnected // TODO and connected when writing to the operational store InetAddress ip = SouthboundMapper.createInetAddress(ovsdbNode.getConnectionInfo().getRemoteIp()); OvsdbClient client = ovsdbConnection.connect(ip, ovsdbNode.getConnectionInfo().getRemotePort().getValue()); // For connections from the controller to the ovs instance, the library doesn't call // this method for us if (client != null) { putInstanceIdentifier(ovsdbNode.getConnectionInfo(), iid.firstIdentifierOf(Node.class)); OvsdbConnectionInstance ovsdbConnectionInstance = connectedButCallBacksNotRegistered(client); ovsdbConnectionInstance.setOvsdbNodeAugmentation(ovsdbNode); // Register Cluster Ownership for ConnectionInfo registerEntityForOwnership(ovsdbConnectionInstance); } else { LOG.warn("Failed to connect to OVSDB Node {}", ovsdbNode.getConnectionInfo()); } return client; }