From: Michal Rehak Date: Thu, 12 Jun 2014 15:02:39 +0000 (+0200) Subject: BUG-1167: missing Notification of FLOW_REMOVED X-Git-Tag: release/helium~640^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=726d96cbc166817eef463d528fe8018de1ab8f90 BUG-1167: missing Notification of FLOW_REMOVED - added propagation of switchFlowRemoved notification Change-Id: I9edf2ebe52fc919c0e986cbe4f58e80a352eda8b Signed-off-by: Michal Rehak --- diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java index e5a9d3e5db..ba7377e8ff 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/FlowProgrammerAdapter.java @@ -163,6 +163,7 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa @Override public void onFlowRemoved(final FlowRemoved notification) { + // notified upon remove flow rpc successfully invoked if (notification == null) { return; } @@ -190,7 +191,25 @@ public class FlowProgrammerAdapter implements IPluginInFlowProgrammerService, Sa @Override public void onSwitchFlowRemoved(final SwitchFlowRemoved notification) { - // FIXME: unfinished? + // notified upon remove flow message from device arrives + if (notification == null) { + return; + } + + final NodeRef node = notification.getNode(); + if (node == null) { + LOG.debug("Notification {} has not node, ignoring it", notification); + return; + } + + Node adNode; + try { + adNode = NodeMapping.toADNode(notification.getNode()); + } catch (ConstructionException e) { + LOG.warn("Failed to construct AD node for {}, ignoring notification", node, e); + return; + } + flowProgrammerPublisher.flowRemoved(adNode, ToSalConversionsUtils.toFlow(notification, adNode)); } @Override diff --git a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java index da3477ee45..764266140a 100644 --- a/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java +++ b/opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ToSalConversionsUtils.java @@ -94,6 +94,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.acti import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.Address; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv4; import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.GenericFlowAttributes; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction; import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType; @@ -125,7 +127,38 @@ public class ToSalConversionsUtils { public static Flow toFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source, Node node) { final Flow target = new Flow(); + genericFlowToAdFlow(source, target); + + target.setMatch(toMatch(source.getMatch())); + List actions = getAction(source); + if (actions != null) { + target.setActions(actionFrom(actions, node)); + } + + return target; + } + + /** + * @param source notification, missing instructions + * @param node corresponding node where the flow change occured + * @return ad-sal node, build from given data + */ + public static Flow toFlow(SwitchFlowRemoved source, Node node) { + final Flow target = new Flow(); + genericFlowToAdFlow(source, target); + + target.setMatch(toMatch(source.getMatch())); + + return target; + } + + /** + * @param source + * @param target + */ + private static void genericFlowToAdFlow(GenericFlowAttributes source, + final Flow target) { Integer hardTimeout = source.getHardTimeout(); if (hardTimeout != null) { target.setHardTimeout(hardTimeout.shortValue()); @@ -140,18 +173,9 @@ public class ToSalConversionsUtils { if (priority != null) { target.setPriority(priority.shortValue()); } - - target.setMatch(toMatch(source.getMatch())); - - List actions = getAction(source); - if (actions != null) { - target.setActions(actionFrom(actions, node)); - } - target.setId(source.getCookie().getValue().longValue()); - return target; } - + public static List getAction( org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source) { if (source.getInstructions() != null) { @@ -356,7 +380,7 @@ public class ToSalConversionsUtils { return nodeConnector; } - public static Match toMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match source) { + public static Match toMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match source) { Match target = new Match(); if (source != null) { fillFrom(target, source.getVlanMatch());