2 * Copyright (c) 2015 CableLabs 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.unimgr.command;
11 import java.util.Map.Entry;
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;
20 public class EvcCreateCommand extends AbstractCreateCommand {
22 private static final Logger LOG = LoggerFactory.getLogger(EvcCreateCommand.class);
24 public EvcCreateCommand(DataBroker dataBroker,
25 Map<InstanceIdentifier<?>, DataObject> changes) {
26 super.dataBroker = dataBroker;
27 super.changes = changes;
31 public void execute() {
32 for (Entry<InstanceIdentifier<?>, DataObject> created : changes
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.");
41 // if (evc.getUniSource() == null || evc.getUniSource().isEmpty()) {
42 // LOG.error("Source UNI cannot be null.");
45 // // Get the destination UNI
46 // InstanceIdentifier<Node> destinationNodeIid = (InstanceIdentifier<Node>) evc.getUniDest().iterator()
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()
54 // Uni sourceUni = UnimgrUtils.readNode(dataBroker, sourceIid).get()
55 // .getAugmentation(UniAugmentation.class);
56 // NodeId ovsdbSourceNodeId = UnimgrMapper.createNodeId(sourceUni.getIpAddress());
59 // Node sourceBr1 = UnimgrUtils.readNode(
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(
69 // UnimgrMapper.getOvsdbBridgeNodeIID(ovsdbSourceNodeId,
70 // UnimgrConstants.DEFAULT_BRIDGE_NAME)).get();
71 // UnimgrUtils.createGreTunnel(dataBroker, sourceUni,
72 // destinationUni, sourceBr2,
73 // UnimgrConstants.DEFAULT_BRIDGE_NAME, "gre0");
76 // Node destinationBr1 = UnimgrUtils.readNode(
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(
86 // UnimgrMapper.getOvsdbBridgeNodeIID(ovsdbDestinationNodeId,
87 // UnimgrConstants.DEFAULT_BRIDGE_NAME)).get();
88 // UnimgrUtils.createGreTunnel(dataBroker, destinationUni,
89 // sourceUni, destinationBr2,
90 // UnimgrConstants.DEFAULT_BRIDGE_NAME, "gre0");