delete uni command 30/29830/1
authorMohamed El-Serngawy <melserngawy@inocybe.com>
Tue, 17 Nov 2015 20:06:11 +0000 (15:06 -0500)
committerMohamed El-Serngawy <melserngawy@inocybe.com>
Tue, 17 Nov 2015 20:06:11 +0000 (15:06 -0500)
Change-Id: Ia36ff78296a72f493299e78f9a863e4d91705555
Signed-off-by: Mohamed El-Serngawy <melserngawy@inocybe.com>
cli/src/main/java/org/opendaylight/unimgr/cli/UniRemoveShellCommand.java
impl/src/main/java/org/opendaylight/unimgr/command/UniDeleteCommand.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrProvider.java
impl/src/main/java/org/opendaylight/unimgr/impl/UnimgrUtils.java

index 977c94840742003bb2f1104ba39669cf0c15ccde..3cbe14f594aad275906e779fe3efde52bdcec0b6 100755 (executable)
@@ -13,7 +13,7 @@ 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;
 
-@Command(name = "remove", scope = "uni", description = "Removes an Uni from the controller.")
+@Command(name = "uni-remove", scope = "uni", description = "Removes an Uni from the controller.")
 public class UniRemoveShellCommand extends OsgiCommandSupport {
 
     protected IUnimgrConsoleProvider provider;
index 2308cbd29400e60b8624c1fe2ee08b9860f2b2e9..9dab51f58386777ee3cc7c2761bbdf3ee054420e 100644 (file)
@@ -56,9 +56,8 @@ public class UniDeleteCommand extends AbstractDeleteCommand {
                                                    bridgeIid,
                                                    LogicalDatastoreType.CONFIGURATION);
                     }
-                    UnimgrUtils.deleteNode(dataBroker,
-                                           removedUniIid,
-                                           LogicalDatastoreType.OPERATIONAL);
+                    InstanceIdentifier<Node> iidUni = UnimgrMapper.getUniIid(dataBroker, uniAugmentation.getIpAddress(), LogicalDatastoreType.OPERATIONAL);
+                    UnimgrUtils.deleteNode(dataBroker, iidUni, LogicalDatastoreType.OPERATIONAL);
                 }
                 else {
                     LOG.info("Received Uni Augmentation is null", removedUniIid);
index 4bc29f54cbbd8822e0c27dcdb11635476030a36b..8a243ec07bbb8a7f0477e63a1758082ed05602e3 100755 (executable)
@@ -26,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 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.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;
@@ -137,8 +138,11 @@ public class UnimgrProvider implements BindingAwareProvider, AutoCloseable, IUni
 
     @Override
     public boolean removeUni(IpAddress ipAddress) {
-        // TODO Auto-generated method stub
-        return false;
+        InstanceIdentifier<Node> iidUni = UnimgrMapper.getUniIid(dataBroker, ipAddress, LogicalDatastoreType.CONFIGURATION);
+        if (iidUni == null)
+            return false;
+
+        return UnimgrUtils.deleteNode(dataBroker, iidUni, LogicalDatastoreType.CONFIGURATION);
     }
 
     @Override
index 5195eddaca6a6c4476e82759183865f11a4db527..6b0ee47421dd5f348c02f1e6c5552bacb1fb965c 100644 (file)
@@ -491,17 +491,20 @@ public class UnimgrUtils {
      * @param genericNode The instance identifier of a generic node
      * @param store The dataStore where to send and submit the delete call.
      */
-    public static void deleteNode(DataBroker dataBroker,
+    public static boolean deleteNode(DataBroker dataBroker,
                                   InstanceIdentifier<?> genericNode,
                                   LogicalDatastoreType store) {
         LOG.info("Received a request to delete node {}", genericNode);
+        boolean result = false;
         WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         transaction.delete(store, genericNode);
         try {
             transaction.submit().checkedGet();
+            return !result;
         } catch (TransactionCommitFailedException e) {
             LOG.error("Unable to remove node with Iid {} from store {}.", genericNode, store);
         }
+        return result;
     }
 
     /**