Fix for openflow devices not connecting to controller 07/87907/16
authordheenadayalan b <dhinua@gmail.com>
Wed, 19 Feb 2020 12:12:05 +0000 (17:42 +0530)
committerArunprakash D <d.arunprakash@ericsson.com>
Wed, 9 Sep 2020 15:49:16 +0000 (15:49 +0000)
Signed-off-by: dheenadayalan b <dhinua@gmail.com>
Change-Id: I641997a74f5b5081366fcaa1fe9a56b6d1c67f5d
Signed-off-by: Dheenadayalan.b <dhinua@gmail.com>
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/impl/FlowNodeReconciliationImpl.java
applications/forwardingrules-manager/src/main/java/org/opendaylight/openflowplugin/applications/frm/util/FrmUtil.java
extension/openflowplugin-extension-onf/src/main/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleControlConverter.java
extension/openflowplugin-extension-onf/src/test/java/org/opendaylight/openflowplugin/extension/onf/converter/BundleControlConverterTest.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalBundleServiceImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/services/sal/SalExperimenterMessageServiceImpl.java

index 49f26504ff29bc12f10739e650eaf602b0a27db6..0c5bff0615bd10a3c5a5ea8b0a86d28da85ed437 100644 (file)
@@ -244,15 +244,19 @@ public class FlowNodeReconciliationImpl implements FlowNodeReconciliation {
                         = salBundleService.controlBundle(closeBundleInput);
 
                 /* Open a new bundle on the switch */
-                ListenableFuture<RpcResult<ControlBundleOutput>> openBundle =
-                        Futures.transformAsync(closeBundle,
-                            rpcResult -> salBundleService.controlBundle(openBundleInput),
-                                service);
+                ListenableFuture<RpcResult<ControlBundleOutput>> openBundle
+                        = Futures.transformAsync(closeBundle, rpcResult -> {
+                            if (rpcResult.isSuccessful()) {
+                                LOG.debug("Existing bundle is successfully closed for device {}", dpnId);
+                            }
+                            return salBundleService.controlBundle(openBundleInput);
+                        }, service);
 
                     /* Push groups and flows via bundle add messages */
                 ListenableFuture<RpcResult<AddBundleMessagesOutput>> deleteAllFlowGroupsFuture
                         = Futures.transformAsync(openBundle, rpcResult -> {
                             if (rpcResult.isSuccessful()) {
+                                LOG.debug("Open bundle is successful for device {}", dpnId);
                                 return salBundleService.addBundleMessages(deleteAllFlowGroupsInput);
                             }
                             return Futures.immediateFuture(null);
index cdcb2bf8bb81e9e713a5550ecd40f8ccf7356408..5eda39b1cdf8ed3e13e6b9dfdbde90edaaa1cb71 100644 (file)
@@ -111,11 +111,11 @@ public final class FrmUtil {
                     actions = ((WriteActionsCase)instruction.getInstruction())
                             .getWriteActions().nonnullAction().values();
                 }
-                for (Action action : actions) {
-                    if (action.getAction().implementedInterface()
-                            .equals(ActionType.GROUP_ACTION.getActionType())) {
-                        return ((GroupActionCase) action.getAction()).getGroupAction()
-                                .getGroupId();
+                if (actions != null) {
+                    for (Action action : actions) {
+                        if (action.getAction().implementedInterface().equals(ActionType.GROUP_ACTION.getActionType())) {
+                            return ((GroupActionCase) action.getAction()).getGroupAction().getGroupId();
+                        }
                     }
                 }
             }
index f717f6e1c9bf1e48be9c32bacaa83d763224c919..012b86c619a9230c42270aa4137fe785d64b6551 100644 (file)
@@ -20,6 +20,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Converter for BundleControl messages (ONF approved extension #230).
@@ -28,8 +30,12 @@ public class BundleControlConverter implements
         ConverterMessageToOFJava<BundleControlSal, BundleControlOnf, ExtensionConvertorData>,
         ConvertorMessageFromOFJava<BundleControlOnf, MessagePath> {
 
+    private static final Logger LOG = LoggerFactory.getLogger(BundleControlConverter.class);
+
     @Override
     public BundleControlOnf convert(final BundleControlSal experimenterMessageCase, final ExtensionConvertorData data) {
+        LOG.trace("Converting the bundle control message for device {} with xid {} and type {}",
+                data.getDatapathId(), data.getXid(), experimenterMessageCase.getSalControlData().getType());
         return new BundleControlOnfBuilder().setOnfControlGroupingData(
                 new OnfControlGroupingDataBuilder(experimenterMessageCase.getSalControlData()).build()).build();
     }
index 43026d398ba1672bb58307897aad8216b466c845..7f3b760d7624b85540c7aed2411e2c40dc4f5488 100644 (file)
@@ -7,11 +7,13 @@
  */
 package org.opendaylight.openflowplugin.extension.onf.converter;
 
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
+import org.opendaylight.openflowplugin.extension.api.ExtensionConvertorData;
 import org.opendaylight.openflowplugin.extension.api.path.MessagePath;
 import org.opendaylight.openflowplugin.extension.onf.BundleTestUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId;
@@ -28,6 +30,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder;
 import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
 
 /**
  * Test for {@link org.opendaylight.openflowplugin.extension.onf.converter.BundleControlConverter}.
@@ -69,7 +72,10 @@ public class BundleControlConverterTest {
 
     private void testConvertDown(final boolean withProperty) {
         final BundleControlSal original = createOFPMessage(withProperty);
-        final BundleControlOnf converted = converter.convert(original, null);
+        final ExtensionConvertorData data = new ExtensionConvertorData((short)1);
+        data.setXid(Uint32.valueOf(0L));
+        data.setDatapathId(Uint64.valueOf(BigInteger.ONE));
+        final BundleControlOnf converted = converter.convert(original, data);
         testConvert(original, converted, withProperty);
     }
 
index 688ea8544729330ab75cc03fb816beb8b1721a8c..d1c223a0813d04227ba72becf9f5e56be69964fa 100644 (file)
@@ -31,12 +31,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.on
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Simple bundle extension service.
  */
 public class SalBundleServiceImpl implements SalBundleService {
-
+    private static final Logger LOG = LoggerFactory.getLogger(SalBundleServiceImpl.class);
     private final SalExperimenterMessageService experimenterMessageService;
 
     public SalBundleServiceImpl(final SalExperimenterMessageService experimenterMessageService) {
@@ -46,6 +48,7 @@ public class SalBundleServiceImpl implements SalBundleService {
 
     @Override
     public ListenableFuture<RpcResult<ControlBundleOutput>> controlBundle(ControlBundleInput input) {
+        LOG.debug("Control message for device {} and bundle type {}", input.getNode(), input.getType());
         final SendExperimenterInputBuilder experimenterInputBuilder = new SendExperimenterInputBuilder();
         experimenterInputBuilder.setNode(input.getNode());
         experimenterInputBuilder.setExperimenterMessageOfChoice(
index a7564536b020d4c08aa98719697511920df85758..ba18b4b5107e4579badf36ba118f43f887ad2033 100644 (file)
@@ -30,10 +30,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SalExperimenterMessageServiceImpl extends AbstractSimpleService<SendExperimenterInput,
         SendExperimenterOutput> implements SalExperimenterMessageService {
-
+    private static final Logger LOG = LoggerFactory.getLogger(SalExperimenterMessageServiceImpl.class);
     private final ExtensionConverterProvider extensionConverterProvider;
 
     public SalExperimenterMessageServiceImpl(final RequestContextStack requestContextStack,
@@ -51,6 +53,8 @@ public class SalExperimenterMessageServiceImpl extends AbstractSimpleService<Sen
             ExtensionConvertorData> messageConverter = extensionConverterProvider.getMessageConverter(key);
 
         if (messageConverter == null) {
+            LOG.warn("Unable to find message converter for experimenter xid {} for device {}", xid,
+                    extractDatapathId(input.getNode()));
             throw new ServiceException(new ConverterNotFoundException(key.toString()));
         }
         final ExperimenterInputBuilder experimenterInputBld;
@@ -65,6 +69,8 @@ public class SalExperimenterMessageServiceImpl extends AbstractSimpleService<Sen
                     .setVersion(getVersion())
                     .setXid(xid.getValue());
         } catch (ConversionException e) {
+            LOG.warn("Error while building experimenter message with id {} and xid {} for device {}",
+                    messageConverter.getExperimenterId(), xid, extractDatapathId(input.getNode()), e);
             throw new ServiceException(e);
         }