1 package org.opendaylight.controller.md.frm.compatibility
3 import org.opendaylight.controller.forwardingrulesmanager.FlowConfig
4 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder
6 import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
7 import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.*
8 import static org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils.*
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow
12 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
14 import org.opendaylight.yangtools.yang.binding.Identifiable
16 class FlowConfigMapping {
18 static def toConfigurationFlow(FlowConfig sourceCfg) {
19 val source = flowAdded(sourceCfg.flow);
20 val it = new FlowBuilder();
21 instructions = source.instructions;
22 cookie = source.cookie;
23 hardTimeout = source.hardTimeout
24 idleTimeout = source.idleTimeout
27 key = new FlowKey(Long.parseLong(sourceCfg.name),node);
31 static def toFlowConfig(Flow sourceCfg) {
32 val it = new FlowConfig;
33 name = String.valueOf(sourceCfg.id);
34 node = sourceCfg.node.toADNode();
39 static def toFlowConfig(InstanceIdentifier<?> identifier) {
40 val it = new FlowConfig()
41 val FlowKey key = ((identifier.path.get(2) as IdentifiableItem<Flow,FlowKey>).key)
42 name = String.valueOf(key.id);
43 node = key.node.toADNode();
48 static def boolean isFlowPath(InstanceIdentifier<?> path) {
49 if(path.path.size < 2) return false;
50 if (path.path.get(2) instanceof IdentifiableItem<?,?>) {
51 val IdentifiableItem<?,? extends Identifiable<?>> item = path.path.get(2) as IdentifiableItem<?,? extends Identifiable<?>>;
52 val Identifiable<?> key = item.key;
53 if (key instanceof FlowKey) {