SfcOvsUtil { public static ServiceFunctionForwarder augmentSffWithOpenFlowNodeId(ServiceFunctionForwarder sff) { String ofNodeId = SfcOvsUtil.getOpenFlowNodeIdForSff(sff); if (ofNodeId != null) { SffOvsBridgeAugmentationBuilder sffOvsBrAugBuilder; OvsBridgeBuilder ovsBrBuilder; SffOvsBridgeAugmentation sffOvsBrAug = sff.getAugmentation(SffOvsBridgeAugmentation.class); if (sffOvsBrAug != null) { sffOvsBrAugBuilder = new SffOvsBridgeAugmentationBuilder(sffOvsBrAug); OvsBridge ovsBridge = sffOvsBrAug.getOvsBridge(); if (ovsBridge != null) { ovsBrBuilder = new OvsBridgeBuilder(ovsBridge); } else { ovsBrBuilder = new OvsBridgeBuilder(); } } else { sffOvsBrAugBuilder = new SffOvsBridgeAugmentationBuilder(); ovsBrBuilder = new OvsBridgeBuilder(); } ovsBrBuilder.setOpenflowNodeId(ofNodeId); sffOvsBrAugBuilder.setOvsBridge(ovsBrBuilder.build()); ServiceFunctionForwarderBuilder sffBuilder = new ServiceFunctionForwarderBuilder(sff); sffBuilder.addAugmentation(SffOvsBridgeAugmentation.class, sffOvsBrAugBuilder.build()); return sffBuilder.build(); } else { return sff; } }  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 testAugmentSffWithOpenFlowNodeId() throws Exception { ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder(); serviceFunctionForwarderBuilder.setName(new SffName(testString)); SffOvsBridgeAugmentationBuilder sffOvsBridgeAugmentationBuilder = new SffOvsBridgeAugmentationBuilder(); OvsBridgeBuilder ovsBridgeBuilder = new OvsBridgeBuilder(); IpBuilder ipBuilder = new IpBuilder(); ServiceFunctionForwarder serviceFunctionForwarder = SfcOvsUtil.augmentSffWithOpenFlowNodeId(serviceFunctionForwarderBuilder.build()); assertNotNull("Must not be null", serviceFunctionForwarder); assertEquals("Must be equal", serviceFunctionForwarder.getName().getValue(), testString); ipBuilder.setIp(new IpAddress(new Ipv4Address(testIpAddress))); ovsBridgeBuilder.setBridgeName(testBridgeName); sffOvsBridgeAugmentationBuilder.setOvsBridge(ovsBridgeBuilder.build()); serviceFunctionForwarderBuilder.setSffDataPlaneLocator(createSffDataPlaneLocatorList(null, ipBuilder.build())) .addAugmentation(SffOvsBridgeAugmentation.class, sffOvsBridgeAugmentationBuilder.build()) .setKey(new ServiceFunctionForwarderKey(new SffName(testIpAddress))); serviceFunctionForwarder = SfcOvsUtil.augmentSffWithOpenFlowNodeId(serviceFunctionForwarderBuilder.build()); assertNotNull("Must not be null", serviceFunctionForwarder); assertEquals("Must be equal", serviceFunctionForwarder.getKey().getName().getValue(), testIpAddress); assertEquals("Must be equal", serviceFunctionForwarder.getSffDataPlaneLocator().get(0).getKey().getName(), dplName); assertEquals("Must be equal", serviceFunctionForwarder.getSffDataPlaneLocator() .get(0) .getDataPlaneLocator() .getLocatorType() .getImplementedInterface(), Ip.class); }
@Test public void testAugmentSffWithOpenFlowNodeId1() throws Exception { final String ofNodeId = "openflow:95075992133360"; ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder(); OvsdbNodeAugmentationBuilder ovsdbNodeAugmentationBuilder = new OvsdbNodeAugmentationBuilder(); org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress ipAddress = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address(testIpAddress)); ovsdbNodeAugmentationBuilder.setConnectionInfo( new ConnectionInfoBuilder().setRemoteIp(ipAddress).build()); NodeBuilder nodeBuilder = new NodeBuilder(); nodeBuilder.setKey(new NodeKey(new NodeId("nodeId"))).addAugmentation(OvsdbNodeAugmentation.class, ovsdbNodeAugmentationBuilder.build()); InstanceIdentifier<Node> nodeIID = InstanceIdentifier.create(NetworkTopology.class) .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID)) .child(Node.class, new NodeKey(new NodeId("nodeId"))); boolean transactionSuccessful = SfcDataStoreAPI.writePutTransactionAPI(nodeIID, nodeBuilder.build(), LogicalDatastoreType.CONFIGURATION); assertTrue("Must be true", transactionSuccessful); serviceFunctionForwarderBuilder.setKey(new ServiceFunctionForwarderKey(new SffName(testString))) .setIpMgmtAddress(new IpAddress(new Ipv4Address(testIpAddress))); ServiceFunctionForwarder serviceFunctionForwarder = serviceFunctionForwarderBuilder.build(); assertNotNull("Must not be null", serviceFunctionForwarder); assertEquals("Must be equal", serviceFunctionForwarder.getKey().getName().getValue(), testString); assertEquals("Must be equal", serviceFunctionForwarder.getIpMgmtAddress().getIpv4Address().getValue(), testIpAddress); OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder(); ovsdbBridgeAugmentationBuilder.setDatapathId(new DatapathId(testDataPath)); InstanceIdentifier<OvsdbBridgeAugmentation> bridgeEntryIID = InstanceIdentifier.create(NetworkTopology.class) .child(Topology.class, new TopologyKey(SouthboundConstants.OVSDB_TOPOLOGY_ID)) .child(Node.class, new NodeKey(new NodeId(testIpAddress + "/bridge/" + testBridgeName))) .augmentation(OvsdbBridgeAugmentation.class); transactionSuccessful = SfcDataStoreAPI.writePutTransactionAPI(bridgeEntryIID, ovsdbBridgeAugmentationBuilder.build(), LogicalDatastoreType.OPERATIONAL); assertTrue("Must be true", transactionSuccessful); IpBuilder ipBuilder = new IpBuilder(); ipBuilder.setIp(new IpAddress((new Ipv4Address(ipv4Address)))).setPort(new PortNumber(5000)); DataPlaneLocatorBuilder dataPlaneLocatorBuilder = new DataPlaneLocatorBuilder(); dataPlaneLocatorBuilder.setTransport(VxlanGpe.class).setLocatorType(ipBuilder.build()); List<SffDataPlaneLocator> sffDataPlaneLocators = new ArrayList<>(); SffDataPlaneLocatorBuilder sffDataPlaneLocatorBuilder = new SffDataPlaneLocatorBuilder(); SffDataPlaneLocatorName sffDplName = new SffDataPlaneLocatorName("sffLocator"); sffDataPlaneLocatorBuilder.setName(sffDplName) .setKey(new SffDataPlaneLocatorKey(sffDplName)) .setDataPlaneLocator(dataPlaneLocatorBuilder.build()); sffDataPlaneLocators.add(sffDataPlaneLocatorBuilder.build()); OvsBridgeBuilder ovsBridgeBuilder = new OvsBridgeBuilder(); ovsBridgeBuilder.setBridgeName(testBridgeName); SffOvsBridgeAugmentationBuilder sffOvsBridgeAugmentationBuilder = new SffOvsBridgeAugmentationBuilder(); sffOvsBridgeAugmentationBuilder.setOvsBridge(ovsBridgeBuilder.build()); serviceFunctionForwarderBuilder = new ServiceFunctionForwarderBuilder(); serviceFunctionForwarderBuilder .addAugmentation(SffOvsBridgeAugmentation.class, sffOvsBridgeAugmentationBuilder.build()) .setKey(new ServiceFunctionForwarderKey(new SffName(testString))) .setSffDataPlaneLocator(sffDataPlaneLocators); serviceFunctionForwarder = SfcOvsUtil.augmentSffWithOpenFlowNodeId(serviceFunctionForwarderBuilder.build()); assertNotNull("Must not be null", serviceFunctionForwarder); assertEquals("Must be equal", serviceFunctionForwarder.getAugmentation(SffOvsBridgeAugmentation.class) .getOvsBridge() .getOpenflowNodeId(), ofNodeId); assertEquals("Must be equal", serviceFunctionForwarder.getKey().getName().getValue(), testString); }