Fixed EVC create
[unimgr.git] / impl / src / main / java / org / opendaylight / unimgr / command / UniUpdateCommand.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.List;
11 import java.util.Map;
12 import java.util.Map.Entry;
13
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public class UniUpdateCommand extends AbstractUpdateCommand {
23
24     private static final Logger LOG = LoggerFactory.getLogger(UniUpdateCommand.class);
25
26     public UniUpdateCommand(DataBroker dataBroker,
27             Map<InstanceIdentifier<?>, DataObject> changes) {
28         super.dataBroker = dataBroker;
29         super.changes = changes;
30     }
31
32     @Override
33     public void execute() {
34         for (Entry<InstanceIdentifier<?>, DataObject> created : changes
35                 .entrySet()) {
36             if (created.getValue() != null
37                     && created.getValue() instanceof OvsdbNodeAugmentation) {
38                 OvsdbNodeAugmentation ovsdbNodeAugmentation = (OvsdbNodeAugmentation) created
39                         .getValue();
40                 if (ovsdbNodeAugmentation != null) {
41                     LOG.trace("Received an OVSDB node create {}",
42                             ovsdbNodeAugmentation.getConnectionInfo()
43                                     .getRemoteIp().getIpv4Address().getValue());
44                     final List<ManagedNodeEntry> managedNodeEntries = ovsdbNodeAugmentation.getManagedNodeEntry();
45                     if (managedNodeEntries != null) {
46                         for (ManagedNodeEntry managedNodeEntry : managedNodeEntries) {
47                             LOG.trace("Received an update from an OVSDB node {}.", managedNodeEntry.getKey());
48                             // We received a node update from the southbound plugin
49                             // so we have to check if it belongs to the UNI
50                         }
51                     }
52                 }
53             }
54         }
55     }
56
57 }