Bug 3107: Sfc-OVS lacks API for storing OVS Bridge Openflow ID 27/19527/4
authorAndrej Kincel <[email protected]>
Mon, 4 May 2015 14:10:05 +0000 (16:10 +0200)
committerAndrej Kincel <[email protected]>
Tue, 5 May 2015 11:44:20 +0000 (13:44 +0200)
Change-Id: I87fbf73eec44d99e4612235085394efa6239abd7
Signed-off-by: Andrej Kincel <[email protected]>
sfc-model/src/main/yang/service-function-forwarder-ovs.yang
sfc-ovs/src/main/java/org/opendaylight/sfc/sfc_ovs/provider/api/SfcOvsToSffMappingAPI.java
sfc-ui/src/main/resources/pages/assets/data/locale-en_US.json
sfc-ui/src/main/resources/pages/src/app/sfc/serviceforwarder/serviceforwarder.create.tpl.html

index 475b1a9a8c41923bc1795cecaa7a92992ca54c8f..c17804526ff00c9f36c9c62f50ab8aebcff74de7 100644 (file)
@@ -56,6 +56,10 @@ module service-function-forwarder-ovs {
         description "Open vSwitch bridge UUID";
         type yang:uuid;
       }
+      leaf openflow-node-id {
+        description "Openflow node ID";
+        type string;
+      }
       list external-ids {
         description
           "The list of external ids associated with this
index f584128e7912a09e7d7f8cec64fbdebc390670b9..ea9b755e1f22f7bd42f8509e527bbfcedfd1404a 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev14070
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.IpBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.DatapathId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
@@ -50,6 +51,7 @@ import org.slf4j.LoggerFactory;
  */
 public class SfcOvsToSffMappingAPI {
 
+    private static final String OPENFLOW_PREFIX = "openflow:";
     private static final Logger LOG = LoggerFactory.getLogger(SfcOvsToSffMappingAPI.class);
 
     /**
@@ -82,6 +84,7 @@ public class SfcOvsToSffMappingAPI {
             OvsBridgeBuilder ovsBridgeBuilder = new OvsBridgeBuilder();
             ovsBridgeBuilder.setBridgeName(ovsdbBridgeAugmentation.getBridgeName().getValue());
             ovsBridgeBuilder.setUuid(ovsdbBridgeAugmentation.getBridgeUuid());
+            ovsBridgeBuilder.setOpenflowNodeId(getOvsBridgeOpenflowNodeId(ovsdbBridgeAugmentation.getDatapathId()));
             ovsServiceForwarder2Augmentation.setOvsBridge(ovsBridgeBuilder.build());
             serviceFunctionForwarderBuilder.addAugmentation(ServiceFunctionForwarder2.class, ovsServiceForwarder2Augmentation.build());
 
@@ -118,6 +121,7 @@ public class SfcOvsToSffMappingAPI {
             OvsBridgeBuilder ovsBridgeBuilder = new OvsBridgeBuilder();
             ovsBridgeBuilder.setBridgeName(ovsdbBridge.getBridgeName().getValue());
             ovsBridgeBuilder.setUuid(ovsdbBridge.getBridgeUuid());
+            ovsBridgeBuilder.setOpenflowNodeId(getOvsBridgeOpenflowNodeId(ovsdbBridge.getDatapathId()));
 
             //fill SffDataPlaneLocatorList with DP locators
             for (TerminationPoint terminationPoint : terminationPointList) {
@@ -168,8 +172,7 @@ public class SfcOvsToSffMappingAPI {
             //set ip:port locator
             IpBuilder ipBuilder = new IpBuilder();
 
-            List<Options> options = terminationPoint.getOptions();
-            for (Options option : options) {
+            for (Options option : terminationPoint.getOptions()) {
                 switch (option.getOption()) {
                     case SfcOvsUtil.OVSDB_OPTION_LOCAL_IP:
                         IpAddress localIp = SfcOvsUtil.convertStringToIpAddress(option.getValue());
@@ -287,4 +290,21 @@ public class SfcOvsToSffMappingAPI {
         }
         return null;
     }
+
+    /**
+     * Returns OpenflowNodeId of OvsBridge specified by DatapathId.
+     * OpenflowNodeId = openflow:hexTodec(DatapathId)
+     * <p/>
+     * Parameter DatapathId
+     * must be not null otherwise NullPointerException will be raised.
+     *
+     * @param datapathId DatapathId
+     * @return String OpenflowNodeId
+     */
+    private static String getOvsBridgeOpenflowNodeId(DatapathId datapathId) {
+        Preconditions.checkNotNull(datapathId, "DatapathId is null, cannot get Bridge OpenflowNode Id");
+
+        Long datapathIdDec = Long.parseLong(datapathId.getValue().replaceAll(":", ""), 16);
+        return OPENFLOW_PREFIX + datapathIdDec.toString();
+    }
 }
index 2fcf7531362c38aa69e8a90cac0d65cb17152f79..537450db5f6268c99b18620e86e49e26709ad33e 100755 (executable)
   "SFC_FORWARDER_IP_MGMT_ADDRESS": "The IP and port used to configure this SFF",\r
   "SFC_FORWARDER_SHORT_IP_MGMT_ADDRESS": "IP management address",\r
   "SFC_FORWARDER_CREATE_IP_MGMT_ADDRESS": "Example 10.0.0.1:5555",\r
+  "SFC_FORWARDER_BRIDGE_OPENFLOW_NODE_ID": "Openflow Node Id",\r
   "SFC_FORWARDER_OVS_BRIDGE": "OVS Bridge",\r
   "SFC_FORWARDER_BRIDGE_NAME": "Open vSwitch bridge name",\r
   "SFC_FORWARDER_SHORT_BRIDGE_NAME": "Name",\r
index f8acde2f65d526650c8dc41404c7661ef62ff533..8be1e1ab54da75bb78e8a7840ea84cd65f607fd1 100755 (executable)
                 </div>
             </div>
 
+            <h4 style="padding-left: 30px;">{{'SFC_FORWARDER_OVS_BRIDGE' | translate}}</h4>
+            <div class="form-group">
+                <label for="bridge_openflow_node_id_{{idSuffix}}" class="col-lg-6 control-label small-label">
+                    {{'SFC_FORWARDER_BRIDGE_OPENFLOW_NODE_ID' | translate}}
+                </label>
+
+                <div class="col-lg-6">
+                    <input type="text" class="form-control input-sm" ng-model="data['service-function-forwarder-ovs:ovs-bridge']['openflow-node-id']"
+                           id="bridge_openflow_node_id_{{idSuffix}}" name="bridge_openflow_node_id" readonly>
+                </div>
+            </div>
+
         </div>
     </div>
 </div>