From 1efd16dce0ecedb81039b26b81d1490cadeb3395 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Thu, 20 Dec 2018 13:44:40 -0500 Subject: 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) --- sliapi/features/ccsdk-sliapi/pom.xml | 44 +------ sliapi/features/features-sliapi/pom.xml | 46 ++++--- sliapi/features/pom.xml | 4 +- sliapi/installer/pom.xml | 4 +- sliapi/model/pom.xml | 48 ++++---- sliapi/model/src/main/yang/sliapi.yang | 2 +- sliapi/pom.xml | 4 +- sliapi/provider/pom.xml | 56 +++++---- .../onap/ccsdk/sli/core/sliapi/sliapiProvider.java | 133 +++++++++++++-------- .../src/main/yang/sliapi-provider-impl.yang | 61 ---------- .../ccsdk/sli/core/sliapi/TestSliapiProvider.java | 6 +- 11 files changed, 176 insertions(+), 232 deletions(-) delete mode 100755 sliapi/provider/src/main/yang/sliapi-provider-impl.yang (limited to 'sliapi') diff --git a/sliapi/features/ccsdk-sliapi/pom.xml b/sliapi/features/ccsdk-sliapi/pom.xml index 9c7e51539..e92fdd004 100644 --- a/sliapi/features/ccsdk-sliapi/pom.xml +++ b/sliapi/features/ccsdk-sliapi/pom.xml @@ -5,56 +5,18 @@ org.onap.ccsdk.parent single-feature-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core ccsdk-sliapi - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT feature ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.version} - - - - - org.opendaylight.mdsal.model - mdsal-model-artifacts - ${odl.mdsal.model.version} - pom - import - - - org.opendaylight.controller - mdsal-artifacts - ${odl.mdsal.version} - pom - import - - - org.onap.ccsdk.sli.core - sli-common - ${project.version} - - - org.onap.ccsdk.sli.core - sli-provider - ${project.version} - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - - - + diff --git a/sliapi/features/features-sliapi/pom.xml b/sliapi/features/features-sliapi/pom.xml index fb1931d8a..3f925dd28 100644 --- a/sliapi/features/features-sliapi/pom.xml +++ b/sliapi/features/features-sliapi/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - feature-repo-parent - 1.2.0 - - + + org.onap.ccsdk.parent + feature-repo-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - features-sliapi - 0.4.0-SNAPSHOT - feature + org.onap.ccsdk.sli.core + features-sliapi + 0.4.1-SNAPSHOT + feature - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.version} - + ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.groupId} - ccsdk-sliapi - ${project.version} - xml - features - + + + ${project.groupId} + ccsdk-sliapi + ${project.version} + xml + features + - + diff --git a/sliapi/features/pom.xml b/sliapi/features/pom.xml index 9ef65fc4e..703d6d1e5 100755 --- a/sliapi/features/pom.xml +++ b/sliapi/features/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-feature-aggregator - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/installer/pom.xml b/sliapi/installer/pom.xml index 48bfee66b..0bd4de3eb 100755 --- a/sliapi/installer/pom.xml +++ b/sliapi/installer/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-installer - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliapi :: ${project.artifactId} diff --git a/sliapi/model/pom.xml b/sliapi/model/pom.xml index 913e8ecdc..e7372bf23 100755 --- a/sliapi/model/pom.xml +++ b/sliapi/model/pom.xml @@ -1,33 +1,29 @@ - 4.0.0 + 4.0.0 - - org.onap.ccsdk.parent - binding-parent - 1.2.0 - - + + org.onap.ccsdk.parent + binding-parent + 1.2.1-SNAPSHOT + + - org.onap.ccsdk.sli.core - sliapi-model - 0.4.0-SNAPSHOT - bundle + org.onap.ccsdk.sli.core + sliapi-model + 0.4.1-SNAPSHOT + bundle - ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - ${project.version} - + ccsdk-sli-core :: sliapi :: ${project.artifactId} - - - org.opendaylight.mdsal.model - ietf-inet-types - - - org.opendaylight.mdsal.model - ietf-yang-types - - + + + org.opendaylight.mdsal.model + ietf-inet-types-2013-07-15 + + + org.opendaylight.mdsal.model + ietf-yang-types-20130715 + + diff --git a/sliapi/model/src/main/yang/sliapi.yang b/sliapi/model/src/main/yang/sliapi.yang index f0e79c068..98cbb2aa7 100755 --- a/sliapi/model/src/main/yang/sliapi.yang +++ b/sliapi/model/src/main/yang/sliapi.yang @@ -6,7 +6,7 @@ module SLI-API { prefix sample; - import ietf-inet-types { prefix "inet"; revision-date 2010-09-24; } + import ietf-inet-types { prefix "inet"; revision-date 2013-07-15; } organization "ONAP"; diff --git a/sliapi/pom.xml b/sliapi/pom.xml index 5c8b68f6d..aa04e9cc6 100755 --- a/sliapi/pom.xml +++ b/sliapi/pom.xml @@ -5,13 +5,13 @@ org.onap.ccsdk.parent odlparent-lite - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT pom ccsdk-sli-core :: sliapi diff --git a/sliapi/provider/pom.xml b/sliapi/provider/pom.xml index 0bcf7f75d..fea02dbcf 100755 --- a/sliapi/provider/pom.xml +++ b/sliapi/provider/pom.xml @@ -5,30 +5,26 @@ org.onap.ccsdk.parent binding-parent - 1.2.0 + 1.2.1-SNAPSHOT org.onap.ccsdk.sli.core sliapi-provider - 0.4.0-SNAPSHOT + 0.4.1-SNAPSHOT bundle ccsdk-sli-core :: sliapi :: ${project.artifactId} - - ${project.version} - - - - - - org.onap.ccsdk.sli.core - dblib-provider - ${project.version} - - - + + + + org.onap.ccsdk.sli.core + dblib-provider + ${project.version} + + + @@ -37,22 +33,40 @@ ${project.version} - - org.opendaylight.controller - sal-binding-config + org.opendaylight.mdsal + mdsal-binding-api - + org.opendaylight.controller sal-binding-api - + + + org.opendaylight.controller + sal-binding-broker-impl + + + + org.opendaylight.mdsal + mdsal-binding-dom-adapter + + + + org.opendaylight.mdsal + yang-binding + + org.opendaylight.controller sal-common-util - + + org.osgi + org.osgi.core + provided + org.onap.ccsdk.sli.core 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> executeGraph(ExecuteGraphInput input) { + public ListenableFuture> executeGraph(ExecuteGraphInput input) { RpcResult rpcResult = null; SvcLogicService svcLogic = getSvcLogicService(); @@ -395,7 +400,7 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } @Override - public Future> healthcheck() { + public ListenableFuture> healthcheck(HealthcheckInput healthcheckInput) { RpcResult rpcResult = null; SvcLogicService svcLogic = getSvcLogicService(); @@ -469,6 +474,80 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ return (Futures.immediateFuture(rpcResult)); } + public ListenableFuture> vlbcheck(VlbcheckInput vlbInput) { + + RpcResult 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. 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. 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. 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. 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 testResultIdBuilder = InstanceIdentifier.builder(TestResults.class) - .child(TestResult.class, entry.getKey()); - InstanceIdentifier path = testResultIdBuilder.toInstance(); + .child(TestResult.class, entry.key()); + InstanceIdentifier path = testResultIdBuilder.build(); int tries = 2; while(true) { try { @@ -590,50 +670,5 @@ public class sliapiProvider implements AutoCloseable, SLIAPIService{ } - @Override - public Future> vlbcheck() { - RpcResult 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.failed().withError(ErrorType.APPLICATION, - "resource-denied", "Server Suspended").build(); - } else { - respBuilder.setResponseMessage("server is normal"); - rpcResult = RpcResultBuilder. 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)); } } -- cgit 1.2.3-korg