SfcOvsUtil { public static String getOpenFlowNodeIdForSff(ServiceFunctionForwarder serviceFunctionForwarder) { Node managerNode = lookupTopologyNode(serviceFunctionForwarder, executor); if (managerNode == null) { LOG.warn("No Topology Node for Service Function Forwarder {}", serviceFunctionForwarder); return null; } SffOvsBridgeAugmentation serviceForwarderOvsBridgeAugmentation = serviceFunctionForwarder.getAugmentation(SffOvsBridgeAugmentation.class); if (serviceForwarderOvsBridgeAugmentation == null) { LOG.warn("No SffOvsBridgeAugmentation for Service Function Forwarder {}", serviceFunctionForwarder); return null; } OvsBridge serviceForwarderOvsBridge = serviceForwarderOvsBridgeAugmentation.getOvsBridge(); if (serviceForwarderOvsBridge == null) { LOG.warn("No OvsBridge for SffOvsBridgeAugmentation in Service Function Forwarder {}", serviceFunctionForwarder); return null; } OvsdbBridgeAugmentationBuilder builder = new OvsdbBridgeAugmentationBuilder(); OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(SfcOvsUtil.buildOvsdbNodeIID(managerNode.getNodeId())); builder.setManagedBy(ovsdbNodeRef); builder.setBridgeName(new OvsdbBridgeName(serviceForwarderOvsBridge.getBridgeName())); NodeId nodeId = getManagedByNodeId(builder.build()); DatapathId datapathId = getOvsDataPathId(nodeId); if (datapathId == null) { LOG.warn("No DatapathId for Service Function Forwarder {}", serviceFunctionForwarder); return null; } Long macLong = getLongFromDpid(datapathId.getValue()); return "openflow:" + String.valueOf(macLong); }  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 getOpenFlowNodeIdForSffNullTests() { ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder(); SffOvsBridgeAugmentationBuilder sffOvsBridgeAugmentationBuilder = new SffOvsBridgeAugmentationBuilder(); String result = SfcOvsUtil.getOpenFlowNodeIdForSff(serviceFunctionForwarderBuilder.build()); assertNull("Must be null", result); serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder(); serviceFunctionForwarderBuilder.addAugmentation(SffOvsBridgeAugmentation.class, sffOvsBridgeAugmentationBuilder.build()); result = SfcOvsUtil.getOpenFlowNodeIdForSff(serviceFunctionForwarderBuilder.build()); assertNull("Must be null", result); }
@Test public void getOpenFlowNodeIdForSffNullTests1() { ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder(); OvsBridgeBuilder ovsBridgeBuilder = new OvsBridgeBuilder(); SffOvsBridgeAugmentationBuilder sffOvsBridgeAugmentationBuilder = new SffOvsBridgeAugmentationBuilder(); ovsBridgeBuilder.setBridgeName(testBridgeName); sffOvsBridgeAugmentationBuilder.setOvsBridge(ovsBridgeBuilder.build()); serviceFunctionForwarderBuilder.addAugmentation(SffOvsBridgeAugmentation.class, sffOvsBridgeAugmentationBuilder.build()); String result = SfcOvsUtil.getOpenFlowNodeIdForSff(serviceFunctionForwarderBuilder.build()); assertNull("Must be null", result); }