2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.frm.compatibility
10 import org.opendaylight.controller.forwardingrulesmanager.FlowConfig
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowBuilder
13 import static extension org.opendaylight.controller.sal.compatibility.NodeMapping.*
14 import static org.opendaylight.controller.sal.compatibility.MDFlowMapping.*
15 import static org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils.*
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.FlowKey
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem
21 import org.opendaylight.yangtools.yang.binding.Identifiable
23 class FlowConfigMapping {
25 static def toConfigurationFlow(FlowConfig sourceCfg) {
26 val source = flowAdded(sourceCfg.flow);
27 val it = new FlowBuilder();
28 instructions = source.instructions;
29 cookie = source.cookie;
30 hardTimeout = source.hardTimeout
31 idleTimeout = source.idleTimeout
34 key = new FlowKey(Long.parseLong(sourceCfg.name),node);
38 static def toFlowConfig(Flow sourceCfg) {
39 val it = new FlowConfig;
40 name = String.valueOf(sourceCfg.id);
41 node = sourceCfg.node.toADNode();
46 static def toFlowConfig(InstanceIdentifier<?> identifier) {
47 val it = new FlowConfig()
48 val FlowKey key = ((identifier.path.get(2) as IdentifiableItem<Flow,FlowKey>).key)
49 name = String.valueOf(key.id);
50 node = key.node.toADNode();
55 static def boolean isFlowPath(InstanceIdentifier<?> path) {
56 if(path.path.size < 2) return false;
57 if (path.path.get(2) instanceof IdentifiableItem<?,?>) {
58 val IdentifiableItem<?,? extends Identifiable<?>> item = path.path.get(2) as IdentifiableItem<?,? extends Identifiable<?>>;
59 val Identifiable<?> key = item.key;
60 if (key instanceof FlowKey) {