aboutsummaryrefslogtreecommitdiffstats
path: root/asdcApi/provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'asdcApi/provider/src')
-rw-r--r--asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java57
-rw-r--r--asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java34
-rw-r--r--asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java415
-rw-r--r--asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java111
-rw-r--r--asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java48
-rw-r--r--asdcApi/provider/src/main/resources/initial/asdcApi-provider.xml72
-rwxr-xr-xasdcApi/provider/src/main/yang/asdcApi-provider-impl.yang61
7 files changed, 798 insertions, 0 deletions
diff --git a/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java
new file mode 100644
index 00000000..c9223a15
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModule.java
@@ -0,0 +1,57 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523;
+
+import org.openecomp.sdnc.asdcapi.AsdcApiProvider;
+
+public class AsdcApiProviderModule extends org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523.AbstractAsdcApiProviderModule {
+ public AsdcApiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public AsdcApiProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523.AsdcApiProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+
+ final AsdcApiProvider provider = new AsdcApiProvider(getDataBrokerDependency()
+ , getNotificationServiceDependency()
+ , getRpcRegistryDependency());
+
+ return new AutoCloseable() {
+
+ @Override
+ public void close() throws Exception {
+
+ provider.close();
+ }
+ };
+ }
+
+}
diff --git a/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java
new file mode 100644
index 00000000..6a1d8068
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/opendaylight/yang/gen/v1/org/openecomp/sdnc/asdcapi/provider/impl/rev140523/AsdcApiProviderModuleFactory.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+/*
+* Generated file
+*
+* Generated from: yang module name: asdcApi-provider-impl yang module local name: asdcApi-provider-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 02 03:46:08 EDT 2016
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523;
+public class AsdcApiProviderModuleFactory extends org.opendaylight.yang.gen.v1.org.openecomp.sdnc.asdcapi.provider.impl.rev140523.AbstractAsdcApiProviderModuleFactory {
+
+}
diff --git a/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java
new file mode 100644
index 00000000..28e59c8d
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiProvider.java
@@ -0,0 +1,415 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.asdcapi;
+
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.http.xmlns.openecomp.org.asdc.license.model._1._0.rev160427.vf.license.model.grouping.VfLicenseModel;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.ASDCAPIService;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.Artifacts;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.ArtifactsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateOutput;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelVersions;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelVersionsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.artifacts.Artifact;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.artifacts.ArtifactBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.artifacts.ArtifactKey;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.vf.license.model.versions.VfLicenseModelVersion;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.vf.license.model.versions.VfLicenseModelVersionBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+
+/**
+ * Defines a base implementation for your provider. This class extends from a helper class
+ * which provides storage for the most commonly used components of the MD-SAL. Additionally the
+ * base class provides some basic logging and initialization / clean up methods.
+ *
+ * To use this, copy and paste (overwrite) the following method into the TestApplicationProviderModule
+ * class which is auto generated under src/main/java in this project
+ * (created only once during first compilation):
+ *
+ * <pre>
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+
+ final asdcApiProvider provider = new asdcApiProvider();
+ provider.setDataBroker( getDataBrokerDependency() );
+ provider.setNotificationService( getNotificationServiceDependency() );
+ provider.setRpcRegistry( getRpcRegistryDependency() );
+ provider.initialize();
+ return new AutoCloseable() {
+
+ @Override
+ public void close() throws Exception {
+ //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION
+ //SERVIE/RPC REGISTRY
+ provider.close();
+ }
+ };
+ }
+
+
+ </pre>
+ */
+public class AsdcApiProvider implements AutoCloseable, ASDCAPIService {
+
+ private static final String ACTIVE_VERSION = "active";
+
+ private final Logger log = LoggerFactory.getLogger( AsdcApiProvider.class );
+ private final String appName = "asdcApi";
+
+ private final ExecutorService executor;
+ protected DataBroker dataBroker;
+ protected NotificationProviderService notificationService;
+ protected RpcProviderRegistry rpcRegistry;
+
+ protected BindingAwareBroker.RpcRegistration<ASDCAPIService> rpcRegistration;
+
+ public AsdcApiProvider(DataBroker dataBroker2,
+ NotificationProviderService notificationProviderService,
+ RpcProviderRegistry rpcProviderRegistry) {
+ this.log.info( "Creating provider for " + appName );
+ executor = Executors.newFixedThreadPool(1);
+ dataBroker = dataBroker2;
+ notificationService = notificationProviderService;
+ rpcRegistry = rpcProviderRegistry;
+ initialize();
+ }
+
+ public void initialize(){
+ log.info( "Initializing provider for " + appName );
+
+
+ createContainers();
+
+ if (rpcRegistration == null) {
+ if (rpcRegistry != null) {
+ rpcRegistration = rpcRegistry.addRpcImplementation(
+ ASDCAPIService.class, this);
+ log.info("Initialization complete for " + appName);
+ } else {
+ log.warn("Error initializing " + appName
+ + " : rpcRegistry unset");
+ }
+ }
+ }
+
+ private void createContainers() {
+
+ if (dataBroker != null) {
+ final WriteTransaction t = dataBroker.newReadWriteTransaction();
+
+ // Create the vf-model-license-versions and artifacts containers
+ t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(VfLicenseModelVersions.class),
+ new VfLicenseModelVersionsBuilder().build());
+
+ t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Artifacts.class), new ArtifactsBuilder().build());
+
+
+ try {
+ CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
+ checkedFuture.get();
+ log.info("Create Containers succeeded!: ");
+
+ } catch (InterruptedException | ExecutionException e) {
+ log.error("Create Containers Failed: " + e);
+ e.printStackTrace();
+ }
+ } else {
+ log.warn("createContainers : cannot find dataBroker to create containers");
+ }
+ }
+ protected void initializeChild() {
+ //Override if you have custom initialization intelligence
+ }
+
+ @Override
+ public void close() throws Exception {
+ log.info( "Closing provider for " + appName );
+ executor.shutdown();
+ rpcRegistration.close();
+ log.info( "Successfully closed provider for " + appName );
+ }
+
+ public void setDataBroker(DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ if( log.isDebugEnabled() ){
+ log.debug( "DataBroker set to " + (dataBroker==null?"null":"non-null") + "." );
+ }
+ }
+
+ public void setNotificationService(
+ NotificationProviderService notificationService) {
+ this.notificationService = notificationService;
+ if( log.isDebugEnabled() ){
+ log.debug( "Notification Service set to " + (notificationService==null?"null":"non-null") + "." );
+ }
+ }
+
+ public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
+ this.rpcRegistry = rpcRegistry;
+
+ rpcRegistration = rpcRegistry.addRpcImplementation(ASDCAPIService.class, this);
+
+ if( log.isDebugEnabled() ){
+ log.debug( "RpcRegistry set to " + (rpcRegistry==null?"null":"non-null") + "." );
+ }
+ }
+
+
+ protected boolean artifactVersionExists(String aName, String aVersion) {
+ InstanceIdentifier artifactInstanceId =
+ InstanceIdentifier.<Artifacts>builder(Artifacts.class)
+ .child(Artifact.class, new ArtifactKey(aName, aVersion)).toInstance();
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ Optional<Artifact> data = null;
+ try {
+ data = (Optional<Artifact>) readTx.read(LogicalDatastoreType.CONFIGURATION, artifactInstanceId).get();
+ } catch (InterruptedException | ExecutionException e) {
+ log.error("Caught Exception reading MD-SAL for ["+aName+","+ aVersion+"] " ,e);
+ return false;
+
+ }
+
+ if (data.isPresent()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected void addArtifactVersion(String aName, String aVersion) {
+
+
+ try {
+ ArtifactBuilder aBuilder = new ArtifactBuilder();
+
+ aBuilder.setArtifactName(aName);
+ aBuilder.setArtifactVersion(aVersion);
+
+ Artifact artifact = aBuilder.build();
+
+ InstanceIdentifier.InstanceIdentifierBuilder<Artifact> aIdBuilder = InstanceIdentifier
+ .<Artifacts> builder(Artifacts.class)
+ .child(Artifact.class, artifact.getKey());
+
+ InstanceIdentifier<Artifact> path = aIdBuilder
+ .toInstance();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+
+ tx.merge(LogicalDatastoreType.CONFIGURATION, path,
+ artifact);
+ tx.submit().checkedGet();
+ } catch (Exception e) {
+ log.error("Caught exception trying to add artifact entry", e);
+ }
+
+ }
+
+
+ private void applyVfLicenseModelUpdate(VfLicenseModelUpdateInput input) {
+
+ String aName = input.getArtifactName();
+ String aVersion = input.getArtifactVersion();
+ VfLicenseModel vfLicenseModel = input.getVfLicenseModel();
+
+
+ // Add new version (version = artifact-version)
+ try {
+
+ VfLicenseModelVersionBuilder vBuilder = new VfLicenseModelVersionBuilder();
+ vBuilder.setArtifactName(aName);
+ vBuilder.setArtifactVersion(aVersion);
+ vBuilder.setVfLicenseModel(vfLicenseModel);
+
+ VfLicenseModelVersion version = vBuilder.build();
+
+ InstanceIdentifier.InstanceIdentifierBuilder<VfLicenseModelVersion> versionIdBuilder = InstanceIdentifier
+ .<VfLicenseModelVersions> builder(VfLicenseModelVersions.class)
+ .child(VfLicenseModelVersion.class, version.getKey());
+
+ InstanceIdentifier<VfLicenseModelVersion> path = versionIdBuilder
+ .toInstance();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ tx.merge(LogicalDatastoreType.CONFIGURATION, path,
+ version);
+ tx.submit().checkedGet();
+ } catch (Exception e) {
+ log.error(
+ "Caught exception trying to save entry to MD-SAL",
+ e);
+ }
+
+
+ // Add "active" version (version = "active")
+ try {
+
+ VfLicenseModelVersionBuilder vBuilder = new VfLicenseModelVersionBuilder();
+ vBuilder.setArtifactName(aName);
+ vBuilder.setArtifactVersion(ACTIVE_VERSION);
+ vBuilder.setVfLicenseModel(vfLicenseModel);
+
+ VfLicenseModelVersion version = vBuilder.build();
+ InstanceIdentifier.InstanceIdentifierBuilder<VfLicenseModelVersion> versionIdBuilder = InstanceIdentifier
+ .<VfLicenseModelVersions> builder(VfLicenseModelVersions.class)
+ .child(VfLicenseModelVersion.class, version.getKey());
+
+ InstanceIdentifier<VfLicenseModelVersion> path = versionIdBuilder
+ .toInstance();
+
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+
+ tx.merge(LogicalDatastoreType.CONFIGURATION, path,
+ version);
+ tx.submit().checkedGet();
+ } catch (Exception e) {
+ log.error(
+ "Caught exception trying to save entry to MD-SAL",
+ e);
+ }
+
+}
+
+@Override
+public Future<RpcResult<VfLicenseModelUpdateOutput>> vfLicenseModelUpdate(VfLicenseModelUpdateInput input) {
+ final String SVC_OPERATION = "vf-license-model-update";
+
+ Properties parms = new Properties();
+
+ log.info( SVC_OPERATION +" called." );
+
+ if(input == null ) {
+ log.debug("exiting " +SVC_OPERATION+ " because of invalid input");
+ return null;
+ }
+
+ VfLicenseModelUpdateInputBuilder inputBuilder = new VfLicenseModelUpdateInputBuilder(input);
+ input = inputBuilder.build();
+
+ String errorMessage = "Success";
+ String errorCode = "200";
+
+ // If this artifact already exists, reject this update
+ if (artifactVersionExists(input.getArtifactName(), input.getArtifactVersion())) {
+ errorCode = "409";
+ errorMessage = "Artifact version already exists";
+ } else {
+ // Translate input object into SLI-consumable properties
+ log.info("Adding INPUT data for "+SVC_OPERATION+" input: " + input);
+ AsdcApiUtil.toProperties(parms, input);
+
+
+ // Call directed graph
+
+ Properties respProps = null;
+
+
+ AsdcApiSliClient sliClient = new AsdcApiSliClient();
+ try
+ {
+ if (sliClient.hasGraph("ASDC-API", SVC_OPERATION , null, "sync"))
+ {
+
+ try
+ {
+ respProps = sliClient.execute("ASDC-API", SVC_OPERATION, null, "sync", parms);
+ }
+ catch (Exception e)
+ {
+ log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ }
+ } else {
+ errorMessage = "No service logic active for ASDC-API: '" + SVC_OPERATION + "'";
+ errorCode = "503";
+ }
+ }
+ catch (Exception e)
+ {
+ errorCode = "500";
+ errorMessage = e.getMessage();
+ log.error("Caught exception looking for service logic", e);
+ }
+
+
+ if (respProps != null)
+ {
+ errorCode = respProps.getProperty("error-code");
+ errorMessage = respProps.getProperty("error-message", "");
+ }
+ }
+
+
+ if ("200".equals(errorCode)) {
+ log.info("ASDC update succeeded");
+
+ // Update config tree
+ applyVfLicenseModelUpdate(input);
+ addArtifactVersion(input.getArtifactName(), input.getArtifactVersion());
+
+ } else {
+ log.info("ASDC update failed ("+errorCode+" : "+errorMessage);
+ }
+
+ // Send response
+ VfLicenseModelUpdateOutputBuilder respBuilder = new VfLicenseModelUpdateOutputBuilder();
+ respBuilder.setAsdcApiResponseCode(errorCode);
+ if (errorMessage != null && errorMessage.length() > 0) {
+ respBuilder.setAsdcApiResponseText(errorMessage);
+ }
+
+ RpcResult<VfLicenseModelUpdateOutput> rpcResult;
+
+
+ rpcResult = RpcResultBuilder.<VfLicenseModelUpdateOutput> status(true).withResult(respBuilder.build()).build();
+
+
+
+ return Futures.immediateFuture(rpcResult);
+}
+
+
+}
diff --git a/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java
new file mode 100644
index 00000000..2f3a783b
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiSliClient.java
@@ -0,0 +1,111 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.asdcapi;
+
+import java.util.Properties;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AsdcApiSliClient {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(AsdcApiSliClient.class);
+
+ private SvcLogicService svcLogic = null;
+
+ public AsdcApiSliClient()
+ {
+ BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext();
+
+ // Get SvcLogicService reference
+ ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME);
+ if (sref != null)
+ {
+ svcLogic = (SvcLogicService) bctx.getService(sref);
+ }
+ else
+ {
+ LOG.warn("Cannot find service reference for "+SvcLogicService.NAME);
+
+ }
+ }
+
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
+ {
+ return(svcLogic.hasGraph(module, rpc, version, mode));
+ }
+
+
+ public Properties execute(String module, String rpc, String version, String mode, Properties parms)
+ throws SvcLogicException {
+
+
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Parameters passed to SLI");
+
+ for (Object key : parms.keySet()) {
+ String parmName = (String) key;
+ String parmValue = parms.getProperty(parmName);
+
+ LOG.debug(parmName+" = "+parmValue);
+
+ }
+ }
+
+ Properties respProps = svcLogic.execute(module, rpc, version, mode, parms);
+
+ 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"))) {
+
+ if (!respProps.containsKey("error-code")) {
+ respProps.setProperty("error-code", "500");
+ }
+ } else {
+ if (!respProps.containsKey("error-code")) {
+ respProps.setProperty("error-code", "200");
+ }
+ }
+
+
+ return (respProps);
+ }
+
+}
diff --git a/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java
new file mode 100644
index 00000000..240c939b
--- /dev/null
+++ b/asdcApi/provider/src/main/java/org/openecomp/sdnc/asdcapi/AsdcApiUtil.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 ONAP Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdnc.asdcapi;
+
+import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.ArtifactsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInput;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelUpdateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.VfLicenseModelVersionsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.sdnc.rev170201.vf.license.model.versions.VfLicenseModelVersionBuilder;
+
+public class AsdcApiUtil extends MdsalHelper {
+
+ static {
+
+ // Input objects
+
+ VfLicenseModelUpdateInput i13 = new VfLicenseModelUpdateInputBuilder().build();
+
+
+ // Other builders
+ ArtifactsBuilder b1 = new ArtifactsBuilder();
+
+ VfLicenseModelVersionsBuilder b14a = new VfLicenseModelVersionsBuilder();
+ VfLicenseModelVersionBuilder b26a = new VfLicenseModelVersionBuilder();
+
+
+ }
+}
diff --git a/asdcApi/provider/src/main/resources/initial/asdcApi-provider.xml b/asdcApi/provider/src/main/resources/initial/asdcApi-provider.xml
new file mode 100644
index 00000000..ab2da905
--- /dev/null
+++ b/asdcApi/provider/src/main/resources/initial/asdcApi-provider.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 ONAP Intellectual Property. All rights
+ reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<snapshot>
+ <configuration>
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+
+ <!-- This xmlns:prefix should match the namespace in the *-provider-impl.yang file
+ The prefix: inside type should match the prefix of the yang file. -->
+ <type xmlns:prefix="org:openecomp:sdnc:asdcapi:provider:impl">
+ prefix:asdcApi-provider-impl
+ </type>
+ <name>asdcApi-provider-impl</name>
+
+ <!-- The following sections contain bindings to services defined in the
+ *-provider-impl yang file. For example the rpc-registry is required
+ because we have a dependency (or augmentation) named "rpc-registry"
+ and which binds to the md-sa-binding-registry. If you remove those
+ dependencies from the yang file then you can remove them from here. -->
+ <rpc-registry>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+ <name>binding-rpc-broker</name>
+ </rpc-registry>
+
+ <data-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type>
+ <name>binding-data-broker</name>
+ </data-broker>
+
+ <notification-service>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
+ binding:binding-notification-service
+ </type>
+ <name>binding-notification-broker</name>
+ </notification-service>
+ </module>
+
+ </modules>
+ </data>
+
+ </configuration>
+
+ <!-- Required capabilities are basically a listing of all modules that need to be imported before
+ our service can be resolved. Capabilities for dependencies defined above are implied which is
+ why we do not have define a required capability for the data broker, for example. -->
+ <required-capabilities>
+ <capability>org:openecomp:sdnc:asdcapi:provider:impl?module=asdcApi-provider-impl&amp;revision=2014-05-23</capability>
+ </required-capabilities>
+
+</snapshot>
diff --git a/asdcApi/provider/src/main/yang/asdcApi-provider-impl.yang b/asdcApi/provider/src/main/yang/asdcApi-provider-impl.yang
new file mode 100755
index 00000000..94ee8836
--- /dev/null
+++ b/asdcApi/provider/src/main/yang/asdcApi-provider-impl.yang
@@ -0,0 +1,61 @@
+module asdcApi-provider-impl {
+
+ yang-version 1;
+ namespace "org:openecomp:sdnc:asdcapi:provider:impl";
+ prefix "asdcApi-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
+ asdcApi-provider impl implementation.";
+
+ revision "2014-05-23" {
+ description
+ "Initial revision.";
+ }
+
+ // This is the definition of the service implementation as a module identity.
+ identity asdcApi-provider-impl {
+ base config:module-type;
+
+ // Specifies the prefix for generated java classes.
+ config:java-name-prefix AsdcApiProvider;
+ }
+
+ // 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 asdcApi-provider-impl {
+ when "/config:modules/config:module/config:type = 'asdcApi-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;
+ }
+ }
+ }
+ }
+ }
+}