YANG Model and Provider Code Updates SDNR OOFPCIPOC 01/89801/1
authorSandeep Shah <sandeep.shah2@techmahindra.com>
Thu, 13 Jun 2019 12:28:11 +0000 (07:28 -0500)
committerSandeep Shah <sandeep.shah2@techmahindra.com>
Thu, 13 Jun 2019 12:28:11 +0000 (07:28 -0500)
Additional leaf nodes for Netconf notification for neigbor
list change, RPC to handle notification, and corresponding
updates to provider code

Issue-ID: CCSDK-1375
Signed-off-by: SandeepLinux <sandeeplinux1068@gmail.com>
Change-Id: I3d092ca9bdb42ce90bc5f69f0035ce806de997a6

sdnr/northbound/oofpcipoc/model/src/main/yang/oofpcipoc-api.yang
sdnr/northbound/oofpcipoc/model/src/main/yang/oofpcipoc.yang
sdnr/northbound/oofpcipoc/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/OofpcipocClient.java
sdnr/northbound/oofpcipoc/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/OofpcipocProvider.java

index 706a8b5..a688090 100644 (file)
@@ -94,4 +94,14 @@ module oofpcipoc-api {
     }
   }
 
+  rpc handle-nbrlist-change-notif {
+    description
+      "Handle nbrlist-change-notification: update configDB & publish DMAAP message";
+    input {
+      uses oofpcipoc:handle-nbrlist-change-notif-request;
+    }
+    output {
+      uses oofpcipoc:oofpcipoc-rpc-response;
+    }
+  }
 }
index 98978c3..2a7a260 100644 (file)
@@ -34,6 +34,11 @@ module oofpcipoc {
         "";
   }
 
+    typedef payload {
+           type string ;
+           description "The payload can be any valid JSON string value. Json escape characters need to be added when required to include an inner json within the payload to make it a valid json string value";
+    }
+
     grouping configuration-phy-cell-id-request {
 
       leaf fap-service-number-of-entries {
@@ -143,9 +148,57 @@ module oofpcipoc {
              length "0..52";
           }
         }
+        leaf pnf-name {
+          type string {
+            length "0..256";
+          }
+          description
+            "PNF name ";
+        }
       }
    }
 
+   grouping handle-nbrlist-change-notif-request {
+
+   description
+     "Input payload for handle-nbrlist-change-notif RPC for this POC";
+
+     leaf fap-service-number-of-entries-changed {
+       type uint64;
+       description
+         "Number of cells for which neighbor list has changed";
+     }
+     list fap-service {
+       key "alias";
+       leaf alias {
+         type string {
+           length "1..64";
+         }
+       }
+       leaf cid {
+         type string {
+         length "0..52";
+         }
+       }
+       uses x-0005b9-lte-g;
+       leaf lte-cell-number-of-entries {
+         type uint64;
+         description
+           "Number of cells in a neighbor list that was changed";
+       }
+       list lte-ran-neighbor-list-in-use-lte-cell-changed {
+         key "plmnid cid";
+         uses lte-ran-neighbor-list-in-use-lte-cell-g;
+         description
+           "Changed/Modified List of cells in a neighbor list for this fap service";
+           }
+        }
+        leaf payload {
+            type payload;
+            mandatory true;
+        }
+    }
+
     grouping oofpcipoc-rpc-response {
       leaf response-code {
         type string;
@@ -383,6 +436,7 @@ module oofpcipoc {
           length "0..52";
           }
         }
+        uses x-0005b9-lte-g;
         leaf lte-cell-number-of-entries {
           type uint64;
           description
index eca01d9..b794658 100644 (file)
@@ -31,6 +31,7 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCel
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.AddNeighborOutputBuilder;
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.DeleteNeighborOutputBuilder;
 import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.GenericNeighborConfigurationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.HandleNbrlistChangeNotifOutputBuilder;
 
 
 import org.slf4j.Logger;
@@ -304,4 +305,55 @@ public Properties execute(String module, String rpc, String version, String mode
        return respProps;
 }
 
+
+// handleNbrlistChangeNotif
+       public Properties execute(String module, String rpc, String version, String mode, HandleNbrlistChangeNotifOutputBuilder serviceData)
+                       throws SvcLogicException {
+
+               Properties parms = new Properties();
+
+               return execute(module,rpc,version, mode,serviceData,parms);
+       }
+
+       public Properties execute(String module, String rpc, String version, String mode, HandleNbrlistChangeNotifOutputBuilder serviceData, Properties parms)
+                               throws SvcLogicException {
+                               Properties localProp;
+                               localProp = MdsalHelper.toProperties(parms, serviceData);
+
+               if (LOG.isDebugEnabled())
+               {
+                       LOG.debug("Parameters passed to SLI");
+
+                       for (Object key : localProp.keySet()) {
+                               String parmName = (String) key;
+                               String parmValue = localProp.getProperty(parmName);
+
+                               LOG.debug(parmName+" = "+parmValue);
+
+                       }
+               }
+
+               Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+
+               if (LOG.isDebugEnabled())
+               {
+                       LOG.debug("Parameters returned by SLI");
+
+                       for (Object key : respProps.keySet()) {
+                               String parmName = (String) key;
+                               String parmValue = respProps.getProperty(parmName);
+
+                               LOG.debug(parmName+" = "+parmValue);
+
+                       }
+               }
+               if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+                       return respProps;
+               }
+
+               MdsalHelper.toBuilder(respProps, serviceData);
+
+               return respProps;
+       }
+
 }
index f52a72d..bfb9b04 100644 (file)
@@ -441,5 +441,73 @@ public class OofpcipocProvider implements AutoCloseable, OofpcipocApiService {
                return Futures.immediateFuture(rpcResult);
        }
 
+    // RPC handle-nbrlist-change-notif
+        @Override
+       public ListenableFuture<RpcResult<HandleNbrlistChangeNotifOutput>> handleNbrlistChangeNotif(
+                       HandleNbrlistChangeNotifInput input) {
+               final String svcOperation = "handle-nbrlist-change-notif";
+
+               Properties parms = new Properties();
+               HandleNbrlistChangeNotifOutputBuilder serviceDataBuilder = new HandleNbrlistChangeNotifOutputBuilder();
+
+          LOG.info( "Reached RPC handle-nbrlist-change-notif");
+
+               LOG.info( svcOperation +" called." );
+
+               if(input == null ) {
+                       LOG.debug("exiting " +svcOperation+ " because of invalid input");
+                       serviceDataBuilder.setResponseCode("Input is null");
+                       RpcResult<HandleNbrlistChangeNotifOutput> rpcResult =
+                               RpcResultBuilder.<HandleNbrlistChangeNotifOutput> status(true).withResult(serviceDataBuilder.build()).build();
+                       return Futures.immediateFuture(rpcResult);
+               }
+
+               // add input to parms
+               LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
+               HandleNbrlistChangeNotifInputBuilder inputBuilder = new HandleNbrlistChangeNotifInputBuilder(input);
+               MdsalHelper.toProperties(parms, inputBuilder.build());
+
+               // Call SLI sync method
+               try
+               {
+                       if (OofpcipocClient.hasGraph("Oofpcipoc", svcOperation , null, "sync"))
+                       {
+              LOG.info( "OofpcipocClient has a Directed Graph for '" + svcOperation + "'");
+                               try
+                               {
+                OofpcipocClient.execute("Oofpcipoc", svcOperation, null, "sync", serviceDataBuilder, parms);
+                               }
+                               catch (Exception e)
+                               {
+                                       LOG.error("Caught exception executing service logic for "+ svcOperation, e);
+                                       serviceDataBuilder.setResponseCode("500");
+                               }
+                       } else {
+                               LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'");
+                               serviceDataBuilder.setResponseCode("503");
+                       }
+               }
+               catch (Exception e)
+               {
+                       LOG.error("Caught exception looking for service logic", e);
+                       serviceDataBuilder.setResponseCode("500");
+               }
+
+               String errorCode = serviceDataBuilder.getResponseCode();
+
+               if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+                       LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
+               } else {
+                       LOG.info("Returned SUCCESS for "+svcOperation+" ");
+            serviceDataBuilder.setResponseCode("Welcome OOF POC. Number of FAP services changed = " + input.getFapServiceNumberOfEntriesChanged());
+               }
+
+               RpcResult<HandleNbrlistChangeNotifOutput> rpcResult =
+                               RpcResultBuilder.<HandleNbrlistChangeNotifOutput> status(true).withResult(serviceDataBuilder.build()).build();
+
+          LOG.info("Successful exit from handle-nbrlist-change-notif ");
+
+               return Futures.immediateFuture(rpcResult);
+       }
 
 }