Write SwitchFeatures to operational datastore 67/46167/1
authorTomas Slusny <tomas.slusny@pantheon.sk>
Mon, 26 Sep 2016 08:34:02 +0000 (10:34 +0200)
committerTomas Slusny <tomas.slusny@pantheon.sk>
Mon, 26 Sep 2016 08:34:02 +0000 (10:34 +0200)
Ensures that SwitchFeatures are written to operational
datastore during device initialization in Lithium design.

Fixes: bug 6764
Change-Id: Ib32f15b73febe4d9115884d418bfe87b8e716635
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.sk>
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/common/NodeStaticReplyTranslatorUtil.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/util/DeviceInitializationUtils.java

index 61c737efa9998a4f5237cce17cb1f69467f8bc5c..78018d83a6ae45d97ebd1049fe5a959b8cf11247 100644 (file)
@@ -79,7 +79,7 @@ public class NodeStaticReplyTranslatorUtil {
      * @param reply
      * @return
      */
-    public static FlowCapableNode nodeDescTranslator(@CheckForNull final MultipartReplyDesc reply, final IpAddress ipAddress) {
+    public static FlowCapableNodeBuilder nodeDescTranslator(@CheckForNull final MultipartReplyDesc reply, final IpAddress ipAddress) {
         Preconditions.checkArgument(reply != null);
         final FlowCapableNodeBuilder flowCapAugBuilder = new FlowCapableNodeBuilder();
         flowCapAugBuilder.setDescription(reply.getDpDesc());
@@ -93,7 +93,7 @@ public class NodeStaticReplyTranslatorUtil {
         if (ipAddress != null) {
             flowCapAugBuilder.setIpAddress(ipAddress);
         }
-        return flowCapAugBuilder.build();
+        return flowCapAugBuilder;
     }
 
     /**
index 0ffdbab0f47dd27b981d3ade5885f03e953390fd..9a8548c82a3e2583973be250dac783d91203d984 100644 (file)
@@ -38,9 +38,10 @@ import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.impl.common.MultipartRequestInputFactory;
 import org.opendaylight.openflowplugin.impl.common.NodeStaticReplyTranslatorUtil;
 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.SwitchFeaturesUtil;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
@@ -59,6 +60,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping;
@@ -108,7 +110,7 @@ public class DeviceInitializationUtils {
         final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
         final short version = deviceInfo.getVersion();
         LOG.trace("initalizeNodeInformation for node {}", deviceInfo.getNodeId());
-        final SettableFuture<Void> returnFuture = SettableFuture.<Void>create();
+        final SettableFuture<Void> returnFuture = SettableFuture.create();
         addNodeToOperDS(deviceContext, returnFuture);
         final ListenableFuture<List<RpcResult<List<MultipartReply>>>> deviceFeaturesFuture;
         if (OFConstants.OFP_VERSION_1_0 == version) {
@@ -160,7 +162,7 @@ public class DeviceInitializationUtils {
     private static void addNodeToOperDS(final DeviceContext deviceContext, final SettableFuture<Void> future) {
         Preconditions.checkArgument(deviceContext != null);
         final NodeBuilder nodeBuilder = new NodeBuilder().setId(deviceContext.getDeviceInfo().getNodeId()).setNodeConnector(
-                Collections.<NodeConnector>emptyList());
+                Collections.emptyList());
         try {
             deviceContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, deviceContext.getDeviceInfo().getNodeInstanceIdentifier(),
                     nodeBuilder.build());
@@ -209,7 +211,7 @@ public class DeviceInitializationUtils {
 
                         final ListenableFuture<RpcResult<List<MultipartReply>>> replyTableFeatures;
 
-                        if (deviceContext.isSkipTableFeatures()){
+                        if (deviceContext.isSkipTableFeatures()) {
                             replyTableFeatures = RpcResultBuilder.<List<MultipartReply>>success().buildFuture();
                         } else {
                             replyTableFeatures = getNodeStaticInfo(
@@ -266,8 +268,12 @@ public class DeviceInitializationUtils {
 
         Preconditions.checkArgument(body instanceof MultipartReplyDescCase);
         final MultipartReplyDesc replyDesc = ((MultipartReplyDescCase) body).getMultipartReplyDesc();
-        final FlowCapableNode fcNode = NodeStaticReplyTranslatorUtil.nodeDescTranslator(replyDesc,
-                getIpAddressOf(dContext));
+        final FlowCapableNode fcNode = NodeStaticReplyTranslatorUtil
+                .nodeDescTranslator(replyDesc, getIpAddressOf(dContext))
+                .setSwitchFeatures(SwitchFeaturesUtil.getInstance().buildSwitchFeatures(
+                        new GetFeaturesOutputBuilder(dContext.getPrimaryConnectionContext().getFeatures()).build()))
+                .build();
+
         final InstanceIdentifier<FlowCapableNode> fNodeII = nodeII.augmentation(FlowCapableNode.class);
         dContext.writeToTransaction(LogicalDatastoreType.OPERATIONAL, fNodeII, fcNode);
         return true;