Integrate the new yang model with Network Topology augmentation
[unimgr.git] / impl / src / main / java / org / opendaylight / unimgr / command / EvcCreateCommand.java
1 /*
2  * Copyright (c) 2015 CableLabs 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.unimgr.command;
9
10 import java.util.Map;
11 import java.util.Map.Entry;
12
13 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentation;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 public class EvcCreateCommand extends AbstractCreateCommand {
21
22     private static final Logger LOG = LoggerFactory.getLogger(EvcCreateCommand.class);
23
24     public EvcCreateCommand(DataBroker dataBroker,
25             Map<InstanceIdentifier<?>, DataObject> changes) {
26         super.dataBroker = dataBroker;
27         super.changes = changes;
28     }
29
30     @Override
31     public void execute() {
32         for (Entry<InstanceIdentifier<?>, DataObject> created : changes
33                 .entrySet()) {
34             if (created.getValue() != null && created.getValue() instanceof EvcAugmentation) {
35 //                EvcAugmentation evc = (EvcAugmentation) created.getValue();
36 //                LOG.info("New EVC created with id {}.", evc.getEvcId());
37 //                if (evc.getUniDest() == null || evc.getUniDest().isEmpty()) {
38 //                    LOG.error("Destination UNI cannot be null.");
39 //                    break;
40 //                }
41 //                if (evc.getUniSource() == null || evc.getUniSource().isEmpty()) {
42 //                    LOG.error("Source UNI cannot be null.");
43 //                    break;
44 //                }
45 //                // Get the destination UNI
46 //                InstanceIdentifier<Node> destinationNodeIid = (InstanceIdentifier<Node>) evc.getUniDest().iterator()
47 //                        .next().getUni();
48 //                Uni destinationUni = UnimgrUtils.readNode(dataBroker, destinationNodeIid).get()
49 //                        .getAugmentation(UniAugmentation.class);
50 //                NodeId ovsdbDestinationNodeId = UnimgrMapper.createNodeId(destinationUni.getIpAddress());
51 //                // Get the source UNI
52 //                InstanceIdentifier<Node> sourceIid = (InstanceIdentifier<Node>) evc.getUniSource().iterator().next()
53 //                        .getUni();
54 //                Uni sourceUni = UnimgrUtils.readNode(dataBroker, sourceIid).get()
55 //                        .getAugmentation(UniAugmentation.class);
56 //                NodeId ovsdbSourceNodeId = UnimgrMapper.createNodeId(sourceUni.getIpAddress());
57 //
58 //                // Set source
59 //                Node sourceBr1 = UnimgrUtils.readNode(
60 //                        dataBroker,
61 //                        UnimgrMapper.getOvsdbBridgeNodeIID(ovsdbSourceNodeId,
62 //                                UnimgrConstants.DEFAULT_BRIDGE_NAME)).get();
63 //                UnimgrUtils.createTerminationPointNode(dataBroker,
64 //                        destinationUni, sourceBr1,
65 //                        UnimgrConstants.DEFAULT_BRIDGE_NAME,
66 //                        UnimgrConstants.DEFAULT_INTERNAL_IFACE, null);
67 //                Node sourceBr2 = UnimgrUtils.readNode(
68 //                        dataBroker,
69 //                        UnimgrMapper.getOvsdbBridgeNodeIID(ovsdbSourceNodeId,
70 //                                UnimgrConstants.DEFAULT_BRIDGE_NAME)).get();
71 //                UnimgrUtils.createGreTunnel(dataBroker, sourceUni,
72 //                        destinationUni, sourceBr2,
73 //                        UnimgrConstants.DEFAULT_BRIDGE_NAME, "gre0");
74 //
75 //                // Set destination
76 //                Node destinationBr1 = UnimgrUtils.readNode(
77 //                        dataBroker,
78 //                        UnimgrMapper.getOvsdbBridgeNodeIID(ovsdbDestinationNodeId,
79 //                                UnimgrConstants.DEFAULT_BRIDGE_NAME)).get();
80 //                UnimgrUtils.createTerminationPointNode(dataBroker,
81 //                        destinationUni, destinationBr1,
82 //                        UnimgrConstants.DEFAULT_BRIDGE_NAME,
83 //                        UnimgrConstants.DEFAULT_INTERNAL_IFACE, null);
84 //                Node destinationBr2 = UnimgrUtils.readNode(
85 //                        dataBroker,
86 //                        UnimgrMapper.getOvsdbBridgeNodeIID(ovsdbDestinationNodeId,
87 //                                UnimgrConstants.DEFAULT_BRIDGE_NAME)).get();
88 //                UnimgrUtils.createGreTunnel(dataBroker, destinationUni,
89 //                        sourceUni, destinationBr2,
90 //                        UnimgrConstants.DEFAULT_BRIDGE_NAME, "gre0");
91             }
92         }
93     }
94
95 }