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 flow = toFlow(sourceCfg);
33 val it = new FlowConfig;
34 name = String.valueOf(sourceCfg.id);
35 node = sourceCfg.node.toADNode();
40 static def toFlowConfig(InstanceIdentifier<?> identifier) {
41 val it = new FlowConfig()
42 val FlowKey key = ((identifier.path.get(2) as IdentifiableItem<Flow,FlowKey>).key)
43 name = String.valueOf(key.id);
44 node = key.node.toADNode();
49 static def boolean isFlowPath(InstanceIdentifier<?> path) {
50 if(path.path.size < 2) return false;
51 if (path.path.get(2) instanceof IdentifiableItem<?,?>) {
52 val IdentifiableItem<?,? extends Identifiable<?>> item = path.path.get(2) as IdentifiableItem<?,? extends Identifiable<?>>;
53 val Identifiable<?> key = item.key;
54 if (key instanceof FlowKey) {