summaryrefslogtreecommitdiffstats
path: root/sliapi/provider/src
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dtimoney@att.com>2018-12-20 13:44:40 -0500
committerDan Timoney <dtimoney@att.com>2019-01-10 12:41:38 +0000
commit1efd16dce0ecedb81039b26b81d1490cadeb3395 (patch)
tree4fa8293a6b72871956f90430a53b9400ce5f7a4f /sliapi/provider/src
parenta3ac46a6aba71ef0f86576fcbf2e196d96103c4d (diff)
Code changes to sli/core for ODL Fluorine
Code changes needed to support port to ODL Fluorine. Change-Id: I539aeaabeab1056cd109b6bee12046d91d61cab1 Issue-ID: CCSDK-870 Signed-off-by: Timoney, Dan (dt5972) <dtimoney@att.com>
Diffstat (limited to 'sliapi/provider/src')
-rw-r--r--sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java133
-rwxr-xr-xsliapi/provider/src/main/yang/sliapi-provider-impl.yang61
-rw-r--r--sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java6
3 files changed, 88 insertions, 112 deletions
diff --git a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
index 4817a95a0..7db5941f8 100644
--- a/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
+++ b/sliapi/provider/src/main/java/org/onap/ccsdk/sli/core/sliapi/sliapiProvider.java
@@ -29,6 +29,7 @@ import java.util.Enumeration;
import java.util.LinkedList;
import java.util.Properties;
import java.util.concurrent.Future;
+
import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
@@ -46,10 +47,12 @@ import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.Exe
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.TestResults;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter;
@@ -75,7 +78,9 @@ import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
/**
@@ -215,7 +220,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{
}
@Override
- public Future<RpcResult<ExecuteGraphOutput>> executeGraph(ExecuteGraphInput input) {
+ public ListenableFuture<RpcResult<ExecuteGraphOutput>> executeGraph(ExecuteGraphInput input) {
RpcResult<ExecuteGraphOutput> rpcResult = null;
SvcLogicService svcLogic = getSvcLogicService();
@@ -395,7 +400,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{
}
@Override
- public Future<RpcResult<HealthcheckOutput>> healthcheck() {
+ public ListenableFuture<RpcResult<HealthcheckOutput>> healthcheck(HealthcheckInput healthcheckInput) {
RpcResult<HealthcheckOutput> rpcResult = null;
SvcLogicService svcLogic = getSvcLogicService();
@@ -469,6 +474,80 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{
return (Futures.immediateFuture(rpcResult));
}
+ public ListenableFuture<RpcResult<VlbcheckOutput>> vlbcheck(VlbcheckInput vlbInput) {
+
+ RpcResult<VlbcheckOutput> rpcResult = null;
+ SvcLogicService svcLogic = getSvcLogicService();
+
+ VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder();
+
+ String calledModule = "sli";
+ String calledRpc = "vlbcheck";
+ String modeStr = "sync";
+
+ if (svcLogic == null) {
+ respBuilder.setResponseCode("500");
+ respBuilder.setResponseMessage("Could not locate OSGi SvcLogicService service");
+ respBuilder.setAckFinalIndicator("Y");
+
+ rpcResult = RpcResultBuilder.<VlbcheckOutput> failed().withResult(respBuilder.build()).build();
+ return(Futures.immediateFuture(rpcResult));
+ }
+
+ try {
+ if (!svcLogic.hasGraph(calledModule, calledRpc, null, modeStr)) {
+ respBuilder.setResponseCode("404");
+ respBuilder.setResponseMessage("Directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr+" not found");
+
+ respBuilder.setAckFinalIndicator("Y");
+
+ rpcResult = RpcResultBuilder.<VlbcheckOutput> status(true).withResult(respBuilder.build()).build();
+ return(Futures.immediateFuture(rpcResult));
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr, e);
+
+ respBuilder.setResponseCode("500");
+ respBuilder.setResponseMessage("Internal error : could not determine if target graph exists");
+ respBuilder.setAckFinalIndicator("Y");
+
+ rpcResult = RpcResultBuilder.<VlbcheckOutput> failed().withResult(respBuilder.build()).build();
+ return(Futures.immediateFuture(rpcResult));
+ }
+
+ try {
+ LOG.info("Calling directed graph for "+calledModule+"/"+calledRpc+"/"+modeStr);
+
+ Properties parms = new Properties();
+
+ Properties respProps = svcLogic.execute(calledModule, calledRpc,
+ null, modeStr, parms);
+
+ respBuilder.setResponseCode(respProps.getProperty("error-code", "0"));
+ respBuilder.setResponseMessage(respProps.getProperty("error-message", ""));
+ respBuilder.setAckFinalIndicator(respProps.getProperty("ack-final", "Y"));
+
+ } catch (Exception e) {
+ LOG.error("Caught exception executing directed graph for"
+ + calledModule + ":" + calledRpc + "," + modeStr + ">", e);
+
+ respBuilder.setResponseCode("500");
+ respBuilder
+ .setResponseMessage("Internal error : caught exception executing directed graph "
+ + calledModule
+ + "/"
+ + calledRpc
+ + "/"
+ + modeStr);
+ respBuilder.setAckFinalIndicator("Y");
+
+ }
+
+ rpcResult = RpcResultBuilder.<VlbcheckOutput> status(true)
+ .withResult(respBuilder.build()).build();
+ return (Futures.immediateFuture(rpcResult));
+ }
+
private void DomSaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) {
@@ -529,10 +608,11 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{
private void SaveTestResult(final TestResult entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException
{
// Each entry will be identifiable by a unique key, we have to create that identifier
+
InstanceIdentifier.InstanceIdentifierBuilder<TestResult> testResultIdBuilder =
InstanceIdentifier.<TestResults>builder(TestResults.class)
- .child(TestResult.class, entry.getKey());
- InstanceIdentifier<TestResult> path = testResultIdBuilder.toInstance();
+ .child(TestResult.class, entry.key());
+ InstanceIdentifier<TestResult> path = testResultIdBuilder.build();
int tries = 2;
while(true) {
try {
@@ -590,50 +670,5 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{
}
- @Override
- public Future<RpcResult<VlbcheckOutput>> vlbcheck() {
- RpcResult<VlbcheckOutput> rpcResult = null;
- VlbcheckOutputBuilder respBuilder = new VlbcheckOutputBuilder();
- boolean suspended = false;
- BufferedReader br = null;
- String line = "";
-
- // check the state based on the config file
-
- if (sdncStatusFile != null) {
- try {
- br = new BufferedReader(new FileReader(sdncStatusFile));
- while((line = br.readLine()) != null)
- {
- if ("ODL_STATE=SUSPENDED".equals(line)) {
- suspended = true;
- LOG.debug("vlbcheck: server is suspended");
- }
- }
- br.close();
- } catch (FileNotFoundException e) {
- LOG.trace("Caught File not found exception " + sdncStatusFile +"\n",e);
- } catch (Exception e) {
- LOG.trace("Failed to read status file " + sdncStatusFile +"\n",e);
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- LOG.warn("Failed to close status file " + sdncStatusFile +"\n",e);
- }
- }
- }
- }
- if (suspended) {
- rpcResult = RpcResultBuilder.<VlbcheckOutput>failed().withError(ErrorType.APPLICATION,
- "resource-denied", "Server Suspended").build();
- } else {
- respBuilder.setResponseMessage("server is normal");
- rpcResult = RpcResultBuilder.<VlbcheckOutput> status(true)
- .withResult(respBuilder.build()).build();
- }
- return (Futures.immediateFuture(rpcResult));
- }
}
diff --git a/sliapi/provider/src/main/yang/sliapi-provider-impl.yang b/sliapi/provider/src/main/yang/sliapi-provider-impl.yang
deleted file mode 100755
index 0421ad0c4..000000000
--- a/sliapi/provider/src/main/yang/sliapi-provider-impl.yang
+++ /dev/null
@@ -1,61 +0,0 @@
-module sliapi-provider-impl {
-
- yang-version 1;
- namespace "org:onap:ccsdk:sli:core:sliapi:provider:impl";
- prefix "sliapi-provider-impl";
-
- import config { prefix config; revision-date 2013-04-05; }
- import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-
- description
- "This module contains the base YANG definitions for
- sliapi-provider impl implementation.";
-
- revision "2014-05-23" {
- description
- "Initial revision.";
- }
-
- // This is the definition of the service implementation as a module identity.
- identity sliapi-provider-impl {
- base config:module-type;
-
- // Specifies the prefix for generated java classes.
- config:java-name-prefix sliapiProvider;
- }
-
- // Augments the 'configuration' choice node under modules/module.
- // We consume the three main services, RPCs, DataStore, and Notifications
- augment "/config:modules/config:module/config:configuration" {
- case sliapi-provider-impl {
- when "/config:modules/config:module/config:type = 'sliapi-provider-impl'";
-
- container rpc-registry {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-rpc-registry;
- }
- }
- }
-
- container notification-service {
- uses config:service-ref {
- refine type {
- mandatory true;
- config:required-identity mdsal:binding-notification-service;
- }
- }
- }
-
- container data-broker {
- uses config:service-ref {
- refine type {
- mandatory false;
- config:required-identity mdsal:binding-async-data-broker;
- }
- }
- }
- }
- }
-}
diff --git a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java
index 96d619331..5106d6fc2 100644
--- a/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java
+++ b/sliapi/provider/src/test/java/org/onap/ccsdk/sli/core/sliapi/TestSliapiProvider.java
@@ -53,7 +53,9 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.ExecuteGraphInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.HealthcheckInput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.SLIAPIService;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.VlbcheckInput;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameter;
import org.opendaylight.yang.gen.v1.org.onap.ccsdk.sli.core.sliapi.rev161110.execute.graph.input.SliParameterBuilder;
@@ -161,7 +163,7 @@ public class TestSliapiProvider {
inputBuilder.setSliParameter(pList);
provider.executeGraph(inputBuilder.build());
- assertTrue(provider.vlbcheck() instanceof Future<?>);
+ assertTrue(provider.vlbcheck(mock(VlbcheckInput.class)) instanceof Future<?>);
}
/**
@@ -170,7 +172,7 @@ public class TestSliapiProvider {
*/
@Test
public void testHealthcheck() {
- provider.healthcheck();
+ provider.healthcheck(mock(HealthcheckInput.class));
}
}