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=da3477ee45329e57d6174c01b9d53de76b098c39;hp=46fd62f3f2790dbd7223b9cba53af42284c57ef1;hb=4f8e371e1b7f6a2aa31115407c3f37738030f4c5;hpb=4043d42c401e0ad6369c9ec35f2c926dcc18c80d 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 46fd62f3f2..da3477ee45 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 @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.compatibility; import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP; @@ -43,7 +50,8 @@ import org.opendaylight.controller.sal.action.SetVlanCfi; import org.opendaylight.controller.sal.action.SetVlanId; import org.opendaylight.controller.sal.action.SetVlanPcp; import org.opendaylight.controller.sal.action.SwPath; -import org.opendaylight.controller.sal.core.Capabilities; +import org.opendaylight.controller.sal.core.ConstructionException; +import org.opendaylight.controller.sal.core.Node; import org.opendaylight.controller.sal.core.NodeConnector; import org.opendaylight.controller.sal.flowprogrammer.Flow; import org.opendaylight.controller.sal.match.Match; @@ -86,7 +94,6 @@ 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.inventory.rev130819.FeatureCapability; 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; @@ -116,7 +123,7 @@ public class ToSalConversionsUtils { } - public static Flow toFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source) { + public static Flow toFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow source, Node node) { final Flow target = new Flow(); Integer hardTimeout = source.getHardTimeout(); @@ -138,10 +145,10 @@ public class ToSalConversionsUtils { List actions = getAction(source); if (actions != null) { - target.setActions(actionFrom(actions)); + target.setActions(actionFrom(actions, node)); } - target.setId(source.getCookie().longValue()); + target.setId(source.getCookie().getValue().longValue()); return target; } @@ -158,10 +165,10 @@ public class ToSalConversionsUtils { return Collections.emptyList(); } - public static List actionFrom(List actions) { + public static List actionFrom(List actions, Node node) { List targetAction = new ArrayList<>(); for (Action action : actions) { - org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action sourceAction = action + org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action sourceAction = action .getAction(); if (sourceAction instanceof ControllerActionCase) { @@ -171,7 +178,7 @@ public class ToSalConversionsUtils { Uri nodeConnector = ((OutputActionCase) sourceAction).getOutputAction().getOutputNodeConnector(); if (nodeConnector != null) { //for (Uri uri : nodeConnectors) { - targetAction.add(new Output(fromNodeConnectorRef(nodeConnector))); + targetAction.add(new Output(fromNodeConnectorRef(nodeConnector, node))); //} } } else if (sourceAction instanceof PopMplsActionCase) { @@ -339,9 +346,14 @@ public class ToSalConversionsUtils { return null; } - private static NodeConnector fromNodeConnectorRef(Uri uri) { - // TODO: Define mapping - return null; + private static NodeConnector fromNodeConnectorRef(Uri uri, Node node) { + NodeConnector nodeConnector = null; + try { + nodeConnector = new NodeConnector(NodeMapping.MD_SAL_TYPE,node.getNodeIDString()+":"+uri.getValue(),node); + } catch (ConstructionException e) { + e.printStackTrace(); + } + return nodeConnector; } public static Match toMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match source) { @@ -573,7 +585,7 @@ public class ToSalConversionsUtils { } return macAddress; } - + public static byte[] bytesFromDpid(long dpid) { byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };