X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fcompatibility%2Fsal-compatibility%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcompatibility%2FToSalConversionsUtils.java;h=58cfb20650930f82f5768fa9f96bbcd1e287ad14;hp=e790c2c591a59d81c3f8068ee62eac36e5dea6f3;hb=c1362c86eb19e92e6c64d10099a45deb499c6db1;hpb=013138732400ae603193db8900371f1df79931a3 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 e790c2c591..58cfb20650 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 @@ -95,6 +95,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.inventory.rev130819.NodeConnectorId; @@ -131,7 +133,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()); @@ -146,16 +179,7 @@ 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( @@ -184,7 +208,8 @@ public class ToSalConversionsUtils { Uri nodeConnector = ((OutputActionCase) sourceAction).getOutputAction().getOutputNodeConnector(); if (nodeConnector != null) { //for (Uri uri : nodeConnectors) { - targetAction.add(new Output(fromNodeConnectorRef(nodeConnector, node))); + Uri fullNodeConnector = new Uri(node.getType()+":"+node.getID()+":"+nodeConnector.getValue()); + targetAction.add(new Output(fromNodeConnectorRef(fullNodeConnector, node))); //} } } else if (sourceAction instanceof PopMplsActionCase) { @@ -352,17 +377,24 @@ public class ToSalConversionsUtils { return null; } - private static NodeConnector fromNodeConnectorRef(Uri uri, Node node) { + /** + * @param openflow nodeConnector uri + * @param node + * @return assembled nodeConnector + */ + public static NodeConnector fromNodeConnectorRef(Uri uri, Node node) { NodeConnector nodeConnector = null; try { - nodeConnector = new NodeConnector(NodeMapping.MD_SAL_TYPE,node.getNodeIDString()+":"+uri.getValue(),node); + NodeConnectorId nodeConnectorId = new NodeConnectorId(uri.getValue()); + nodeConnector = NodeMapping.toADNodeConnector(nodeConnectorId, node); } catch (ConstructionException e) { - e.printStackTrace(); + LOG.warn("nodeConnector creation failed at node: {} with nodeConnectorUri: {}", + node, uri.getValue()); } 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()); @@ -398,13 +430,17 @@ public class ToSalConversionsUtils { if (vlanMatch != null) { VlanId vlanId = vlanMatch.getVlanId(); if (vlanId != null) { - org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanIdInner = vlanId - .getVlanId(); - if (vlanIdInner != null) { - Integer vlanValue = vlanIdInner.getValue(); - if (vlanValue != null) { - target.setField(DL_VLAN, vlanValue.shortValue()); + if (Boolean.TRUE.equals(vlanId.isVlanIdPresent())) { + org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId vlanIdInner = vlanId + .getVlanId(); + if (vlanIdInner != null) { + Integer vlanValue = vlanIdInner.getValue(); + if (vlanValue != null) { + target.setField(DL_VLAN, vlanValue.shortValue()); + } } + } else { + target.setField(DL_VLAN, MatchType.DL_VLAN_NONE); } } VlanPcp vlanPcp = vlanMatch.getVlanPcp();