SfcOvsUtil { public static Node getManagerNodeByIp(IpAddress ip, ExecutorService executor) { String ipAddressString = null; if ((ip == null) || ((ip.getIpv4Address() == null) && (ip.getIpv6Address() == null))) { LOG.warn("Invalid IP address"); return null; } if (ip.getIpv4Address() != null) { ipAddressString = ip.getIpv4Address().getValue(); } else if (ip.getIpv6Address() != null) { ipAddressString = ip.getIpv6Address().getValue(); } Object[] methodParams = {ipAddressString}; SfcOvsDataStoreAPI sfcOvsDataStoreAPI = new SfcOvsDataStoreAPI(SfcOvsDataStoreAPI.Method.READ_OVSDB_NODE_BY_IP, methodParams); Node node = (Node) SfcOvsUtil.submitCallable(sfcOvsDataStoreAPI, executor); if (node != null && node.getNodeId() != null) { return node; } else { LOG.warn("OVS Node for IP address {} does not exist!", methodParams[0]); return null; } }  static Object submitCallable(Callable callable, ExecutorService executor); static InstanceIdentifier<Topology> buildOvsdbTopologyIID(); static InstanceIdentifier<Node> buildOvsdbNodeIID(OvsdbBridgeAugmentation ovsdbBridge); static InstanceIdentifier<Node> buildOvsdbNodeIID(String serviceFunctionForwarderName); static InstanceIdentifier<Node> buildOvsdbNodeIID(NodeId nodeId); static InstanceIdentifier<OvsdbBridgeAugmentation> buildOvsdbBridgeIID(OvsdbBridgeAugmentation ovsdbBridge); static InstanceIdentifier<OvsdbBridgeAugmentation> buildOvsdbBridgeIID(NodeId nodeId); static InstanceIdentifier<OvsdbBridgeAugmentation> buildOvsdbBridgeIID(String serviceFunctionForwarderName); static InstanceIdentifier<OvsdbTerminationPointAugmentation> buildOvsdbTerminationPointAugmentationIID(
            OvsdbBridgeAugmentation ovsdbBridge, OvsdbTerminationPointAugmentation ovsdbTerminationPoint); static InstanceIdentifier<TerminationPoint> buildOvsdbTerminationPointIID(String sffName,
            String sffDataPlaneLocatorName); static IpAddress convertStringToIpAddress(String ipAddressString); static String convertIpAddressToString(IpAddress ipAddress); static boolean putOvsdbTerminationPoints(OvsdbBridgeAugmentation ovsdbBridge,
                                                    List<SffDataPlaneLocator> sffDataPlaneLocatorList, ExecutorService executor); static boolean putOvsdbBridge(OvsdbBridgeAugmentation ovsdbBridge, ExecutorService executor); static boolean deleteOvsdbNode(InstanceIdentifier<Node> ovsdbNodeIID, ExecutorService executor); static boolean deleteOvsdbTerminationPoint(InstanceIdentifier<TerminationPoint> ovsdbTerminationPointIID,
            ExecutorService executor); static ServiceFunctionForwarder augmentSffWithOpenFlowNodeId(ServiceFunctionForwarder sff); static Ip getSffVxlanDataLocator(ServiceFunctionForwarder sff); static Node lookupTopologyNode(ServiceFunctionForwarder serviceFunctionForwarder, ExecutorService executor); static String getOpenFlowNodeIdForSff(ServiceFunctionForwarder serviceFunctionForwarder); static Node getManagerNodeByIp(IpAddress ip, ExecutorService executor); static OvsdbNodeAugmentation getOvsdbNodeAugmentation(OvsdbNodeRef nodeRef, ExecutorService executor); static Long getOfPortByName(String nodeName, String portName); static Long getVxlanOfPort(String nodeName); static Long getVxlanGpeOfPort(String nodeName); static Long getDpdkOfPort(String nodeName, String dpdkPortName); static final String OVSDB_OPTION_LOCAL_IP; static final String OVSDB_OPTION_REMOTE_IP; static final String OVSDB_OPTION_DST_PORT; static final String OVSDB_OPTION_NSP; static final String OVSDB_OPTION_NSI; static final String OVSDB_OPTION_IN_NSP; static final String OVSDB_OPTION_IN_NSI; static final String OVSDB_OPTION_OUT_NSP; static final String OVSDB_OPTION_OUT_NSI; static final String OVSDB_OPTION_NSHC1; static final String OVSDB_OPTION_NSHC2; static final String OVSDB_OPTION_NSHC3; static final String OVSDB_OPTION_NSHC4; static final String OVSDB_OPTION_KEY; static final String OVSDB_OPTION_EXTS; static final String OVSDB_OPTION_GPE; static final String OVSDB_OPTION_VALUE_FLOW; static final String DPL_NAME_DPDK; static final String DPL_NAME_DPDKVHOST; static final String DPL_NAME_DPDKVHOSTUSER; static final String DPL_NAME_INTERNAL; static final PortNumber NSH_VXLAN_TUNNEL_PORT; }
@Test public void testGetManagerNodeByIp() { Node node = SfcOvsUtil.getManagerNodeByIp(null, executorService); assertNull("Must be null", node); node = SfcOvsUtil.getManagerNodeByIp(new IpAddress(new Ipv6Address(ipv6Address)), executorService); assertNull("Must be null", node); }
@Test public void testGetManagerNodeByIpV4() { Node node = SfcOvsUtil.getManagerNodeByIp(new IpAddress(new Ipv4Address(testIpAddress)), executorService); assertNotNull("Must be not null", node); assertEquals("Must be equal", node.getKey().getNodeId().getValue(), testIpAddress); }