Added Model-Driven Inventory Provider for Flow-Capable Node.
[controller.git] / opendaylight / md-sal / inventory-manager / src / main / java / org / opendaylight / controller / md / inventory / manager / InventoryMapping.xtend
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  * 
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
7  */
8 package org.opendaylight.controller.md.inventory.manager
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorUpdated
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNodeConnector
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowNode
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder
17
18 class InventoryMapping {
19
20     static def FlowCapableNodeConnector toInventoryAugment(FlowNodeConnector updated) {
21         if (updated instanceof FlowCapableNodeConnector) {
22             return updated as FlowCapableNodeConnector;
23         }
24         val it = new FlowCapableNodeConnectorBuilder();
25         advertisedFeatures = updated.advertisedFeatures
26         configuration = updated.configuration
27         currentFeature = updated.currentFeature
28         currentSpeed = updated.currentSpeed
29         hardwareAddress = updated.hardwareAddress
30         maximumSpeed = updated.maximumSpeed
31         name = updated.name
32         peerFeatures = updated.peerFeatures
33         portNumber = updated.portNumber
34         state = updated.state
35         supported = updated.supported
36         return build();
37     }
38
39     static def FlowCapableNode toInventoryAugment(FlowNode source) {
40         if (source instanceof FlowCapableNode) {
41             return source as FlowCapableNode;
42         }
43         val it = new FlowCapableNodeBuilder(source);
44         return build();
45     }
46
47 }