Ignore ModifiedNodeDoesNotExistException on delete 03/19803/1
authorDan Timoney <dtimoney@att.com>
Thu, 19 Oct 2017 20:03:04 +0000 (16:03 -0400)
committerDan Timoney <dtimoney@att.com>
Thu, 19 Oct 2017 20:03:56 +0000 (16:03 -0400)
When trying to deleteVnf from operational or config tree, if a
ModifiedNodeDoesNotExistException is cause for commit exception
it means that the data you are trying to delete does not exist.
So you wanted it gone, it's already gone ... log a message at
debug level but don't fail the transaction.

Change-Id: Iea0f4e78522cc2f437843e2b17080855cd314ea6
Issue-ID: SDNC-137
Signed-off-by: Dan Timoney <dtimoney@att.com>
generic-resource-api/model/src/main/yang/GENERIC-RESOURCE-API.yang
vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java

index 327c6a2..2f45ae2 100644 (file)
@@ -829,7 +829,7 @@ module GENERIC-RESOURCE-API {
            description "The Network Controller will look up the vgmux bearer ip from the vgmux vf module";\r
            type inet:ip-address;\r
        }\r
-       leaf vgmux-lan-up {\r
+       leaf vgmux-lan-ip {\r
            description "The Network Controller will look up the vgmux lan ip from the vgmux vg module";\r
            type inet:ip-address;\r
        }\r
index a94d5e3..28daac2 100644 (file)
@@ -131,6 +131,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.ModifiedNodeDoesNotExistException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.MDC;
@@ -778,16 +779,21 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
                 tx.submit().checkedGet();
                 log.debug("DataStore delete succeeded");
                 break;
-            } catch (final TransactionCommitFailedException e) {
+            } catch (final TransactionCommitFailedException  e) {
                 if (e instanceof OptimisticLockFailedException) {
                     if (--tries <= 0) {
                         log.debug("Got OptimisticLockFailedException on last try - failing ");
                         throw new IllegalStateException(e);
                     }
                     log.debug("Got OptimisticLockFailedException - trying again ");
-                } else {
-                    log.debug("Delete DataStore failed");
-                    throw new IllegalStateException(e);
+                }
+                else {
+                               if (e.getCause() instanceof ModifiedNodeDoesNotExistException) {
+                                       log.debug("Ignoring MpdifiedNodeDoesNotExistException");
+                               } else {
+                                       log.debug("Delete DataStore failed");
+                                       throw new IllegalStateException(e);
+                               }
                 }
             }
         }