Code Review
/
controller.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Bug 499: Initial implementation of data tree modifications
[controller.git]
/
opendaylight
/
md-sal
/
compatibility
/
sal-compatibility
/
src
/
main
/
java
/
org
/
opendaylight
/
controller
/
sal
/
compatibility
/
ToSalConversionsUtils.java
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 37bb2778584dc6deb08add85d63eee4ca9489acd..cb7289685831b75d275335c1aa6c9b2c44bc4532 100644
(file)
--- 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;
package org.opendaylight.controller.sal.compatibility;
import static org.opendaylight.controller.sal.compatibility.ProtocolConstants.CRUDP;
@@
-43,6
+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.action.SetVlanId;
import org.opendaylight.controller.sal.action.SetVlanPcp;
import org.opendaylight.controller.sal.action.SwPath;
+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;
import org.opendaylight.controller.sal.core.NodeConnector;
import org.opendaylight.controller.sal.flowprogrammer.Flow;
import org.opendaylight.controller.sal.match.Match;
@@
-114,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();
final Flow target = new Flow();
Integer hardTimeout = source.getHardTimeout();
@@
-136,7
+145,7
@@
public class ToSalConversionsUtils {
List<Action> actions = getAction(source);
if (actions != null) {
List<Action> actions = getAction(source);
if (actions != null) {
- target.setActions(actionFrom(actions));
+ target.setActions(actionFrom(actions
, node
));
}
target.setId(source.getCookie().longValue());
}
target.setId(source.getCookie().longValue());
@@
-156,7
+165,7
@@
public class ToSalConversionsUtils {
return Collections.emptyList();
}
return Collections.emptyList();
}
- public static List<org.opendaylight.controller.sal.action.Action> actionFrom(List<Action> actions) {
+ public static List<org.opendaylight.controller.sal.action.Action> actionFrom(List<Action> actions
, Node node
) {
List<org.opendaylight.controller.sal.action.Action> targetAction = new ArrayList<>();
for (Action action : actions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action sourceAction = action
List<org.opendaylight.controller.sal.action.Action> targetAction = new ArrayList<>();
for (Action action : actions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action sourceAction = action
@@
-169,7
+178,7
@@
public class ToSalConversionsUtils {
Uri nodeConnector = ((OutputActionCase) sourceAction).getOutputAction().getOutputNodeConnector();
if (nodeConnector != null) {
//for (Uri uri : nodeConnectors) {
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) {
//}
}
} else if (sourceAction instanceof PopMplsActionCase) {
@@
-337,9
+346,14
@@
public class ToSalConversionsUtils {
return null;
}
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) {
}
public static Match toMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match source) {
@@
-563,7
+577,7
@@
public class ToSalConversionsUtils {
}
}
}
}
- p
rivate
static byte[] bytesFrom(MacAddress address) {
+ p
ublic
static byte[] bytesFrom(MacAddress address) {
String[] mac = address.getValue().split(":");
byte[] macAddress = new byte[6]; // mac.length == 6 bytes
for (int i = 0; i < mac.length; i++) {
String[] mac = address.getValue().split(":");
byte[] macAddress = new byte[6]; // mac.length == 6 bytes
for (int i = 0; i < mac.length; i++) {
@@
-571,4
+585,15
@@
public class ToSalConversionsUtils {
}
return macAddress;
}
}
return macAddress;
}
+
+ public static byte[] bytesFromDpid(long dpid) {
+ byte[] mac = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+ for (short i = 0; i < 6; i++) {
+ mac[5 - i] = (byte) dpid;
+ dpid >>= 8;
+ }
+
+ return mac;
+ }
}
}