Update UNI 31/33931/1
authorJohann David <jdavid@inocybe.com>
Wed, 27 Jan 2016 14:29:53 +0000 (09:29 -0500)
committerAlexis de Talhouët <adetalhouet@inocybe.com>
Tue, 2 Feb 2016 22:31:09 +0000 (22:31 +0000)
Change-Id: I8aeeae26e0eac60328eb035863a4e74d1a43f709
Signed-off-by: Johann David <jdavid@inocybe.com>
(cherry picked from commit 7f2d29ec585c95911ea67ceaefbe432659ce1fef)

cli/src/main/java/org/opendaylight/unimgr/cli/UniUpdateShellCommand.java [new file with mode: 0644]
cli/src/main/resources/OSGI-INF/blueprint/commands.xml
cli/src/test/java/org/opendaylight/unimgr/cli/UnimgrConsoleProviderTest.java
impl/src/main/java/org/opendaylight/unimgr/api/IUnimgrConsoleProvider.java
impl/src/main/java/org/opendaylight/unimgr/command/UniCreateCommand.java
impl/src/main/java/org/opendaylight/unimgr/command/UniUpdateCommand.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrProvider.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java
impl/src/test/java/org/opendaylight/unimgr/impl/UnimgrProviderTest.java

diff --git a/cli/src/main/java/org/opendaylight/unimgr/cli/UniUpdateShellCommand.java b/cli/src/main/java/org/opendaylight/unimgr/cli/UniUpdateShellCommand.java
new file mode 100644 (file)
index 0000000..4618080
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2016 CableLabs and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.unimgr.cli;
+
+import java.math.BigInteger;
+
+import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.console.OsgiCommandSupport;
+import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed100MBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed10GBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed10MBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.service.speed.speed.Speed1GBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.uni.Speed;
+
+@Command(name = "uni-update",
+scope = "uni",
+description = "Updates an uni to the controller.")
+public class UniUpdateShellCommand extends OsgiCommandSupport{
+    protected IUnimgrConsoleProvider provider;
+
+    @Option(name = "-pm",
+            aliases = { "--physical-medium" },
+            description = "The physical medium.\n-pm / --physical-medium <physical-medium>",
+            required = false,
+            multiValued = false)
+    private final String physicalMedium = "UNI TypeFull Duplex 2 Physical Interface";
+
+    @Option(name = "-ma",
+            aliases = { "--mac-address" },
+            description = "The mac address.\n-ma / --mac-address <mac-address>",
+            required = true,
+            multiValued = false)
+    private final String macAddress = "any";
+
+    @Option(name = "-m",
+            aliases = { "--mode" },
+            description = "The mode.\n-m / --mode <mode>",
+            required = false,
+            multiValued = false)
+    private final String mode = "Full Duplex";
+
+    @Option(name = "-ml",
+            aliases = { "--mac-layer" },
+            description = "The mac layer.\n-ml / --mac-layer <mac-layer",
+            required = false,
+            multiValued = false)
+    private final String macLayer = "IEEE 802.3-2005";
+
+    @Option(name = "-t",
+            aliases = { "--type" },
+            description = "The type.\n-t / --type <type>",
+            required = false,
+            multiValued = false)
+    private final String type = "";
+
+    @Option(name = "-ms",
+            aliases = { "--mtu-size" },
+            description = "The mtu size.\n-ms / --mtu-size <mtu-size>",
+            required = false,
+            multiValued = false)
+    private final String mtuSize = "0";
+
+    @Option(name = "-s",
+            aliases = { "--speed" },
+            description = "Spped.\n-s / --speed 10M/100M/1G/10G",
+            required = false,
+            multiValued = true)
+    private final String speed = "";
+
+    @Option(name = "-ip",
+            aliases = { "--ipAddress" },
+            description = "IpAddress of the Uni",
+            required = true,
+            multiValued = false)
+    private final String ipAddress = "any";
+
+    public UniUpdateShellCommand(IUnimgrConsoleProvider provider) {
+        this.provider = provider;
+    }
+
+    private Object getSpeed() {
+        Object speedObject = null;
+        if (speed.equals("10M")) {
+            speedObject = new Speed10MBuilder().build();
+        }
+        else if (speed.equals("100M")) {
+            speedObject = new Speed100MBuilder().build();
+        }
+        else if (speed.equals("1G")) {
+            speedObject = new Speed1GBuilder().build();
+        }
+        else if (speed.equals("10G")) {
+            speedObject = new Speed10GBuilder().build();
+        }
+        return speedObject;
+    }
+
+    @Override
+    protected Object doExecute() throws Exception {
+        final UniAugmentation uniAug = new UniAugmentationBuilder()
+                .setMacAddress(new MacAddress(macAddress))
+                .setMacLayer(macLayer)
+                .setMode(mode)
+                .setMtuSize(BigInteger.valueOf(Long.valueOf(mtuSize)))
+                .setPhysicalMedium(physicalMedium)
+                .setSpeed((Speed) getSpeed())
+                .setType(type)
+                .setIpAddress(new IpAddress(ipAddress.toCharArray()))
+                .build();
+        if (provider.updateUni(uniAug)) {
+            return new String("Uni with ip " +ipAddress+" updated");
+        } else {
+            return new String("Error updating new Uni");
+        }
+    }
+}
\ No newline at end of file
index 69240c7072b8c79981ae99485ddabf0fd6a7a476..1f07d5c771d631a46ffbea3d4f456d1ad7d71563 100755 (executable)
                 <argument ref="unimgrConsoleProvider" />
             </action>
         </command>
+        <command>
+            <action class="org.opendaylight.unimgr.cli.UniUpdateShellCommand">
+                 <argument ref="unimgrConsoleProvider" />
+            </action>
+        </command>
         <command>
             <action class="org.opendaylight.unimgr.cli.UniRemoveShellCommand">
                  <argument ref="unimgrConsoleProvider" />
index 0584b57d34fb118794cff28a4e15e855d6d86340..00b9ad186c7b51da52364b2b4c56bc6dea9b9b14 100644 (file)
@@ -20,6 +20,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Evc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSource;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public class UnimgrConsoleProviderTest implements IUnimgrConsoleProvider {
 
@@ -79,4 +83,17 @@ public class UnimgrConsoleProviderTest implements IUnimgrConsoleProvider {
     @Override
     public void close() throws Exception { }
 
+    @Override
+    public boolean updateUni(UniAugmentation uni) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean updateEvc(InstanceIdentifier<Link> evcKey, EvcAugmentation evc, UniSource uniSource,
+            UniDest uniDest) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
 }
index 5357638a6e822debfac6e93b5a2fa3be372ccd5a..76fe647127d85a5706d15ff59efc666385a8c8f7 100755 (executable)
@@ -14,11 +14,17 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Evc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSource;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
 public interface IUnimgrConsoleProvider extends AutoCloseable {
 
     boolean addUni(UniAugmentation uni);
 
+    boolean updateUni(UniAugmentation uni);
+
     boolean removeUni(IpAddress ipAddress);
 
     List<UniAugmentation> listUnis(LogicalDatastoreType dataStoreType);
@@ -30,4 +36,6 @@ public interface IUnimgrConsoleProvider extends AutoCloseable {
     boolean addEvc(EvcAugmentation evc);
 
     Evc getEvc(String uuid);
+
+    boolean updateEvc(InstanceIdentifier<Link> evcKey, EvcAugmentation evc, UniSource uniSource, UniDest uniDest);
 }
index a81724e9886c21f8ca2451444f3b9ed85463193b..da7fedea6d1baf309b2b45474617597598d7067e 100644 (file)
@@ -39,10 +39,10 @@ public class UniCreateCommand extends AbstractCreateCommand {
 
     @Override
     public void execute() {
-        for (Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
+        for (final Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
             if (created.getValue() != null && created.getValue() instanceof UniAugmentation) {
-                UniAugmentation uni = (UniAugmentation) created.getValue();
-                InstanceIdentifier<?> uniKey = created.getKey();
+                final UniAugmentation uni = (UniAugmentation) created.getValue();
+                final InstanceIdentifier<?> uniKey = created.getKey();
                 LOG.trace("New UNI created {}.", uni.getIpAddress().getIpv4Address());
                 /* We assume that when the user specifies the
                  * ovsdb-node-ref that the node already exists in
@@ -59,14 +59,14 @@ public class UniCreateCommand extends AbstractCreateCommand {
                  *
                  */
                 if (uni.getOvsdbNodeRef() != null) {
-                    OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef();
-                    Optional<Node> optionalNode = UnimgrUtils.readNode(dataBroker,
+                    final OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef();
+                    final Optional<Node> optionalNode = UnimgrUtils.readNode(dataBroker,
                                                                        LogicalDatastoreType.OPERATIONAL,
                                                                        ovsdbNodeRef.getValue());
                     if (!optionalNode.isPresent()) {
                         LOG.info("Invalid OVSDB node instance identifier specified, "
                                + "attempting to retrieve the node.");
-                        Optional<Node> optionalOvsdbNode = UnimgrUtils.findOvsdbNode(dataBroker,
+                        final Optional<Node> optionalOvsdbNode = UnimgrUtils.findOvsdbNode(dataBroker,
                                                                                      uni);
                         Node ovsdbNode;
                         if (optionalOvsdbNode.isPresent()) {
@@ -96,12 +96,12 @@ public class UniCreateCommand extends AbstractCreateCommand {
                 } else {
                     // We assume the ovs is in passive mode
                     // Check if the ovsdb node exist
-                    Optional<Node> optionalOvsdbNode = UnimgrUtils.findOvsdbNode(dataBroker,
+                    final Optional<Node> optionalOvsdbNode = UnimgrUtils.findOvsdbNode(dataBroker,
                                                                                  uni);
                     Node ovsdbNode;
                     if (optionalOvsdbNode.isPresent()) {
                         ovsdbNode = optionalOvsdbNode.get();
-                        InstanceIdentifier<Node> ovsdbIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNode.getNodeId());
+                        final InstanceIdentifier<Node> ovsdbIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNode.getNodeId());
                         LOG.info("Retrieved the OVSDB node");
                         // Update QoS entries to ovsdb if speed is configured to UNI node
                         if (uni.getSpeed() != null) {
@@ -133,31 +133,31 @@ public class UniCreateCommand extends AbstractCreateCommand {
                 }
             }
             if (created.getValue() != null && created.getValue() instanceof OvsdbNodeAugmentation) {
-                OvsdbNodeAugmentation ovsdbNodeAugmentation = (OvsdbNodeAugmentation) created
+                final OvsdbNodeAugmentation ovsdbNodeAugmentation = (OvsdbNodeAugmentation) created
                                                                                           .getValue();
-                InstanceIdentifier<Node> ovsdbIid = created.getKey().firstIdentifierOf(Node.class);
+                final InstanceIdentifier<Node> ovsdbIid = created.getKey().firstIdentifierOf(Node.class);
                 if (ovsdbNodeAugmentation != null) {
                     LOG.info("Received an OVSDB node create {}",
                             ovsdbNodeAugmentation.getConnectionInfo()
                                                  .getRemoteIp()
                                                  .getIpv4Address()
                                                  .getValue());
-                    List<Node> uniNodes = UnimgrUtils.getUniNodes(dataBroker);
+                    final List<Node> uniNodes = UnimgrUtils.getUniNodes(dataBroker);
                     if (uniNodes != null && !uniNodes.isEmpty()) {
-                        for (Node uniNode: uniNodes) {
-                            UniAugmentation uniAugmentation = uniNode.getAugmentation(UniAugmentation.class);
+                        for (final Node uniNode: uniNodes) {
+                            final UniAugmentation uniAugmentation = uniNode.getAugmentation(UniAugmentation.class);
                             if (uniAugmentation.getOvsdbNodeRef() != null
                                     && uniAugmentation.getOvsdbNodeRef().getValue() != null) {
-                                InstanceIdentifier<Node> ovsdbNodeRefIid = uniAugmentation
+                                final InstanceIdentifier<Node> ovsdbNodeRefIid = uniAugmentation
                                                                             .getOvsdbNodeRef()
                                                                             .getValue()
                                                                             .firstIdentifierOf(Node.class);
                                 if (ovsdbNodeRefIid.equals(ovsdbIid)) {
-                                    Optional<Node> optionalOvsdbNode = UnimgrUtils.readNode(dataBroker,
+                                    final Optional<Node> optionalOvsdbNode = UnimgrUtils.readNode(dataBroker,
                                                                                             LogicalDatastoreType.OPERATIONAL,
                                                                                             ovsdbIid);
                                     if (optionalOvsdbNode.isPresent()) {
-                                        InstanceIdentifier<Node> uniIid =
+                                        final InstanceIdentifier<Node> uniIid =
                                                                     UnimgrMapper.getUniIid(dataBroker,
                                                                                            uniAugmentation.getIpAddress(),
                                                                                            LogicalDatastoreType.CONFIGURATION);
@@ -180,7 +180,7 @@ public class UniCreateCommand extends AbstractCreateCommand {
                                           .getConnectionInfo()
                                           .getRemoteIp()
                                           .equals(uniAugmentation.getIpAddress())) {
-                                InstanceIdentifier<Node> uniIid = UnimgrMapper.getUniIid(dataBroker,
+                                final InstanceIdentifier<Node> uniIid = UnimgrMapper.getUniIid(dataBroker,
                                                                                          uniAugmentation.getIpAddress(),
                                                                                          LogicalDatastoreType.CONFIGURATION);
                                 UnimgrUtils.createBridgeNode(dataBroker,
index 607625019b0ac767279445a7d2274bd540e146fa..c84744c8dc3fa1c9ed5d41d79cb578b20fc8e5c9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 CableLabs and others.  All rights reserved.
+ * Copyright (c) 2016 CableLabs and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,18 +7,24 @@
  */
 package org.opendaylight.unimgr.command;
 
-import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ManagedNodeEntry;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.unimgr.impl.UnimgrMapper;
+import org.opendaylight.unimgr.impl.UnimgrUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
 public class UniUpdateCommand extends AbstractUpdateCommand {
 
     private static final Logger LOG = LoggerFactory.getLogger(UniUpdateCommand.class);
@@ -31,27 +37,46 @@ public class UniUpdateCommand extends AbstractUpdateCommand {
 
     @Override
     public void execute() {
-        for (Entry<InstanceIdentifier<?>, DataObject> created : changes
-                .entrySet()) {
-            if (created.getValue() != null
-                    && created.getValue() instanceof OvsdbNodeAugmentation) {
-                OvsdbNodeAugmentation ovsdbNodeAugmentation = (OvsdbNodeAugmentation) created
-                        .getValue();
-                if (ovsdbNodeAugmentation != null) {
-                    LOG.trace("Received an OVSDB node create {}",
-                            ovsdbNodeAugmentation.getConnectionInfo()
-                                    .getRemoteIp().getIpv4Address().getValue());
-                    final List<ManagedNodeEntry> managedNodeEntries = ovsdbNodeAugmentation.getManagedNodeEntry();
-                    if (managedNodeEntries != null) {
-                        for (ManagedNodeEntry managedNodeEntry : managedNodeEntries) {
-                            LOG.trace("Received an update from an OVSDB node {}.", managedNodeEntry.getKey());
-                            // We received a node update from the southbound plugin
-                            // so we have to check if it belongs to the UNI
+        for (final Entry<InstanceIdentifier<?>, DataObject> updated : changes.entrySet()) {
+            if (updated.getValue() != null && updated.getValue() instanceof UniAugmentation) {
+                final UniAugmentation uni = (UniAugmentation) updated.getValue();
+                final InstanceIdentifier<?> uniIID = UnimgrMapper.getUniIid(dataBroker,
+                        uni.getIpAddress(), LogicalDatastoreType.OPERATIONAL);
+                final UniAugmentation uniAug = UnimgrUtils.getUni(dataBroker, LogicalDatastoreType.OPERATIONAL, uni.getIpAddress());
+                Preconditions.checkArgument(uniAug != null, "No UNI %s on OPERATION Topoligy",
+                        uni.getIpAddress().getIpv4Address().getValue());
+                Preconditions.checkArgument(uniAug.getIpAddress().getIpv4Address().getValue().equals(
+                        uni.getIpAddress().getIpv4Address().getValue()), "New IpAddress %s should be the same than %s",
+                        uniAug.getIpAddress().getIpv4Address().getValue(),
+                        uni.getIpAddress().getIpv4Address().getValue());
+                Node ovsdbNode;
+                if (uni.getOvsdbNodeRef() != null) {
+                    final OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef();
+                    final Optional<Node> ovsdbNodeIID = UnimgrUtils.readNode(dataBroker,
+                            LogicalDatastoreType.OPERATIONAL, ovsdbNodeRef.getValue());
+                    if(ovsdbNodeIID.isPresent()){
+                        ovsdbNode= ovsdbNodeIID.get();
+                    } else {
+                        final Optional<Node> optionalOvsdbNode = UnimgrUtils.findOvsdbNode(dataBroker, uni);
+                        if (optionalOvsdbNode.isPresent()) {
+                            ovsdbNode = optionalOvsdbNode.get();
+                        } else {
+                            ovsdbNode = UnimgrUtils.createOvsdbNode(dataBroker, uni);
                         }
                     }
+                    LOG.trace("UNI updated {}.", uni.getIpAddress().getIpv4Address());
+                } else {
+                    final Optional<Node> optionalOvsdbNode = UnimgrUtils.findOvsdbNode(dataBroker, uni);
+                    if (optionalOvsdbNode.isPresent()) {
+                        ovsdbNode = optionalOvsdbNode.get();
+                    } else {
+                        ovsdbNode = UnimgrUtils.createOvsdbNode(dataBroker, uni);
+                    }
                 }
+                UnimgrUtils.deleteNode(dataBroker, uniIID, LogicalDatastoreType.OPERATIONAL);
+                UnimgrUtils.updateUniNode(LogicalDatastoreType.OPERATIONAL, uniIID,
+                        uni, ovsdbNode, dataBroker);
             }
         }
     }
-
 }
index 155669e7931ff21e8f051e9b0ddcb190a74cf9eb..8e6415944ae69bd20863f2ef0a93022c9a734202 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 CableLabs and others.  All rights reserved.
+ * Copyright (c) 2016 CableLabs and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -19,16 +19,20 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
 import org.opendaylight.unimgr.command.TransactionInvoker;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Evc;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSource;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
@@ -62,7 +66,7 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
         invoker = new  TransactionInvoker();
 
         // Register the unimgr OSGi CLI
-        BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+        final BundleContext context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
         unimgrConsoleRegistration = context.registerService(IUnimgrConsoleProvider.class,
                                                             this,
                                                             null);
@@ -90,41 +94,41 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
 
     protected void initDatastore(final LogicalDatastoreType type,
                                  TopologyId topoId) {
-        InstanceIdentifier<Topology> path = InstanceIdentifier
+        final InstanceIdentifier<Topology> path = InstanceIdentifier
                                                 .create(NetworkTopology.class)
                                                 .child(Topology.class,
                                                         new TopologyKey(topoId));
         initializeTopology(type);
-        ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
-        CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = transaction.read(type,
+        final ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
+        final CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = transaction.read(type,
                                                                                            path);
         try {
             if (!unimgrTp.get().isPresent()) {
-                TopologyBuilder tpb = new TopologyBuilder();
+                final TopologyBuilder tpb = new TopologyBuilder();
                 tpb.setTopologyId(topoId);
                 transaction.put(type, path, tpb.build());
                 transaction.submit();
             } else {
                 transaction.cancel();
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.error("Error initializing unimgr topology", e);
         }
     }
 
     private void initializeTopology(LogicalDatastoreType type) {
-        ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
-        InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class);
-        CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path);
+        final ReadWriteTransaction transaction = dataBroker.newReadWriteTransaction();
+        final InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.create(NetworkTopology.class);
+        final CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = transaction.read(type,path);
         try {
             if (!topology.get().isPresent()) {
-                NetworkTopologyBuilder ntb = new NetworkTopologyBuilder();
+                final NetworkTopologyBuilder ntb = new NetworkTopologyBuilder();
                 transaction.put(type,path,ntb.build());
                 transaction.submit();
             } else {
                 transaction.cancel();
             }
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.error("Error initializing unimgr topology {}",e);
         }
     }
@@ -139,7 +143,7 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
 
     @Override
     public boolean removeUni(IpAddress ipAddress) {
-        InstanceIdentifier<Node> iidUni = UnimgrMapper.getUniIid(dataBroker, ipAddress, LogicalDatastoreType.CONFIGURATION);
+        final InstanceIdentifier<Node> iidUni = UnimgrMapper.getUniIid(dataBroker, ipAddress, LogicalDatastoreType.CONFIGURATION);
         if (iidUni == null)
             return false;
 
@@ -177,4 +181,38 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
         return null;
     }
 
+    @Override
+    public boolean updateEvc(InstanceIdentifier<Link> evcKey, EvcAugmentation evc, UniSource uniSource,
+            UniDest uniDest) {
+        final InstanceIdentifier<?> sourceUniIid = uniSource.getUni();
+        final InstanceIdentifier<?> destinationUniIid = uniDest.getUni();
+        return UnimgrUtils.updateEvcNode(LogicalDatastoreType.CONFIGURATION, evcKey, evc, sourceUniIid,
+                destinationUniIid, dataBroker);
+    }
+
+    @Override
+    public boolean updateUni(UniAugmentation uni) {
+        // Remove the old UNI with IpAdress and create a new one with updated informations
+        if (uni != null && uni.getOvsdbNodeRef() != null) {
+            LOG.trace("UNI updated {}.", uni.getIpAddress().getIpv4Address());
+            final InstanceIdentifier<?> uniIID = UnimgrMapper.getUniIid(dataBroker,
+                    uni.getIpAddress(), LogicalDatastoreType.OPERATIONAL);
+            Node ovsdbNode;
+            if (uni.getOvsdbNodeRef() != null) {
+                final OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef();
+                ovsdbNode= UnimgrUtils.readNode(dataBroker,
+                        LogicalDatastoreType.OPERATIONAL, ovsdbNodeRef.getValue()).get();
+
+                UnimgrUtils.updateUniNode(LogicalDatastoreType.OPERATIONAL, uniIID, uni, ovsdbNode, dataBroker);
+                LOG.trace("UNI updated {}.", uni.getIpAddress().getIpv4Address());
+            } else {
+                final Optional<Node> optionalOvsdbNode = UnimgrUtils.findOvsdbNode(dataBroker, uni);
+                ovsdbNode = optionalOvsdbNode.get();
+            }
+            UnimgrUtils.deleteNode(dataBroker, uniIID, LogicalDatastoreType.OPERATIONAL);
+            return UnimgrUtils.updateUniNode(LogicalDatastoreType.OPERATIONAL, uniIID,
+                    uni, ovsdbNode, dataBroker);
+        }
+        return false;
+    }
 }
index 9ef3737f2793eb1bce8c388bb35c3d47dab1d1e9..5b12c885c353838bfa163240834329871ad073ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 CableLabs and others.  All rights reserved.
+ * Copyright (c) 2016 CableLabs and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -122,22 +122,22 @@ public class UnimgrUtils {
                                         UniAugmentation uni,
                                         String bridgeName) {
         LOG.info("Creating a bridge on node {}", ovsdbNode.getNodeId().getValue());
-        InstanceIdentifier<Node> ovsdbNodeIid = uni.getOvsdbNodeRef().getValue().firstIdentifierOf(Node.class);
+        final InstanceIdentifier<Node> ovsdbNodeIid = uni.getOvsdbNodeRef().getValue().firstIdentifierOf(Node.class);
         if (ovsdbNodeIid != null) {
-            NodeBuilder bridgeNodeBuilder = new NodeBuilder();
-            InstanceIdentifier<Node> bridgeIid = UnimgrMapper.createOvsdbBridgeNodeIid(ovsdbNode,
+            final NodeBuilder bridgeNodeBuilder = new NodeBuilder();
+            final InstanceIdentifier<Node> bridgeIid = UnimgrMapper.createOvsdbBridgeNodeIid(ovsdbNode,
                                                                                        bridgeName);
-            NodeId bridgeNodeId = new NodeId(ovsdbNode.getNodeId()
+            final NodeId bridgeNodeId = new NodeId(ovsdbNode.getNodeId()
                                            + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX
                                            + bridgeName);
             bridgeNodeBuilder.setNodeId(bridgeNodeId);
-            OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
+            final OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
             ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridgeName));
             ovsdbBridgeAugmentationBuilder.setProtocolEntry(UnimgrUtils.createMdsalProtocols());
-            OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
+            final OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
             ovsdbBridgeAugmentationBuilder.setManagedBy(ovsdbNodeRef);
             bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class, ovsdbBridgeAugmentationBuilder.build());
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
             transaction.put(LogicalDatastoreType.CONFIGURATION, bridgeIid, bridgeNodeBuilder.build());
             transaction.submit();
         } else {
@@ -158,26 +158,26 @@ public class UnimgrUtils {
                                         String bridgeName) {
         LOG.info("Creating a bridge on node {}", ovsdbNodeIid);
         if (ovsdbNodeIid != null) {
-            NodeBuilder bridgeNodeBuilder = new NodeBuilder();
-            Optional<Node> optionalOvsdbNode = UnimgrUtils.readNode(dataBroker,
+            final NodeBuilder bridgeNodeBuilder = new NodeBuilder();
+            final Optional<Node> optionalOvsdbNode = UnimgrUtils.readNode(dataBroker,
                                                                     LogicalDatastoreType.OPERATIONAL,
                                                                     ovsdbNodeIid);
             if (optionalOvsdbNode.isPresent()) {
-                Node ovsdbNode = optionalOvsdbNode.get();
-                InstanceIdentifier<Node> bridgeIid = UnimgrMapper.createOvsdbBridgeNodeIid(ovsdbNode,
+                final Node ovsdbNode = optionalOvsdbNode.get();
+                final InstanceIdentifier<Node> bridgeIid = UnimgrMapper.createOvsdbBridgeNodeIid(ovsdbNode,
                                                                                            bridgeName);
-                NodeId bridgeNodeId = new NodeId(ovsdbNode.getNodeId().getValue()
+                final NodeId bridgeNodeId = new NodeId(ovsdbNode.getNodeId().getValue()
                                                + UnimgrConstants.DEFAULT_BRIDGE_NODE_ID_SUFFIX
                                                + bridgeName);
                 bridgeNodeBuilder.setNodeId(bridgeNodeId);
-                OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
+                final OvsdbBridgeAugmentationBuilder ovsdbBridgeAugmentationBuilder = new OvsdbBridgeAugmentationBuilder();
                 ovsdbBridgeAugmentationBuilder.setBridgeName(new OvsdbBridgeName(bridgeName));
                 ovsdbBridgeAugmentationBuilder.setProtocolEntry(UnimgrUtils.createMdsalProtocols());
-                OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
+                final OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
                 ovsdbBridgeAugmentationBuilder.setManagedBy(ovsdbNodeRef);
                 bridgeNodeBuilder.addAugmentation(OvsdbBridgeAugmentation.class,
                                                   ovsdbBridgeAugmentationBuilder.build());
-                WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+                final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
                 transaction.put(LogicalDatastoreType.CONFIGURATION,
                                 bridgeIid,
                                 bridgeNodeBuilder.build());
@@ -195,8 +195,8 @@ public class UnimgrUtils {
      * @return A List of Controller Entry to be used when adding controllers
      */
     public static List<ControllerEntry> createControllerEntries(String targetString) {
-        List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
-        ControllerEntryBuilder controllerEntryBuilder = new ControllerEntryBuilder();
+        final List<ControllerEntry> controllerEntries = new ArrayList<ControllerEntry>();
+        final ControllerEntryBuilder controllerEntryBuilder = new ControllerEntryBuilder();
         controllerEntryBuilder.setTarget(new Uri(targetString));
         controllerEntries.add(controllerEntryBuilder.build());
         return controllerEntries;
@@ -217,15 +217,15 @@ public class UnimgrUtils {
                                        Node bridgeNode,
                                        String bridgeName,
                                        String portName) {
-        InstanceIdentifier<TerminationPoint> tpIid =
+        final InstanceIdentifier<TerminationPoint> tpIid =
                                                  UnimgrMapper.getTerminationPointIid(bridgeNode,
                                                                                      portName);
-        OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder =
+        final OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder =
                                                      new OvsdbTerminationPointAugmentationBuilder();
         tpAugmentationBuilder.setName(portName);
-        ArrayList<Options> options = Lists.newArrayList();
-        OptionsKey optionKey = new OptionsKey("remote_ip");
-        Options destinationIp = new OptionsBuilder()
+        final ArrayList<Options> options = Lists.newArrayList();
+        final OptionsKey optionKey = new OptionsKey("remote_ip");
+        final Options destinationIp = new OptionsBuilder()
                                         .setOption(destination.getIpAddress().getIpv4Address().getValue())
                                         .setKey(optionKey).setValue(destination.getIpAddress().getIpv4Address().getValue())
                                         .build();
@@ -233,14 +233,14 @@ public class UnimgrUtils {
         tpAugmentationBuilder.setOptions(options);
         tpAugmentationBuilder.setInterfaceType(SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.get("gre"));
         if (source.getSpeed() != null) {
-            Uuid qosUuid = getQosUuid(dataBroker, source);
+            final Uuid qosUuid = getQosUuid(dataBroker, source);
             tpAugmentationBuilder.setQos(getQosUuid(dataBroker, source));
             LOG.info("Updating Qos {} to termination point {}", qosUuid , bridgeName);
         }
-        TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+        final TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
         tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
         tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class, tpAugmentationBuilder.build());
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.put(LogicalDatastoreType.CONFIGURATION,
                         tpIid,
                         tpBuilder.build());
@@ -252,8 +252,8 @@ public class UnimgrUtils {
      * @return A List of protocol entry
      */
     public static List<ProtocolEntry> createMdsalProtocols() {
-        List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
-        ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
+        final List<ProtocolEntry> protocolList = new ArrayList<ProtocolEntry>();
+        final ImmutableBiMap<String, Class<? extends OvsdbBridgeProtocolBase>> mapper =
                 SouthboundConstants.OVSDB_PROTOCOL_MAP.inverse();
         protocolList.add(new ProtocolEntryBuilder().
                 setProtocol((Class<? extends OvsdbBridgeProtocolBase>) mapper.get("OpenFlow13")).build());
@@ -267,10 +267,10 @@ public class UnimgrUtils {
      * @throws Exception if the Ovsdb Node Reference cannot be found.
      */
     public static OvsdbBridgeAugmentation createOvsdbBridgeAugmentation(Uni uni) throws Exception {
-        OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef();
+        final OvsdbNodeRef ovsdbNodeRef = uni.getOvsdbNodeRef();
         if (ovsdbNodeRef != null && ovsdbNodeRef.getValue() != null) {
-            UUID bridgeUuid = UUID.randomUUID();
-            OvsdbBridgeAugmentation ovsdbBridge = new OvsdbBridgeAugmentationBuilder()
+            final UUID bridgeUuid = UUID.randomUUID();
+            final OvsdbBridgeAugmentation ovsdbBridge = new OvsdbBridgeAugmentationBuilder()
                                                         .setBridgeName(
                                                                 new OvsdbBridgeName(UnimgrConstants.DEFAULT_BRIDGE_NAME))
                                                         .setManagedBy(ovsdbNodeRef)
@@ -292,21 +292,21 @@ public class UnimgrUtils {
     public static void createOvsdbNode(DataBroker dataBroker,
                                        NodeId ovsdbNodeId,
                                        Uni uni) {
-        InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(uni.getIpAddress());
+        final InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(uni.getIpAddress());
         try {
-            NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId);
-            Node nodeData = new NodeBuilder()
+            final NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId);
+            final Node nodeData = new NodeBuilder()
                                     .setNodeId(ovsdbNodeId)
                                     .setKey(ovsdbNodeKey)
                                     .addAugmentation(OvsdbNodeAugmentation.class,
                                                      UnimgrUtils.createOvsdbNodeAugmentation(uni))
                                     .build();
             // Submit the node to the datastore
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
             transaction.put(LogicalDatastoreType.CONFIGURATION, ovsdbNodeIid, nodeData);
             transaction.submit();
             LOG.info("Created and submitted a new OVSDB node {}", nodeData.getNodeId());
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.error("Exception while creating OvsdbNodeAugmentation, " + "Uni is null. Node Id: {}", ovsdbNodeId);
         }
     }
@@ -319,23 +319,23 @@ public class UnimgrUtils {
      */
     public static Node createOvsdbNode(DataBroker dataBroker,
                                        UniAugmentation uni) {
-        NodeId ovsdbNodeId = new NodeId(createOvsdbNodeId(uni.getIpAddress()));
+        final NodeId ovsdbNodeId = new NodeId(createOvsdbNodeId(uni.getIpAddress()));
         try {
-            InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNodeId);
-            NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId);
-            Node nodeData = new NodeBuilder()
+            final InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNodeId);
+            final NodeKey ovsdbNodeKey = new NodeKey(ovsdbNodeId);
+            final Node nodeData = new NodeBuilder()
                                     .setNodeId(ovsdbNodeId)
                                     .setKey(ovsdbNodeKey)
                                     .addAugmentation(OvsdbNodeAugmentation.class,
                                                      UnimgrUtils.createOvsdbNodeAugmentation(uni))
                                     .build();
             // Submit the node to the datastore
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
             transaction.put(LogicalDatastoreType.CONFIGURATION, ovsdbNodeIid, nodeData);
             transaction.submit();
             LOG.info("Created and submitted a new OVSDB node {}", nodeData.getNodeId());
             return nodeData;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.error("Exception while creating OvsdbNodeAugmentation, " + "Uni is null. Node Id: {}", ovsdbNodeId);
         }
         return null;
@@ -347,23 +347,22 @@ public class UnimgrUtils {
      * @return The built OsvdbNodeAugmentation
      */
     public static OvsdbNodeAugmentation createOvsdbNodeAugmentation(Uni uni) {
-        ConnectionInfo connectionInfos = new ConnectionInfoBuilder()
+        final ConnectionInfo connectionInfos = new ConnectionInfoBuilder()
                                                 .setRemoteIp(uni.getIpAddress())
                                                 .setRemotePort(new PortNumber(UnimgrConstants.OVSDB_PORT))
                                                 .build();
-        OvsdbNodeAugmentation ovsdbNode = new OvsdbNodeAugmentationBuilder()
-                                                .setConnectionInfo(connectionInfos)
-                                                .build();
+        final OvsdbNodeAugmentation ovsdbNode = new OvsdbNodeAugmentationBuilder()
+                                                .setConnectionInfo(connectionInfos).build();
         return ovsdbNode;
     }
 
     public static OvsdbNodeAugmentation createOvsdbNodeAugmentation(UniAugmentation uni,
             PortNumber remotePort) {
-        ConnectionInfo connectionInfos = new ConnectionInfoBuilder()
+        final ConnectionInfo connectionInfos = new ConnectionInfoBuilder()
                 .setRemoteIp(uni.getIpAddress())
                 .setRemotePort(remotePort)
                 .build();
-        OvsdbNodeAugmentation ovsdbNode = new OvsdbNodeAugmentationBuilder()
+        final OvsdbNodeAugmentation ovsdbNode = new OvsdbNodeAugmentationBuilder()
                 .setConnectionInfo(connectionInfos)
                 .setQosEntries(createQosEntries(uni))
                 .setQueues(createQueues(uni))
@@ -372,26 +371,26 @@ public class UnimgrUtils {
     }
 
     public static Node createQoSForOvsdbNode (DataBroker dataBroker, UniAugmentation uni) {
-        Optional<Node> optionalNode = findOvsdbNode(dataBroker, uni);
+        final Optional<Node> optionalNode = findOvsdbNode(dataBroker, uni);
         if (optionalNode.isPresent()) {
-            NodeId ovsdbNodeId = optionalNode.get().getNodeId();
-            InstanceIdentifier<OvsdbNodeAugmentation> ovsdbNodeAugmentationIid = UnimgrMapper
+            final NodeId ovsdbNodeId = optionalNode.get().getNodeId();
+            final InstanceIdentifier<OvsdbNodeAugmentation> ovsdbNodeAugmentationIid = UnimgrMapper
                     .getOvsdbNodeIid(ovsdbNodeId)
                     .augmentation(OvsdbNodeAugmentation.class);
-            OvsdbNodeAugmentation ovsdbNodeAugmentation = createOvsdbNodeAugmentation(uni,
+            final OvsdbNodeAugmentation ovsdbNodeAugmentation = createOvsdbNodeAugmentation(uni,
                     getRemotePort(dataBroker, uni));
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
             transaction.put(LogicalDatastoreType.CONFIGURATION, ovsdbNodeAugmentationIid, ovsdbNodeAugmentation, true);
-            CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+            final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
             try {
                 Thread.sleep(UnimgrConstants.OVSDB_UPDATE_TIMEOUT);
-            } catch (InterruptedException e) {
+            } catch (final InterruptedException e) {
                 LOG.warn("Interrupted while waiting after OVSDB node augmentation {} {}", ovsdbNodeId, e);
             }
             try {
                 future.checkedGet();
                 LOG.trace("Update qos and queues to ovsdb for node {} {}", ovsdbNodeId, ovsdbNodeAugmentationIid);
-            } catch (TransactionCommitFailedException e) {
+            } catch (final TransactionCommitFailedException e) {
                 LOG.warn("Failed to put {} ", ovsdbNodeAugmentationIid, e);
             }
             updateQosEntries(dataBroker, uni);
@@ -401,7 +400,7 @@ public class UnimgrUtils {
 
     private static PortNumber getRemotePort(DataBroker dataBroker, UniAugmentation uni) {
         PortNumber remotePort = null;
-        Optional<Node> optionalNode = findOvsdbNode(dataBroker, uni);
+        final Optional<Node> optionalNode = findOvsdbNode(dataBroker, uni);
 
         if (optionalNode.isPresent()) {
             remotePort = optionalNode.get()
@@ -413,7 +412,7 @@ public class UnimgrUtils {
 
     private static List<QosEntries> createQosEntries(Uni uni) {
         // Configure queue for best-effort dscp and max rate
-        List<QosOtherConfig> otherConfig = new ArrayList<>();
+        final List<QosOtherConfig> otherConfig = new ArrayList<>();
         QosOtherConfig qOtherConfig = new QosOtherConfigBuilder()
                 .setKey(new QosOtherConfigKey(UnimgrConstants.QOS_DSCP_ATTRIBUTE))
                 .setOtherConfigKey(UnimgrConstants.QOS_DSCP_ATTRIBUTE)
@@ -428,21 +427,21 @@ public class UnimgrUtils {
                 .build();
         otherConfig.add(qOtherConfig);
 
-        Uuid qosUuid = new Uuid(UUID.randomUUID().toString());
-        QosEntries qosEntry = new QosEntriesBuilder()
+        final Uuid qosUuid = new Uuid(UUID.randomUUID().toString());
+        final QosEntries qosEntry = new QosEntriesBuilder()
                 .setKey(new QosEntriesKey(new Uri(UnimgrConstants.QOS_PREFIX + qosUuid.getValue())))
                 .setQosId(new Uri(UnimgrConstants.QOS_PREFIX + qosUuid.getValue()))
                 .setQosOtherConfig(otherConfig)
                 .setQosType(SouthboundMapper.createQosType(SouthboundConstants.QOS_LINUX_HTB))
                 .build();
 
-        List<QosEntries> qosEntries = new ArrayList<>();
+        final List<QosEntries> qosEntries = new ArrayList<>();
         qosEntries.add(qosEntry);
         return qosEntries;
     }
 
     private static List<Queues> createQueues(Uni uni) {
-        List<QueuesOtherConfig> otherConfig = new ArrayList<>();
+        final List<QueuesOtherConfig> otherConfig = new ArrayList<>();
         QueuesOtherConfig queuesOtherConfig = new QueuesOtherConfigBuilder()
                 .setKey(new QueuesOtherConfigKey(UnimgrConstants.QOS_DSCP_ATTRIBUTE))
                 .setQueueOtherConfigKey(UnimgrConstants.QOS_DSCP_ATTRIBUTE)
@@ -458,15 +457,15 @@ public class UnimgrUtils {
         otherConfig.add(queuesOtherConfig);
 
         // Configure dscp value for best-effort
-        Uuid queueUuid = new Uuid(UUID.randomUUID().toString());
-        Queues queues = new QueuesBuilder()
+        final Uuid queueUuid = new Uuid(UUID.randomUUID().toString());
+        final Queues queues = new QueuesBuilder()
                 .setDscp(Short.parseShort(UnimgrConstants.QOS_DSCP_ATTRIBUTE_VALUE))
                 .setKey(new QueuesKey(new Uri(UnimgrConstants.QUEUE_PREFIX + queueUuid.getValue())))
                 .setQueueId(new Uri(UnimgrConstants.QUEUE_PREFIX + queueUuid.getValue()))
                 .setQueuesOtherConfig(otherConfig)
                 .build();
 
-        List<Queues> queuesList = new ArrayList<>();
+        final List<Queues> queuesList = new ArrayList<>();
         queuesList.add(queues);
         return queuesList;
     }
@@ -493,40 +492,40 @@ public class UnimgrUtils {
     }
 
     private static void updateQosEntries(DataBroker dataBroker, UniAugmentation uni) {
-        Optional<Node> optionalNode = findOvsdbNode(dataBroker, uni);
+        final Optional<Node> optionalNode = findOvsdbNode(dataBroker, uni);
         if (optionalNode.isPresent()) {
-            NodeId ovsdbNodeId = optionalNode.get().getNodeId();
-            Long queueNumber = 0L;
-            List<QosEntries> qosList = optionalNode.get()
+            final NodeId ovsdbNodeId = optionalNode.get().getNodeId();
+            final Long queueNumber = 0L;
+            final List<QosEntries> qosList = optionalNode.get()
                     .getAugmentation(OvsdbNodeAugmentation.class)
                     .getQosEntries();
             LOG.trace("QOS entries list {} for node {}", qosList, ovsdbNodeId);
             QosEntriesKey qosEntryKey = null;
-            for (QosEntries qosEntry : qosList) {
+            for (final QosEntries qosEntry : qosList) {
                 qosEntryKey = qosEntry.getKey();
             }
-            InstanceIdentifier<QueueList> queueIid = UnimgrMapper
+            final InstanceIdentifier<QueueList> queueIid = UnimgrMapper
                     .getOvsdbQueueListIid(ovsdbNodeId, qosEntryKey, queueNumber);
 
             Uuid queueUuid = null;
-            List<Queues> queuesList = optionalNode.get()
+            final List<Queues> queuesList = optionalNode.get()
                     .getAugmentation(OvsdbNodeAugmentation.class).getQueues();
-            for (Queues queue : queuesList) {
+            for (final Queues queue : queuesList) {
                 queueUuid = queue.getQueueUuid();
             }
-            QueueList queueList = new QueueListBuilder()
+            final QueueList queueList = new QueueListBuilder()
                     .setKey(new QueueListKey(queueNumber))
                     .setQueueNumber(queueNumber)
                     .setQueueUuid(queueUuid)
                     .build();
 
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
             transaction.put(LogicalDatastoreType.CONFIGURATION, queueIid, queueList, true);
-            CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+            final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
             try {
                 future.checkedGet();
                 LOG.info("Update qos-entries to ovsdb for node {} {}", ovsdbNodeId, queueIid);
-            } catch (TransactionCommitFailedException e) {
+            } catch (final TransactionCommitFailedException e) {
                 LOG.warn("Failed to put {} ", queueIid, e);
             }
         }
@@ -563,29 +562,29 @@ public class UnimgrUtils {
     private static void updateQosMaxRate(DataBroker dataBroker,
             Optional<Node> optionalOvsdbNode,
             EvcAugmentation evc) {
-        NodeId ovsdbNodeId = optionalOvsdbNode.get().getNodeId();
-        List<QosEntries> qosList = optionalOvsdbNode.get()
+        final NodeId ovsdbNodeId = optionalOvsdbNode.get().getNodeId();
+        final List<QosEntries> qosList = optionalOvsdbNode.get()
                 .getAugmentation(OvsdbNodeAugmentation.class)
                 .getQosEntries();
         LOG.trace("QOS entries list {} for node {}", qosList, ovsdbNodeId);
         QosEntriesKey qosEntryKey = null;
-        for (QosEntries qosEntry : qosList) {
+        for (final QosEntries qosEntry : qosList) {
             qosEntryKey = qosEntry.getKey();
         }
-        InstanceIdentifier<QosOtherConfig> qosOtherConfigIid = UnimgrMapper
+        final InstanceIdentifier<QosOtherConfig> qosOtherConfigIid = UnimgrMapper
                 .getQosOtherConfigIid(ovsdbNodeId, qosEntryKey);
-        QosOtherConfig qOtherConfig = new QosOtherConfigBuilder()
+        final QosOtherConfig qOtherConfig = new QosOtherConfigBuilder()
                 .setKey(new QosOtherConfigKey(UnimgrConstants.QOS_MAX_RATE))
                 .setOtherConfigKey(UnimgrConstants.QOS_MAX_RATE)
                 .setOtherConfigValue(getSpeed(evc.getIngressBw().getSpeed()))
                 .build();
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.put(LogicalDatastoreType.CONFIGURATION, qosOtherConfigIid, qOtherConfig, true);
-        CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+        final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
         try {
             future.checkedGet();
             LOG.info("Update qos-entries max-rate to ovsdb for node {} {}", ovsdbNodeId, qosOtherConfigIid);;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.warn("Failed to put {} ", qosOtherConfigIid, e);
         }
     }
@@ -593,28 +592,28 @@ public class UnimgrUtils {
     private static void updateQueuesMaxRate(DataBroker dataBroker,
             Optional<Node> optionalOvsdbNode,
             EvcAugmentation evc) {
-        NodeId ovsdbNodeId = optionalOvsdbNode.get().getNodeId();
-        List<Queues> queues = optionalOvsdbNode.get()
+        final NodeId ovsdbNodeId = optionalOvsdbNode.get().getNodeId();
+        final List<Queues> queues = optionalOvsdbNode.get()
                 .getAugmentation(OvsdbNodeAugmentation.class)
                 .getQueues();
         QueuesKey queuesKey = null;
-        for (Queues queue: queues) {
+        for (final Queues queue: queues) {
             queuesKey = queue.getKey();
         }
-        InstanceIdentifier<QueuesOtherConfig> queuesOtherConfigIid = UnimgrMapper
+        final InstanceIdentifier<QueuesOtherConfig> queuesOtherConfigIid = UnimgrMapper
                 .getQueuesOtherConfigIid(ovsdbNodeId, queuesKey);
-        QueuesOtherConfig queuesOtherConfig = new QueuesOtherConfigBuilder()
+        final QueuesOtherConfig queuesOtherConfig = new QueuesOtherConfigBuilder()
                 .setKey(new QueuesOtherConfigKey(UnimgrConstants.QOS_MAX_RATE))
                 .setQueueOtherConfigKey(UnimgrConstants.QOS_MAX_RATE)
                 .setQueueOtherConfigValue(getSpeed(evc.getIngressBw().getSpeed()))
                 .build();
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.put(LogicalDatastoreType.CONFIGURATION, queuesOtherConfigIid, queuesOtherConfig, true);
-        CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+        final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
         try {
             future.checkedGet();
             LOG.info("Update queues max-rate to ovsdb for node {} {}", ovsdbNodeId, queuesOtherConfigIid);;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.warn("Failed to put {} ", queuesOtherConfigIid, e);
         }
     }
@@ -625,7 +624,7 @@ public class UnimgrUtils {
      * @return A NodeId for a Specific Ovsdb Node Id
      */
     public static NodeId createOvsdbNodeId(IpAddress ipAddress) {
-        String nodeId = UnimgrConstants.OVSDB_PREFIX
+        final String nodeId = UnimgrConstants.OVSDB_PREFIX
                         + ipAddress.getIpv4Address().getValue().toString()
                         + ":"
                         + UnimgrConstants.OVSDB_PORT;
@@ -639,8 +638,8 @@ public class UnimgrUtils {
      */
     public static OvsdbTerminationPointAugmentation createOvsdbTerminationPointAugmentation(Uni uni) {
         // we will use nodeId to set interface port id
-        VlanId vlanID = new VlanId(1);
-        OvsdbTerminationPointAugmentation terminationPoint = new OvsdbTerminationPointAugmentationBuilder()
+        final VlanId vlanID = new VlanId(1);
+        final OvsdbTerminationPointAugmentation terminationPoint = new OvsdbTerminationPointAugmentationBuilder()
                                                                      .setName(UnimgrConstants.DEFAULT_INTERNAL_IFACE)
                                                                      .setVlanTag(vlanID)
                                                                      .setVlanMode(VlanMode.Access)
@@ -665,23 +664,23 @@ public class UnimgrUtils {
      * @return true if uni created
      */
     public static boolean createUniNode(DataBroker dataBroker, UniAugmentation uni) {
-        NodeId uniNodeId = new NodeId(createUniNodeId(uni.getIpAddress()));
+        final NodeId uniNodeId = new NodeId(createUniNodeId(uni.getIpAddress()));
         boolean result = false;
         try {
-            InstanceIdentifier<Node> uniNodeIid = UnimgrMapper.getUniNodeIid(uniNodeId);
-            NodeKey uniNodeKey = new NodeKey(uniNodeId);
-            Node nodeData = new NodeBuilder()
+            final InstanceIdentifier<Node> uniNodeIid = UnimgrMapper.getUniNodeIid(uniNodeId);
+            final NodeKey uniNodeKey = new NodeKey(uniNodeId);
+            final Node nodeData = new NodeBuilder()
                                     .setNodeId(uniNodeId)
                                     .setKey(uniNodeKey)
                                     .addAugmentation(UniAugmentation.class, uni)
                                     .build();
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
             transaction.put(LogicalDatastoreType.CONFIGURATION, uniNodeIid, nodeData);
-            CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+            final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
             future.checkedGet();
             result = true;
             LOG.info("Created and submitted a new Uni node {}", nodeData.getNodeId());
-        } catch (Exception e) {
+        } catch (final Exception e) {
             LOG.error("Exception while creating Uni Node" + "Uni Node Id: {}", uniNodeId);
         }
         return result;
@@ -712,20 +711,20 @@ public class UnimgrUtils {
                                                   String bridgeName,
                                                   String portName,
                                                   String type) {
-        InstanceIdentifier<TerminationPoint> tpIid = UnimgrMapper
+        final InstanceIdentifier<TerminationPoint> tpIid = UnimgrMapper
                                                         .getTerminationPointIid(bridgeNode,
                                                                                 portName);
-        OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder =
+        final OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder =
                                                      new OvsdbTerminationPointAugmentationBuilder();
         tpAugmentationBuilder.setName(portName);
         if (type != null) {
             tpAugmentationBuilder.setInterfaceType(SouthboundConstants.OVSDB_INTERFACE_TYPE_MAP.get(type));
         }
-        TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+        final TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
         tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
         tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class,
                                   tpAugmentationBuilder.build());
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.put(LogicalDatastoreType.CONFIGURATION,
                         tpIid,
                         tpBuilder.build());
@@ -745,23 +744,23 @@ public class UnimgrUtils {
                                                   Node bridgeNode,
                                                   String bridgeName,
                                                   String portName) {
-        InstanceIdentifier<TerminationPoint> tpIid = UnimgrMapper
+        final InstanceIdentifier<TerminationPoint> tpIid = UnimgrMapper
                                                         .getTerminationPointIid(bridgeNode,
                                                                                 portName);
-        OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder =
+        final OvsdbTerminationPointAugmentationBuilder tpAugmentationBuilder =
                                                      new OvsdbTerminationPointAugmentationBuilder();
         tpAugmentationBuilder.setName(portName);
         tpAugmentationBuilder.setInterfaceType(null);
         if (uni.getSpeed() != null) {
-            Uuid qosUuid = getQosUuid(dataBroker, uni);
+            final Uuid qosUuid = getQosUuid(dataBroker, uni);
             tpAugmentationBuilder.setQos(getQosUuid(dataBroker, uni));
             LOG.info("Updating Qos {} to termination point {}", qosUuid , bridgeName);
         }
-        TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+        final TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
         tpBuilder.setKey(InstanceIdentifier.keyOf(tpIid));
         tpBuilder.addAugmentation(OvsdbTerminationPointAugmentation.class,
                                   tpAugmentationBuilder.build());
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.put(LogicalDatastoreType.CONFIGURATION,
                         tpIid,
                         tpBuilder.build());
@@ -770,17 +769,17 @@ public class UnimgrUtils {
 
     private static Uuid getQosUuid(DataBroker dataBroker, Uni uni) {
         Uuid qosUuid = null;
-        Optional<Node> optionalNode = findUniNode(dataBroker, uni.getIpAddress());
+        final Optional<Node> optionalNode = findUniNode(dataBroker, uni.getIpAddress());
 
         if (optionalNode.isPresent()) {
-            UniAugmentation uniAugmentation = optionalNode.get()
+            final UniAugmentation uniAugmentation = optionalNode.get()
                     .getAugmentation(UniAugmentation.class);
-            Optional<Node> ovsdbNode = findOvsdbNode(dataBroker, uniAugmentation);
+            final Optional<Node> ovsdbNode = findOvsdbNode(dataBroker, uniAugmentation);
             if (ovsdbNode.isPresent()) {
-                List<QosEntries> qosEntries = ovsdbNode.get()
+                final List<QosEntries> qosEntries = ovsdbNode.get()
                         .getAugmentation(OvsdbNodeAugmentation.class)
                         .getQosEntries();
-                for (QosEntries qosEntry : qosEntries) {
+                for (final QosEntries qosEntry : qosEntries) {
                     qosUuid = qosEntry.getQosUuid();
                 }
             }
@@ -802,11 +801,11 @@ public class UnimgrUtils {
         boolean result = false;
         final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.delete(store, path);
-        CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+        final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
         try {
             future.checkedGet();
             result = true;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.warn("Failed to delete {} ", path, e);
         }
         return result;
@@ -814,33 +813,33 @@ public class UnimgrUtils {
 
     public static void deleteEvcData(DataBroker dataBroker, Optional<Node> optionalUni) {
         if (optionalUni.isPresent()) {
-            UniAugmentation uniAugmentation =
+            final UniAugmentation uniAugmentation =
                                 optionalUni
                                     .get()
                                     .getAugmentation(UniAugmentation.class);
-            InstanceIdentifier<Node> ovsdbNodeIid =
+            final InstanceIdentifier<Node> ovsdbNodeIid =
                                               uniAugmentation
                                              .getOvsdbNodeRef()
                                              .getValue()
                                              .firstIdentifierOf(Node.class);
-            Optional<Node> optionalOvsdNode =
+            final Optional<Node> optionalOvsdNode =
                     UnimgrUtils.readNode(dataBroker,
                                          LogicalDatastoreType.OPERATIONAL,
                                          ovsdbNodeIid);
             if (optionalOvsdNode.isPresent()) {
-                Node ovsdbNode = optionalOvsdNode.get();
-                OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
-                for (ManagedNodeEntry managedNodeEntry: ovsdbNodeAugmentation.getManagedNodeEntry()) {
-                    InstanceIdentifier<Node> bridgeIid = managedNodeEntry
+                final Node ovsdbNode = optionalOvsdNode.get();
+                final OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode.getAugmentation(OvsdbNodeAugmentation.class);
+                for (final ManagedNodeEntry managedNodeEntry: ovsdbNodeAugmentation.getManagedNodeEntry()) {
+                    final InstanceIdentifier<Node> bridgeIid = managedNodeEntry
                                                              .getBridgeRef()
                                                              .getValue()
                                                              .firstIdentifierOf(Node.class);
-                    Optional<Node> optBridgeNode = UnimgrUtils.readNode(dataBroker, bridgeIid);
+                    final Optional<Node> optBridgeNode = UnimgrUtils.readNode(dataBroker, bridgeIid);
                     if (optBridgeNode.isPresent()) {
-                        Node bridgeNode = optBridgeNode.get();
-                        InstanceIdentifier<TerminationPoint> iidGreTermPoint = UnimgrMapper.getTerminationPointIid(bridgeNode,
+                        final Node bridgeNode = optBridgeNode.get();
+                        final InstanceIdentifier<TerminationPoint> iidGreTermPoint = UnimgrMapper.getTerminationPointIid(bridgeNode,
                                                                                         UnimgrConstants.DEFAULT_GRE_TUNNEL_NAME);
-                        InstanceIdentifier<TerminationPoint> iidEthTermPoint = UnimgrMapper.getTerminationPointIid(bridgeNode,
+                        final InstanceIdentifier<TerminationPoint> iidEthTermPoint = UnimgrMapper.getTerminationPointIid(bridgeNode,
                                                                                         UnimgrConstants.DEFAULT_TUNNEL_IFACE);
                         UnimgrUtils.deleteNode(dataBroker, iidGreTermPoint, LogicalDatastoreType.CONFIGURATION);
                         UnimgrUtils.deleteNode(dataBroker, iidEthTermPoint, LogicalDatastoreType.CONFIGURATION);
@@ -864,7 +863,7 @@ public class UnimgrUtils {
                                 deleteTerminationPoint(DataBroker dataBroker,
                                                        TerminationPoint terminationPoint,
                                                        Node ovsdbNode) {
-        InstanceIdentifier<TerminationPoint> terminationPointPath =
+        final InstanceIdentifier<TerminationPoint> terminationPointPath =
                                                  InstanceIdentifier
                                                      .create(NetworkTopology.class)
                                                      .child(Topology.class,
@@ -877,7 +876,7 @@ public class UnimgrUtils {
         transaction.delete(LogicalDatastoreType.CONFIGURATION, terminationPointPath);
         transaction.delete(LogicalDatastoreType.OPERATIONAL, terminationPointPath);
         transaction.submit();
-        CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
+        final CheckedFuture<Void, TransactionCommitFailedException> future = transaction.submit();
         return future;
     }
 
@@ -892,12 +891,12 @@ public class UnimgrUtils {
                                   LogicalDatastoreType store) {
         LOG.info("Received a request to delete node {}", genericNode);
         boolean result = false;
-        WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.delete(store, genericNode);
         try {
             transaction.submit().checkedGet();
             result = true;
-        } catch (TransactionCommitFailedException e) {
+        } catch (final TransactionCommitFailedException e) {
             LOG.error("Unable to remove node with Iid {} from store {}.", genericNode, store);
         }
         return result;
@@ -911,15 +910,17 @@ public class UnimgrUtils {
      */
     public static <T extends DataObject> Map<InstanceIdentifier<T>,T> extract(
             Map<InstanceIdentifier<?>, DataObject> changes, Class<T> klazz) {
-        Map<InstanceIdentifier<T>,T> result = new HashMap<InstanceIdentifier<T>,T>();
+        final Map<InstanceIdentifier<T>,T> result = new HashMap<InstanceIdentifier<T>,T>();
         if (changes != null && changes.entrySet() != null) {
-            for (Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
+            for (final Entry<InstanceIdentifier<?>, DataObject> created : changes.entrySet()) {
                 if (klazz.isInstance(created.getValue())) {
                     @SuppressWarnings("unchecked")
+                    final
                     T value = (T) created.getValue();
-                    Class<?> type = created.getKey().getTargetType();
+                    final Class<?> type = created.getKey().getTargetType();
                     if (type.equals(klazz)) {
                         @SuppressWarnings("unchecked") // Actually checked above
+                        final
                         InstanceIdentifier<T> iid = (InstanceIdentifier<T>) created.getKey();
                         result.put(iid, value);
                     }
@@ -948,11 +949,12 @@ public class UnimgrUtils {
      */
     public static <T extends DataObject> Set<InstanceIdentifier<T>> extractRemoved(
             AsyncDataChangeEvent<InstanceIdentifier<?>,DataObject> changes,Class<T> klazz) {
-        Set<InstanceIdentifier<T>> result = new HashSet<InstanceIdentifier<T>>();
+        final Set<InstanceIdentifier<T>> result = new HashSet<InstanceIdentifier<T>>();
         if (changes != null && changes.getRemovedPaths() != null) {
-            for (InstanceIdentifier<?> iid : changes.getRemovedPaths()) {
+            for (final InstanceIdentifier<?> iid : changes.getRemovedPaths()) {
                 if (iid.getTargetType().equals(klazz)) {
                     @SuppressWarnings("unchecked") // Actually checked above
+                    final
                     InstanceIdentifier<T> iidn = (InstanceIdentifier<T>)iid;
                     result.add(iidn);
                 }
@@ -969,11 +971,11 @@ public class UnimgrUtils {
      */
     public static Optional<Node> findOvsdbNode(DataBroker dataBroker,
                                                UniAugmentation uni) {
-        List<Node> ovsdbNodes = getOvsdbNodes(dataBroker);
+        final List<Node> ovsdbNodes = getOvsdbNodes(dataBroker);
         Optional<Node> optionalOvsdb;
         if (!ovsdbNodes.isEmpty()) {
-            for (Node ovsdbNode : ovsdbNodes) {
-                OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode
+            for (final Node ovsdbNode : ovsdbNodes) {
+                final OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode
                                                                   .getAugmentation(OvsdbNodeAugmentation.class);
                 if (ovsdbNodeAugmentation.getConnectionInfo()
                                          .getRemoteIp()
@@ -996,10 +998,10 @@ public class UnimgrUtils {
      */
     public static Optional<Node> findUniNode(DataBroker dataBroker,
                                              IpAddress ipAddress) {
-        List<Node> uniNodes = getUniNodes(dataBroker);
+        final List<Node> uniNodes = getUniNodes(dataBroker);
         if (!uniNodes.isEmpty()) {
-            for (Node uniNode : uniNodes) {
-                UniAugmentation uniAugmentation = uniNode.getAugmentation(UniAugmentation.class);
+            for (final Node uniNode : uniNodes) {
+                final UniAugmentation uniAugmentation = uniNode.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation.getIpAddress().equals(ipAddress)) {
                     LOG.info("Found Uni node");
                     return Optional.of(uniNode);
@@ -1018,15 +1020,15 @@ public class UnimgrUtils {
      */
     public static ConnectionInfo getConnectionInfo(DataBroker dataBroker,
                                                    NodeId ovsdbNodeId) {
-        InstanceIdentifier<Node> nodeIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNodeId);
-        Optional<Node> node = readNode(dataBroker,
+        final InstanceIdentifier<Node> nodeIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNodeId);
+        final Optional<Node> node = readNode(dataBroker,
                                        LogicalDatastoreType.OPERATIONAL,
                                        nodeIid);
         if (node.isPresent()) {
-            Node ovsdbNode = node.get();
-            OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode
+            final Node ovsdbNode = node.get();
+            final OvsdbNodeAugmentation ovsdbNodeAugmentation = ovsdbNode
                                                               .getAugmentation(OvsdbNodeAugmentation.class);
-            ConnectionInfo connectionInfo = ovsdbNodeAugmentation.getConnectionInfo();
+            final ConnectionInfo connectionInfo = ovsdbNodeAugmentation.getConnectionInfo();
             return connectionInfo;
         } else {
             return null;
@@ -1039,14 +1041,14 @@ public class UnimgrUtils {
      * @return A list of Links retrieved from the Operational DataStore
      */
     public static List<Link> getEvcLinks(DataBroker dataBroker) {
-        List<Link> evcLinks = new ArrayList<>();
-        InstanceIdentifier<Topology> evcTopology = UnimgrMapper.getEvcTopologyIid();
-        Topology topology = UnimgrUtils.read(dataBroker,
+        final List<Link> evcLinks = new ArrayList<>();
+        final InstanceIdentifier<Topology> evcTopology = UnimgrMapper.getEvcTopologyIid();
+        final Topology topology = UnimgrUtils.read(dataBroker,
                                              LogicalDatastoreType.OPERATIONAL,
                                              evcTopology);
         if (topology != null && topology.getLink() != null) {
-            for (Link link : topology.getLink()) {
-                EvcAugmentation evcAugmentation = link.getAugmentation(EvcAugmentation.class);
+            for (final Link link : topology.getLink()) {
+                final EvcAugmentation evcAugmentation = link.getAugmentation(EvcAugmentation.class);
                 if (evcAugmentation != null) {
                     evcLinks.add(link);
                 }
@@ -1063,10 +1065,10 @@ public class UnimgrUtils {
         String ip;
         try {
             ip = InetAddress.getLocalHost().getHostAddress();
-            Ipv4Address ipv4 = new Ipv4Address(ip);
-            IpAddress ipAddress = new IpAddress(ipv4);
+            final Ipv4Address ipv4 = new Ipv4Address(ip);
+            final IpAddress ipAddress = new IpAddress(ipv4);
             return ipAddress;
-        } catch (UnknownHostException e) {
+        } catch (final UnknownHostException e) {
             LOG.info("Unable to retrieve controller's ip address, using loopback.");
         }
         return new IpAddress(UnimgrConstants.LOCAL_IP);
@@ -1078,14 +1080,14 @@ public class UnimgrUtils {
      * @return The Ovsdb Node retrieved from the Operational DataStore
      */
     public static List<Node> getOvsdbNodes(DataBroker dataBroker) {
-        List<Node> ovsdbNodes = new ArrayList<>();
-        InstanceIdentifier<Topology> ovsdbTopoIdentifier = UnimgrMapper.getOvsdbTopologyIid();
-        Topology topology = UnimgrUtils.read(dataBroker,
+        final List<Node> ovsdbNodes = new ArrayList<>();
+        final InstanceIdentifier<Topology> ovsdbTopoIdentifier = UnimgrMapper.getOvsdbTopologyIid();
+        final Topology topology = UnimgrUtils.read(dataBroker,
                                              LogicalDatastoreType.OPERATIONAL,
                                              ovsdbTopoIdentifier);
         if (topology != null && topology.getNode() != null) {
-            for (Node node : topology.getNode()) {
-                OvsdbNodeAugmentation ovsdbNodeAugmentation = node.getAugmentation(OvsdbNodeAugmentation.class);
+            for (final Node node : topology.getNode()) {
+                final OvsdbNodeAugmentation ovsdbNodeAugmentation = node.getAugmentation(OvsdbNodeAugmentation.class);
                 if (ovsdbNodeAugmentation != null) {
                     ovsdbNodes.add(node);
                 }
@@ -1100,14 +1102,14 @@ public class UnimgrUtils {
      * @return A list of Uni Nodes from the Config dataStore
      */
     public static List<Node> getUniNodes(DataBroker dataBroker) {
-        List<Node> uniNodes = new ArrayList<>();
-        InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
-        Topology topology = read(dataBroker,
+        final List<Node> uniNodes = new ArrayList<>();
+        final InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
+        final Topology topology = read(dataBroker,
                                  LogicalDatastoreType.CONFIGURATION,
                                  topologyInstanceIdentifier);
         if (topology != null && topology.getNode() != null) {
-            for (Node node : topology.getNode()) {
-                UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
+            for (final Node node : topology.getNode()) {
+                final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation != null) {
                     uniNodes.add(node);
                 }
@@ -1124,14 +1126,14 @@ public class UnimgrUtils {
      */
     public static List<Node> getUniNodes(DataBroker dataBroker,
                                          LogicalDatastoreType store) {
-        List<Node> uniNodes = new ArrayList<>();
-        InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
-        Topology topology = read(dataBroker,
+        final List<Node> uniNodes = new ArrayList<>();
+        final InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
+        final Topology topology = read(dataBroker,
                                  store,
                                  topologyInstanceIdentifier);
         if (topology != null && topology.getNode() != null) {
-            for (Node node : topology.getNode()) {
-                UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
+            for (final Node node : topology.getNode()) {
+                final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation != null) {
                     uniNodes.add(node);
                 }
@@ -1148,14 +1150,14 @@ public class UnimgrUtils {
      */
     public static List<UniAugmentation> getUnis(DataBroker dataBroker,
                                          LogicalDatastoreType store) {
-        List<UniAugmentation> unis = new ArrayList<>();
-        InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
-        Topology topology = read(dataBroker,
+        final List<UniAugmentation> unis = new ArrayList<>();
+        final InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
+        final Topology topology = read(dataBroker,
                                  store,
                                  topologyInstanceIdentifier);
         if (topology != null && topology.getNode() != null) {
-            for (Node node : topology.getNode()) {
-                UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
+            for (final Node node : topology.getNode()) {
+                final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation != null) {
                     unis.add(uniAugmentation);
                 }
@@ -1173,13 +1175,13 @@ public class UnimgrUtils {
      */
     public static UniAugmentation getUni(DataBroker dataBroker,
                                          LogicalDatastoreType store, IpAddress ipAddress) {
-        InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
-        Topology topology = read(dataBroker,
+        final InstanceIdentifier<Topology> topologyInstanceIdentifier = UnimgrMapper.getUniTopologyIid();
+        final Topology topology = read(dataBroker,
                                  store,
                                  topologyInstanceIdentifier);
         if (topology != null && topology.getNode() != null) {
-            for (Node node : topology.getNode()) {
-                UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
+            for (final Node node : topology.getNode()) {
+                final UniAugmentation uniAugmentation = node.getAugmentation(UniAugmentation.class);
                 if (uniAugmentation != null && uniAugmentation.getIpAddress().getIpv4Address().getValue().equals(ipAddress.getIpv4Address().getValue())) {
                     return uniAugmentation;
                 }
@@ -1203,7 +1205,7 @@ public class UnimgrUtils {
         D result = null;
         final ReadOnlyTransaction transaction = dataBroker.newReadOnlyTransaction();
         Optional<D> optionalDataObject;
-        CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
+        final CheckedFuture<Optional<D>, ReadFailedException> future = transaction.read(store, path);
         try {
             optionalDataObject = future.checkedGet();
             if (optionalDataObject.isPresent()) {
@@ -1212,7 +1214,7 @@ public class UnimgrUtils {
                 LOG.debug("{}: Failed to read {}",
                         Thread.currentThread().getStackTrace()[1], path);
             }
-        } catch (ReadFailedException e) {
+        } catch (final ReadFailedException e) {
             LOG.warn("Failed to read {} ", path, e);
         }
         transaction.close();
@@ -1228,14 +1230,14 @@ public class UnimgrUtils {
     @Deprecated
     public static final Optional<Node> readNode(DataBroker dataBroker,
                                                 InstanceIdentifier<?> genericNode) {
-        ReadTransaction read = dataBroker.newReadOnlyTransaction();
-        InstanceIdentifier<Node> nodeIid = genericNode.firstIdentifierOf(Node.class);
-        CheckedFuture<Optional<Node>, ReadFailedException> nodeFuture =
+        final ReadTransaction read = dataBroker.newReadOnlyTransaction();
+        final InstanceIdentifier<Node> nodeIid = genericNode.firstIdentifierOf(Node.class);
+        final CheckedFuture<Optional<Node>, ReadFailedException> nodeFuture =
                                                               read.read(LogicalDatastoreType.OPERATIONAL,
                                                                         nodeIid);
         try {
             return nodeFuture.checkedGet();
-        } catch (ReadFailedException e) {
+        } catch (final ReadFailedException e) {
             LOG.info("Unable to read node with Iid {}", nodeIid);
         }
         return Optional.absent();
@@ -1251,12 +1253,12 @@ public class UnimgrUtils {
     public static final Optional<Link> readLink(DataBroker dataBroker,
                                                 LogicalDatastoreType store,
                                                 InstanceIdentifier<?> genericNode) {
-        ReadTransaction read = dataBroker.newReadOnlyTransaction();
-        InstanceIdentifier<Link> linkIid = genericNode.firstIdentifierOf(Link.class);
-        CheckedFuture<Optional<Link>, ReadFailedException> linkFuture = read.read(store, linkIid);
+        final ReadTransaction read = dataBroker.newReadOnlyTransaction();
+        final InstanceIdentifier<Link> linkIid = genericNode.firstIdentifierOf(Link.class);
+        final CheckedFuture<Optional<Link>, ReadFailedException> linkFuture = read.read(store, linkIid);
         try {
             return linkFuture.checkedGet();
-        } catch (ReadFailedException e) {
+        } catch (final ReadFailedException e) {
             LOG.info("Unable to read node with Iid {}", linkIid);
         }
         return Optional.absent();
@@ -1272,13 +1274,13 @@ public class UnimgrUtils {
     public static final Optional<Node> readNode(DataBroker dataBroker,
                                                 LogicalDatastoreType store,
                                                 InstanceIdentifier<?> genericNode) {
-        ReadTransaction read = dataBroker.newReadOnlyTransaction();
-        InstanceIdentifier<Node> nodeIid = genericNode.firstIdentifierOf(Node.class);
-        CheckedFuture<Optional<Node>, ReadFailedException> nodeFuture = read
+        final ReadTransaction read = dataBroker.newReadOnlyTransaction();
+        final InstanceIdentifier<Node> nodeIid = genericNode.firstIdentifierOf(Node.class);
+        final CheckedFuture<Optional<Node>, ReadFailedException> nodeFuture = read
                 .read(store, nodeIid);
         try {
             return nodeFuture.checkedGet();
-        } catch (ReadFailedException e) {
+        } catch (final ReadFailedException e) {
             LOG.info("Unable to read node with Iid {}", nodeIid);
         }
         return Optional.absent();
@@ -1287,35 +1289,38 @@ public class UnimgrUtils {
     /**
      * Updates a specific Uni Node on a specific DataStore type
      * @param dataStore The datastore type
-     * @param uniKey The UNI key
+     * @param uniIID The UNI InstanceIdentifier
      * @param uni The Uni's data
      * @param ovsdbNode The Ovsdb Node
      * @param dataBroker The dataBroker instance to create transactions
+     * @return true if uni is updated
      */
-    public static void updateUniNode(LogicalDatastoreType dataStore,
-                                     InstanceIdentifier<?> uniKey,
+    public static boolean updateUniNode(LogicalDatastoreType dataStore,
+                                     InstanceIdentifier<?> uniIID,
                                      UniAugmentation uni,
                                      Node ovsdbNode,
                                      DataBroker dataBroker) {
-        InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNode.getNodeId());
-        OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
-        UniAugmentationBuilder updatedUniBuilder = new UniAugmentationBuilder(uni);
+        final InstanceIdentifier<Node> ovsdbNodeIid = UnimgrMapper.getOvsdbNodeIid(ovsdbNode.getNodeId());
+        final OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
+        final UniAugmentationBuilder updatedUniBuilder = new UniAugmentationBuilder(uni);
         if (ovsdbNodeRef != null) {
             updatedUniBuilder.setOvsdbNodeRef(ovsdbNodeRef);
         }
-        Optional<Node> optionalNode = readNode(dataBroker,
+        final Optional<Node> optionalNode = readNode(dataBroker,
                                                LogicalDatastoreType.CONFIGURATION,
-                                               uniKey);
+                                               uniIID);
         if (optionalNode.isPresent()) {
-            Node node = optionalNode.get();
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
-            NodeBuilder nodeBuilder = new NodeBuilder();
+            final Node node = optionalNode.get();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final NodeBuilder nodeBuilder = new NodeBuilder();
             nodeBuilder.setKey(node.getKey());
             nodeBuilder.setNodeId(node.getNodeId());
             nodeBuilder.addAugmentation(UniAugmentation.class, updatedUniBuilder.build());
-            transaction.put(dataStore, uniKey.firstIdentifierOf(Node.class), nodeBuilder.build());
+            transaction.put(dataStore, uniIID.firstIdentifierOf(Node.class), nodeBuilder.build());
             transaction.submit();
+            return true;
         }
+        return false;
     }
 
     /**
@@ -1325,30 +1330,33 @@ public class UnimgrUtils {
      * @param uni The Uni's data
      * @param ovsdbNodeIid The Ovsdb Node Instance Identifier
      * @param dataBroker The dataBroker instance to create transactions
+     * @return true if uni is updated
      */
-    public static void updateUniNode(LogicalDatastoreType dataStore,
+    public static boolean updateUniNode(LogicalDatastoreType dataStore,
                                      InstanceIdentifier<?> uniKey,
                                      UniAugmentation uni,
                                      InstanceIdentifier<?> ovsdbNodeIid,
                                      DataBroker dataBroker) {
-        OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
-        UniAugmentationBuilder updatedUniBuilder = new UniAugmentationBuilder(uni);
+        final OvsdbNodeRef ovsdbNodeRef = new OvsdbNodeRef(ovsdbNodeIid);
+        final UniAugmentationBuilder updatedUniBuilder = new UniAugmentationBuilder(uni);
         if (ovsdbNodeRef != null) {
             updatedUniBuilder.setOvsdbNodeRef(ovsdbNodeRef);
         }
-        Optional<Node> optionalNode = readNode(dataBroker,
+        final Optional<Node> optionalNode = readNode(dataBroker,
                                                LogicalDatastoreType.CONFIGURATION,
                                                uniKey);
         if (optionalNode.isPresent()) {
-            Node node = optionalNode.get();
-            WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
-            NodeBuilder nodeBuilder = new NodeBuilder();
+            final Node node = optionalNode.get();
+            final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+            final NodeBuilder nodeBuilder = new NodeBuilder();
             nodeBuilder.setKey(node.getKey());
             nodeBuilder.setNodeId(node.getNodeId());
             nodeBuilder.addAugmentation(UniAugmentation.class, updatedUniBuilder.build());
             transaction.put(dataStore, uniKey.firstIdentifierOf(Node.class), nodeBuilder.build());
             transaction.submit();
+            return true;
         }
+        return false;
     }
 
     /**
@@ -1359,20 +1367,21 @@ public class UnimgrUtils {
      * @param sourceUniIid The Source Uni Instance Identifier
      * @param destinationUniIid The destination Uni Instance Identifier
      * @param dataBroker The dataBroker instance to create transactions
+     * @return true if evc is updated
      */
-    public static void updateEvcNode(LogicalDatastoreType dataStore,
+    public static boolean updateEvcNode(LogicalDatastoreType dataStore,
                                      InstanceIdentifier<?> evcKey,
                                      EvcAugmentation evcAugmentation,
                                      InstanceIdentifier<?> sourceUniIid,
                                      InstanceIdentifier<?> destinationUniIid,
                                      DataBroker dataBroker) {
-        EvcAugmentationBuilder updatedEvcBuilder = new EvcAugmentationBuilder(evcAugmentation);
+        final EvcAugmentationBuilder updatedEvcBuilder = new EvcAugmentationBuilder(evcAugmentation);
         if (sourceUniIid != null && destinationUniIid != null) {
-            List<UniSource> sourceList = new ArrayList<UniSource>();
-            UniSourceKey sourceKey = evcAugmentation.getUniSource().iterator().next().getKey();
-            short sourceOrder = evcAugmentation.getUniSource().iterator().next().getOrder();
-            IpAddress sourceIp = evcAugmentation.getUniSource().iterator().next().getIpAddress();
-            UniSource uniSource = new UniSourceBuilder()
+            final List<UniSource> sourceList = new ArrayList<UniSource>();
+            final UniSourceKey sourceKey = evcAugmentation.getUniSource().iterator().next().getKey();
+            final short sourceOrder = evcAugmentation.getUniSource().iterator().next().getOrder();
+            final IpAddress sourceIp = evcAugmentation.getUniSource().iterator().next().getIpAddress();
+            final UniSource uniSource = new UniSourceBuilder()
                                           .setOrder(sourceOrder)
                                           .setKey(sourceKey)
                                           .setIpAddress(sourceIp)
@@ -1381,11 +1390,11 @@ public class UnimgrUtils {
             sourceList.add(uniSource);
             updatedEvcBuilder.setUniSource(sourceList);
 
-            List<UniDest> destinationList = new ArrayList<UniDest>();
-            UniDestKey destKey = evcAugmentation.getUniDest().iterator().next().getKey();
-            short destOrder = evcAugmentation.getUniDest().iterator().next().getOrder();
-            IpAddress destIp = evcAugmentation.getUniDest().iterator().next().getIpAddress();
-            UniDest uniDest = new UniDestBuilder()
+            final List<UniDest> destinationList = new ArrayList<UniDest>();
+            final UniDestKey destKey = evcAugmentation.getUniDest().iterator().next().getKey();
+            final short destOrder = evcAugmentation.getUniDest().iterator().next().getOrder();
+            final IpAddress destIp = evcAugmentation.getUniDest().iterator().next().getIpAddress();
+            final UniDest uniDest = new UniDestBuilder()
                                       .setIpAddress(destIp)
                                       .setOrder(destOrder)
                                       .setKey(destKey)
@@ -1393,13 +1402,13 @@ public class UnimgrUtils {
                                       .build();
             destinationList.add(uniDest);
             updatedEvcBuilder.setUniDest(destinationList);
-            Optional<Link> optionalEvcLink = readLink(dataBroker,
+            final Optional<Link> optionalEvcLink = readLink(dataBroker,
                                                       LogicalDatastoreType.CONFIGURATION,
                                                       evcKey);
             if (optionalEvcLink.isPresent()) {
-                Link link = optionalEvcLink.get();
-                WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
-                LinkBuilder linkBuilder = new LinkBuilder();
+                final Link link = optionalEvcLink.get();
+                final WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+                final LinkBuilder linkBuilder = new LinkBuilder();
                 linkBuilder.setKey(link.getKey());
                 linkBuilder.setLinkId(link.getLinkId());
                 linkBuilder.setDestination(link.getDestination());
@@ -1407,9 +1416,13 @@ public class UnimgrUtils {
                 linkBuilder.addAugmentation(EvcAugmentation.class, updatedEvcBuilder.build());
                 transaction.put(dataStore, evcKey.firstIdentifierOf(Link.class), linkBuilder.build());
                 transaction.submit();
+                return true;
+            } else {
+                LOG.info("EvcLink is not present: " + optionalEvcLink.get().getKey());
             }
         } else {
             LOG.info("Invalid instance identifiers for sourceUni and destUni.");
         }
+        return false;
     }
 }
index 337fc7d117408ca07cc242b8d456f81c7faca8e0..abf2c2c5c556d05a5cf64afcd129dad8d61905ab 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 CableLabs and others.  All rights reserved.
+ * Copyright (c) 2016 CableLabs and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -40,6 +40,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDest;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSource;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
@@ -87,11 +89,11 @@ public class UnimgrProviderTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testOnSessionInitiated() throws Exception {
-        ProviderContext session = mock(ProviderContext.class);
+        final ProviderContext session = mock(ProviderContext.class);
         when(session.getSALService(DataBroker.class)).thenReturn(dataBroker);
-        BundleContext context = mock(BundleContext.class);
+        final BundleContext context = mock(BundleContext.class);
         PowerMockito.mockStatic(FrameworkUtil.class);
-        Bundle bundle = mock(Bundle.class);
+        final Bundle bundle = mock(Bundle.class);
         when(bundle.getBundleContext()).thenReturn(context);
         PowerMockito.when(FrameworkUtil.getBundle(unimgrProvider.getClass())).thenReturn(bundle);
         mockUnimgrConsoleRegistration = mock(ServiceRegistration.class);
@@ -109,29 +111,29 @@ public class UnimgrProviderTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testInitializeTopology() throws Exception {
-        InstanceIdentifier<NetworkTopology> path = mock(InstanceIdentifier.class);
+        final InstanceIdentifier<NetworkTopology> path = mock(InstanceIdentifier.class);
         PowerMockito.mockStatic(InstanceIdentifier.class);
         when(InstanceIdentifier.create(NetworkTopology.class)).thenReturn(path);
 
-        CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = mock(CheckedFuture.class);
-        ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
+        final CheckedFuture<Optional<NetworkTopology>, ReadFailedException> topology = mock(CheckedFuture.class);
+        final ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
         when(dataBroker.newReadWriteTransaction()).thenReturn(transaction);
         when(transaction.read(any(LogicalDatastoreType.class),
                               any(InstanceIdentifier.class))).thenReturn(topology);
 
-        Optional<NetworkTopology> optNetTopo = mock(Optional.class);
+        final Optional<NetworkTopology> optNetTopo = mock(Optional.class);
         when(topology.get()).thenReturn(optNetTopo);
         when(optNetTopo.isPresent()).thenReturn(false);
-        NetworkTopologyBuilder ntb = mock(NetworkTopologyBuilder.class);
+        final NetworkTopologyBuilder ntb = mock(NetworkTopologyBuilder.class);
         PowerMockito.whenNew(NetworkTopologyBuilder.class).withNoArguments().thenReturn(ntb);
-        NetworkTopology networkTopology = mock(NetworkTopology.class);
+        final NetworkTopology networkTopology = mock(NetworkTopology.class);
         when(ntb.build()).thenReturn(networkTopology);
         doNothing().when(transaction).put(any(LogicalDatastoreType.class),
                                           any(InstanceIdentifier.class),
                                           any(NetworkTopology.class));
         when(transaction.submit()).thenReturn(mock(CheckedFuture.class));
 
-        LogicalDatastoreType type = PowerMockito.mock(LogicalDatastoreType.class);
+        final LogicalDatastoreType type = PowerMockito.mock(LogicalDatastoreType.class);
         Whitebox.invokeMethod(unimgrProvider, "initializeTopology", type);
         verify(ntb).build();
         verify(transaction).put(any(LogicalDatastoreType.class),
@@ -143,7 +145,7 @@ public class UnimgrProviderTest {
     @SuppressWarnings("unchecked")
     @Test
     public void testInitDatastore() throws Exception {
-        ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
+        final ReadWriteTransaction transaction = mock(ReadWriteTransaction.class);
         when(dataBroker.newReadWriteTransaction()).thenReturn(transaction);
 
         //suppress calls to initializeTopology()
@@ -151,26 +153,26 @@ public class UnimgrProviderTest {
                                                      "initializeTopology",
                                                      LogicalDatastoreType.class));
 
-        CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = mock(CheckedFuture.class);
+        final CheckedFuture<Optional<Topology>, ReadFailedException> unimgrTp = mock(CheckedFuture.class);
         when(transaction.read(any(LogicalDatastoreType.class),
                               any(InstanceIdentifier.class))).thenReturn(unimgrTp);
 
         //true case
-        Optional<Topology> optTopo = mock(Optional.class);
+        final Optional<Topology> optTopo = mock(Optional.class);
         when(unimgrTp.get()).thenReturn(optTopo);
         when(optTopo.isPresent()).thenReturn(false);
-        TopologyBuilder tpb = mock(TopologyBuilder.class);
+        final TopologyBuilder tpb = mock(TopologyBuilder.class);
         PowerMockito.whenNew(TopologyBuilder.class).withNoArguments().thenReturn(tpb);
         when(tpb.setTopologyId(any(TopologyId.class))).thenReturn(tpb);
-        Topology data = mock(Topology.class);
+        final Topology data = mock(Topology.class);
         when(tpb.build()).thenReturn(data);
         doNothing().when(transaction).put(any(LogicalDatastoreType.class),
                                           any(InstanceIdentifier.class),
                                           any(Topology.class));
         when(transaction.submit()).thenReturn(mock(CheckedFuture.class));
 
-        LogicalDatastoreType type = PowerMockito.mock(LogicalDatastoreType.class);
-        TopologyId mockTopoId = mock(TopologyId.class);
+        final LogicalDatastoreType type = PowerMockito.mock(LogicalDatastoreType.class);
+        final TopologyId mockTopoId = mock(TopologyId.class);
         Whitebox.invokeMethod(unimgrProvider, "initDatastore", type, mockTopoId);
         PowerMockito.verifyPrivate(unimgrProvider).invoke("initializeTopology", type);
         verify(tpb).setTopologyId(any(TopologyId.class));
@@ -192,7 +194,7 @@ public class UnimgrProviderTest {
     public void testAddUni() throws Exception {
         PowerMockito.mockStatic(UnimgrUtils.class);
         assertEquals(unimgrProvider.addUni(null), false);
-        UniAugmentation mockUniAug = mock(UniAugmentation.class);
+        final UniAugmentation mockUniAug = mock(UniAugmentation.class);
         // false case
         when(mockUniAug.getIpAddress()).thenReturn(null);
         assertEquals(unimgrProvider.addUni(mockUniAug), false);
@@ -201,7 +203,7 @@ public class UnimgrProviderTest {
         // true case
         when(mockUniAug.getIpAddress()).thenReturn(mock(IpAddress.class));
         when(mockUniAug.getMacAddress()).thenReturn(mock(MacAddress.class));
-        UniAugmentationBuilder uniAugBuilder = new UniAugmentationBuilder()
+        final UniAugmentationBuilder uniAugBuilder = new UniAugmentationBuilder()
                                                     .setIpAddress(mock(IpAddress.class))
                                                     .setMacAddress(mock(MacAddress.class));
         when(UnimgrUtils.createUniNode(any(DataBroker.class),
@@ -218,7 +220,7 @@ public class UnimgrProviderTest {
         PowerMockito.mockStatic(InstanceIdentifier.class);
 
         // false case
-        IpAddress mockIpAddress = mock(IpAddress.class);
+        final IpAddress mockIpAddress = mock(IpAddress.class);
         PowerMockito.when(UnimgrMapper.getUniIid(any(DataBroker.class),
                                                  any(IpAddress.class),
                                                  any(LogicalDatastoreType.class)))
@@ -226,8 +228,8 @@ public class UnimgrProviderTest {
         assertEquals(false, unimgrProvider.removeUni(mockIpAddress));
 
         // true case
-        InstanceIdentifier<Node> iid = mock(InstanceIdentifier.class);
-        IpAddress ipAddress = new IpAddress(new Ipv4Address("192.168.1.1"));
+        final InstanceIdentifier<Node> iid = mock(InstanceIdentifier.class);
+        final IpAddress ipAddress = new IpAddress(new Ipv4Address("192.168.1.1"));
         PowerMockito.when(UnimgrMapper.getUniIid(any(DataBroker.class),
                                                  any(IpAddress.class),
                                                  any(LogicalDatastoreType.class)))
@@ -243,7 +245,7 @@ public class UnimgrProviderTest {
     @Test
     public void testlistUnis() throws Exception {
         PowerMockito.mockStatic(UnimgrUtils.class);
-        List<UniAugmentation> mockUniList = mock(List.class);
+        final List<UniAugmentation> mockUniList = mock(List.class);
         when(UnimgrUtils.getUnis(any(DataBroker.class),
                                  any(LogicalDatastoreType.class)))
                         .thenReturn(mockUniList);
@@ -254,12 +256,12 @@ public class UnimgrProviderTest {
     @Test
     public void testgetUni() throws Exception {
         PowerMockito.mockStatic(UnimgrUtils.class);
-        UniAugmentation mockUniAug = mock(UniAugmentation.class);
+        final UniAugmentation mockUniAug = mock(UniAugmentation.class);
         when(UnimgrUtils.getUni(any(DataBroker.class),
                                 any(LogicalDatastoreType.class),
                                 any(IpAddress.class)))
                         .thenReturn(mockUniAug);
-        IpAddress mockIpAddress = mock(IpAddress.class);
+        final IpAddress mockIpAddress = mock(IpAddress.class);
         assertEquals(mockUniAug, unimgrProvider.getUni(mockIpAddress));
     }
 
@@ -278,4 +280,18 @@ public class UnimgrProviderTest {
         assertEquals(null, unimgrProvider.getEvc(any(String.class)));
     }
 
+    @Test
+    public void testUpdateEvc() throws Exception {
+        final UniSource uniSource = mock(UniSource.class);
+        final UniDest uniDest = mock(UniDest.class);
+        when(uniSource.getUni()).thenReturn(null);
+        when(uniDest.getUni()).thenReturn(null);
+        //TODO
+    }
+
+    @Test
+    public void testUpdateUni() throws Exception {
+        assertEquals(false, unimgrProvider.updateUni(null));
+    }
+
 }