summaryrefslogtreecommitdiffstats
path: root/adaptors/mdsal-resource/provider
diff options
context:
space:
mode:
Diffstat (limited to 'adaptors/mdsal-resource/provider')
-rwxr-xr-xadaptors/mdsal-resource/provider/pom.xml81
-rw-r--r--adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java153
-rwxr-xr-xadaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProvider.java28
-rwxr-xr-xadaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java186
-rw-r--r--adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java147
-rw-r--r--adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java184
-rwxr-xr-xadaptors/mdsal-resource/provider/src/main/resources/IPV4_ADDRESS_POOL.csv9
-rwxr-xr-xadaptors/mdsal-resource/provider/src/main/resources/OSGI-INF/blueprint/mdsal-resource-blueprint.xml49
-rwxr-xr-xadaptors/mdsal-resource/provider/src/main/resources/VLAN_ID_POOL.csv22
-rw-r--r--adaptors/mdsal-resource/provider/src/main/resources/crtables.sql70
-rw-r--r--adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties27
-rwxr-xr-xadaptors/mdsal-resource/provider/src/main/resources/org/opendaylight/blueprint/mdsal-resource-blueprint.xml49
-rw-r--r--adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties26
-rw-r--r--adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResourceTest.java43
-rw-r--r--adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestConfigResource.java31
-rw-r--r--adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourcePropertiesProviderImpl.java64
-rw-r--r--adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestOperationalResource.java31
17 files changed, 1200 insertions, 0 deletions
diff --git a/adaptors/mdsal-resource/provider/pom.xml b/adaptors/mdsal-resource/provider/pom.xml
new file mode 100755
index 000000000..255812b55
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/pom.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.ccsdk.parent</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>2.1.0</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.onap.ccsdk.sli.adaptors</groupId>
+ <artifactId>mdsal-resource-provider</artifactId>
+ <version>1.1.1-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>ccsdk-sli-adaptors :: mdsal-resource :: ${project.artifactId}</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <ccsdk.sli.adaptors.version>${project.version}</ccsdk.sli.adaptors.version>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-core-artifacts</artifactId>
+ <version>${ccsdk.sli.core.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-common</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.ccsdk.sli.core</groupId>
+ <artifactId>sli-provider</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java
new file mode 100644
index 000000000..e2e9bc230
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java
@@ -0,0 +1,153 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+public class ConfigResource implements SvcLogicResource {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class);
+
+ private RestService restService;
+
+ public ConfigResource(MdsalResourcePropertiesProvider propProvider) {
+ LOG.info("Loading ConfigResource using property provider");
+ Properties props = propProvider.getProperties();
+
+ String sdncUser = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user", "admin");
+ String sdncPasswd = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd", "admin");
+ String sdncHost = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host", "localhost");
+ String sdncProtocol = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol", "https");
+ String sdncPort = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port", "8443");
+
+ restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML");
+ }
+
+ public ConfigResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd)
+ {
+ restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML");
+ }
+
+ public ConfigResource(RestService restService) {
+ this.restService = restService;
+ }
+
+ @Override
+ public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException
+ {
+ return(query(resource, false, null, key, prefix, null, null));
+ }
+
+ @Override
+ public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException
+ {
+ return(query(resource, false, null, key, prefix, null, null));
+ }
+
+ @Override
+ public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix,
+ String orderBy, SvcLogicContext ctx) throws SvcLogicException {
+ String module = resource;
+ StringBuffer restQuery = new StringBuffer();
+
+ String[] keyParts = key.split("/");
+ for (String keyPart : keyParts) {
+ if (restQuery.length() > 0) {
+ restQuery.append("/");
+ }
+ if (keyPart.startsWith("$")) {
+ restQuery.append(ctx.resolve(keyPart.substring(1)));
+ } else {
+ restQuery.append(keyPart);
+ }
+ }
+
+ String restQueryStr = restQuery.toString();
+ if ((restQueryStr.startsWith("'") && restQueryStr.endsWith("'")) ||
+ (restQueryStr.startsWith("\"") && restQueryStr.endsWith("\""))) {
+ restQueryStr = restQueryStr.substring(1, restQueryStr.length()-1);
+ }
+
+ String urlString = "restconf/config/" + module + ":" + restQueryStr;
+ LOG.info("Querying resource: " + resource + ". At URL: " + urlString);
+
+ Document results = restService.get(urlString);
+ if (results == null) {
+ return(QueryStatus.NOT_FOUND);
+ } else {
+ if (ctx != null) {
+ ctx.mergeDocument(prefix, results);
+ }
+ return(QueryStatus.SUCCESS);
+ }
+ }
+
+ @Override
+ public QueryStatus reserve(String resource, String select, String key, String prefix,
+ SvcLogicContext ctx) throws SvcLogicException {
+ return(QueryStatus.SUCCESS);
+
+ }
+
+ @Override
+ public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException {
+ return(QueryStatus.SUCCESS);
+ }
+
+ @Override
+ public QueryStatus delete(String arg0, String arg1, SvcLogicContext arg2)
+ throws SvcLogicException {
+ // TODO Auto-generated method stub
+ return(QueryStatus.SUCCESS);
+ }
+
+ @Override
+ public QueryStatus save(String arg0, boolean arg1, boolean localOnly, String arg2,
+ Map<String, String> arg3, String arg4, SvcLogicContext arg5)
+ throws SvcLogicException {
+ // TODO Auto-generated method stub
+ return(QueryStatus.SUCCESS);
+ }
+
+ @Override
+ public QueryStatus notify(String resource, String action, String key,
+ SvcLogicContext ctx) throws SvcLogicException {
+ return(QueryStatus.SUCCESS);
+ }
+
+
+ public QueryStatus update(String resource, String key,
+ Map<String, String> parms, String prefix, SvcLogicContext ctx)
+ throws SvcLogicException {
+ return(QueryStatus.SUCCESS);
+ }
+
+}
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProvider.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProvider.java
new file mode 100755
index 000000000..e433a4c13
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProvider.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * onap
+ * ================================================================================
+ * Copyright (C) 2016 - 2017 ONAP
+ * ================================================================================
+ * 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.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import java.util.Properties;
+
+public interface MdsalResourcePropertiesProvider {
+
+ public Properties getProperties();
+}
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java
new file mode 100755
index 000000000..e9e006f17
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java
@@ -0,0 +1,186 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * onap
+ * ================================================================================
+ * Copyright (C) 2016 - 2017 ONAP
+ * ================================================================================
+ * 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.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.onap.ccsdk.sli.core.sli.ConfigurationException;
+import org.onap.ccsdk.sli.core.utils.JREFileResolver;
+import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver;
+import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver;
+import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver;
+import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Responsible for determining the properties file to use and instantiating the
+ * <code>SqlResource</code> Service. The priority for properties file
+ * resolution is as follows:
+ *
+ * <ol>
+ * <li>A directory identified by the system environment variable
+ * <code>SDNC_CONFIG_DIR</code></li>
+ * <li>The default directory <code>DEFAULT_DBLIB_PROP_DIR</code></li>
+ * <li>A directory identified by the JRE argument
+ * <code>sql-resource.properties</code></li>
+ * <li>A <code>sql-resource.properties</code> file located in the karaf root
+ * directory</li>
+ * </ol>
+ */
+public class MdsalResourcePropertiesProviderImpl implements MdsalResourcePropertiesProvider {
+
+ private static final Logger LOG = LoggerFactory.getLogger(MdsalResourcePropertiesProviderImpl.class);
+
+ /**
+ * The name of the properties file for database configuration
+ */
+ private static final String MDSALRESOURCE_PROP_FILE_NAME = "mdsal-resource.properties";
+
+ /**
+ * A prioritized list of strategies for resolving sql-resource properties files.
+ */
+ private Vector<PropertiesFileResolver> mdsalResourcePropertiesFileResolvers = new Vector<>();
+
+ /**
+ * The configuration properties for the db connection.
+ */
+ private Properties properties;
+
+ /**
+ * Set up the prioritized list of strategies for resolving dblib properties
+ * files.
+ */
+ public MdsalResourcePropertiesProviderImpl() {
+ mdsalResourcePropertiesFileResolvers
+ .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable"));
+ mdsalResourcePropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory"));
+
+ mdsalResourcePropertiesFileResolvers.add(
+ new JREFileResolver("Using property file (3) from JRE argument", MdsalResourcePropertiesProviderImpl.class));
+ mdsalResourcePropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this));
+
+ // determines properties file as according to the priority described in the
+ // class header comment
+ final File propertiesFile = determinePropertiesFile(this);
+ if (propertiesFile != null) {
+ try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) {
+ properties = new Properties();
+ properties.load(fileInputStream);
+ } catch (final IOException e) {
+ LOG.error("Failed to load properties for file: {}", propertiesFile.toString(),
+ new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(),
+ e));
+ }
+ } else {
+ // Try to read properties as resource
+
+ InputStream propStr = getClass().getResourceAsStream("/" + MDSALRESOURCE_PROP_FILE_NAME);
+ if (propStr != null) {
+ properties = new Properties();
+ try {
+ properties.load(propStr);
+ propStr.close();
+ } catch (IOException e) {
+ properties = null;
+ }
+ }
+
+ }
+
+ if (properties == null) {
+ reportFailure("Missing configuration properties resource(3)", new ConfigurationException(
+ "Missing configuration properties resource(3): " + MDSALRESOURCE_PROP_FILE_NAME));
+ }
+ }
+
+ /**
+ * Extract svclogic config properties.
+ *
+ * @return the svclogic config properties
+ */
+ public Properties getProperties() {
+ return properties;
+ }
+
+ /**
+ * Reports the method chosen for properties resolution to the
+ * <code>Logger</code>.
+ *
+ * @param message
+ * Some user friendly message
+ * @param fileOptional
+ * The file location of the chosen properties file
+ * @return the file location of the chosen properties file
+ */
+ private static File reportSuccess(final String message, final Optional<File> fileOptional) {
+ if (fileOptional.isPresent()) {
+ final File file = fileOptional.get();
+ LOG.info("{} {}", message, file.getPath());
+ return file;
+ }
+ return null;
+ }
+
+ /**
+ * Reports fatal errors. This is the case in which no properties file could be
+ * found.
+ *
+ * @param message
+ * An appropriate fatal error message
+ * @param configurationException
+ * An exception describing what went wrong during resolution
+ */
+ private static void reportFailure(final String message, final ConfigurationException configurationException) {
+
+ LOG.error("{}", message, configurationException);
+ }
+
+ /**
+ * Determines the sql-resource properties file to use based on the following priority:
+ * <ol>
+ * <li>A directory identified by the system environment variable
+ * <code>SDNC_CONFIG_DIR</code></li>
+ * <li>The default directory <code>DEFAULT_DBLIB_PROP_DIR</code></li>
+ * <li>A directory identified by the JRE argument
+ * <code>mdsal-resource.properties</code></li>
+ * <li>A <code>sql-resource.properties</code> file located in the karaf root
+ * directory</li>
+ * </ol>
+ */
+ File determinePropertiesFile(final MdsalResourcePropertiesProviderImpl resourceProvider) {
+
+ for (final PropertiesFileResolver sliPropertiesFileResolver : mdsalResourcePropertiesFileResolvers) {
+ final Optional<File> fileOptional = sliPropertiesFileResolver.resolveFile(MDSALRESOURCE_PROP_FILE_NAME);
+ if (fileOptional.isPresent()) {
+ return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional);
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java
new file mode 100644
index 000000000..320878126
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java
@@ -0,0 +1,147 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+import java.util.Map;
+import java.util.Properties;
+
+public class OperationalResource implements SvcLogicResource {
+
+ private static final Logger LOG = LoggerFactory.getLogger(OperationalResource.class);
+
+ private RestService restService;
+
+ public OperationalResource(MdsalResourcePropertiesProvider propProvider) {
+ Properties props = propProvider.getProperties();
+
+ String sdncUser = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user", "admin");
+ String sdncPasswd = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd", "admin");
+ String sdncHost = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host", "localhost");
+ String sdncProtocol = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol", "https");
+ String sdncPort = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port", "8443");
+
+ restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML");
+ }
+
+ public OperationalResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd) {
+ restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML");
+ }
+
+ public OperationalResource(RestService restService) {
+ this.restService = restService;
+ }
+
+ @Override
+ public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException {
+ return (query(resource, false, null, key, prefix, null, null));
+ }
+
+ @Override
+ public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException {
+ return (query(resource, false, null, key, prefix, null, null));
+ }
+
+ @Override
+ public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix,
+ String orderBy, SvcLogicContext ctx) throws SvcLogicException {
+ String module = resource;
+ StringBuffer restQuery = new StringBuffer();
+
+ String[] keyParts = key.split("/");
+ for (String keyPart : keyParts) {
+ if (restQuery.length() > 0) {
+ restQuery.append("/");
+ }
+ if (keyPart.startsWith("$")) {
+ restQuery.append(ctx.resolve(keyPart.substring(1)));
+ } else {
+ restQuery.append(keyPart);
+ }
+ }
+
+ String restQueryStr = restQuery.toString();
+ if ((restQueryStr.startsWith("'") && restQueryStr.endsWith("'")) ||
+ (restQueryStr.startsWith("\"") && restQueryStr.endsWith("\""))) {
+ restQueryStr = restQueryStr.substring(1, restQueryStr.length() - 1);
+ }
+
+ String urlString = "restconf/operational/" + module + ":" + restQueryStr;
+ LOG.info("Querying resource: " + resource + ". At URL: " + urlString);
+
+ Document results = restService.get(urlString);
+
+ if (results == null) {
+ return (QueryStatus.NOT_FOUND);
+ } else {
+ if (ctx != null) {
+ ctx.mergeDocument(prefix, results);
+ }
+ return (QueryStatus.SUCCESS);
+ }
+ }
+
+ @Override
+ public QueryStatus reserve(String resource, String select, String key, String prefix,
+ SvcLogicContext ctx) throws SvcLogicException {
+ return (QueryStatus.SUCCESS);
+ }
+
+ @Override
+ public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException {
+ return (QueryStatus.SUCCESS);
+ }
+
+ @Override
+ public QueryStatus delete(String arg0, String arg1, SvcLogicContext arg2)
+ throws SvcLogicException {
+ // TODO Auto-generated method stub
+ return (QueryStatus.SUCCESS);
+ }
+
+ @Override
+ public QueryStatus save(String arg0, boolean arg1, boolean localOnly, String arg2,
+ Map<String, String> arg3, String arg4, SvcLogicContext arg5)
+ throws SvcLogicException {
+ // TODO Auto-generated method stub
+ return (QueryStatus.SUCCESS);
+ }
+
+ @Override
+ public QueryStatus notify(String resource, String action, String key,
+ SvcLogicContext ctx) throws SvcLogicException {
+ return (QueryStatus.SUCCESS);
+ }
+
+ public QueryStatus update(String resource, String key,
+ Map<String, String> parms, String prefix, SvcLogicContext ctx)
+ throws SvcLogicException {
+ return (QueryStatus.SUCCESS);
+ }
+
+}
diff --git a/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java
new file mode 100644
index 000000000..ebddc24ae
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java
@@ -0,0 +1,184 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import org.apache.commons.codec.binary.Base64;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+
+import javax.net.ssl.HostnameVerifier;
+import javax.net.ssl.HttpsURLConnection;
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.*;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.PasswordAuthentication;
+import java.net.URL;
+
+public class RestService {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class);
+ private String user;
+ private String passwd;
+ private String contentType;
+ private String accept;
+ private String protocol;
+ private String host;
+ private String port;
+
+ public RestService(String protocol, String host, String port, String user, String passwd, String accept, String contentType) {
+ this.protocol = protocol;
+ this.host = host;
+ this.port = port;
+ this.user = user;
+ this.passwd = passwd;
+ this.accept = accept;
+ this.contentType = contentType;
+ }
+
+ private HttpURLConnection getRestConnection(String urlString, String method) throws IOException {
+ URL sdncUrl = new URL(urlString);
+ Authenticator.setDefault(new SdncAuthenticator(user, passwd));
+
+ String authStr = user + ":" + passwd;
+ String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes()));
+
+ HttpURLConnection conn = (HttpURLConnection) sdncUrl.openConnection();
+ conn.addRequestProperty("Authentication", "Basic " + encodedAuthStr);
+ conn.setRequestMethod(method);
+ conn.setDoInput(true);
+ conn.setDoOutput(true);
+ conn.setUseCaches(false);
+
+ //Setting Accept header (doesn't dependent on Msg Body if present or not)
+ if ("XML".equalsIgnoreCase(accept)) {
+ conn.setRequestProperty("Accept", "application/xml");
+ } else {
+ conn.setRequestProperty("Accept", "application/json");
+ }
+
+ return (conn);
+ }
+
+ private Document send(String urlString, byte[] msgBytes, String method) {
+ Document response = null;
+ String fullUrl = protocol + "://" + host + ":" + port + "/" + urlString;
+ LOG.info("Sending REST {} to {}", method, fullUrl);
+
+ try {
+ HttpURLConnection conn = getRestConnection(fullUrl, method);
+ if (conn instanceof HttpsURLConnection) {
+ HostnameVerifier hostnameVerifier = (hostname, session) -> true;
+ ((HttpsURLConnection) conn).setHostnameVerifier(hostnameVerifier);
+ }
+
+ // Write message
+ if (msgBytes != null) {
+ LOG.info("Message body:\n{}", msgBytes);
+ conn.setRequestProperty("Content-Length", "" + msgBytes.length);
+
+ // Setting Content-Type header only if Msg Body is present
+ if ("XML".equalsIgnoreCase(contentType)) {
+ conn.setRequestProperty("Content-Type", "application/xml");
+ } else {
+ conn.setRequestProperty("Content-Type", "application/json");
+ }
+
+ DataOutputStream outStr = new DataOutputStream(conn.getOutputStream());
+ outStr.write(msgBytes);
+ outStr.close();
+ } else {
+ conn.setRequestProperty("Content-Length", "0");
+ }
+
+ // Read response
+ LOG.info("Response: {} {}", conn.getResponseCode(), conn.getResponseMessage());
+
+ BufferedReader respRdr;
+ if (conn.getResponseCode() < 300) {
+ respRdr = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+ } else {
+ respRdr = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
+ }
+
+ StringBuffer respBuff = new StringBuffer();
+ String respLn;
+ while ((respLn = respRdr.readLine()) != null) {
+ respBuff.append(respLn + "\n");
+ }
+ respRdr.close();
+
+ String respString = respBuff.toString();
+ LOG.info("Response body :\n{}", respString);
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+
+ response = db.parse(new ByteArrayInputStream(respString.getBytes()));
+
+ } catch (Exception e) {
+ LOG.error("Caught exception executing REST command", e);
+ }
+
+ return (response);
+ }
+
+ public Document get(String urlString) {
+ return (send(urlString, null, "GET"));
+ }
+
+ public Document delete(String urlString) {
+ return (send(urlString, null, "DELETE"));
+ }
+
+ public Document post(String urlString, byte[] msgBytes) {
+ return (send(urlString, msgBytes, "POST"));
+ }
+
+ public Document put(String urlString, byte[] msgBytes) {
+ return (send(urlString, msgBytes, "PUT"));
+ }
+
+
+ private class SdncAuthenticator extends Authenticator {
+ private String user;
+ private String passwd;
+
+ SdncAuthenticator(String user, String passwd) {
+ this.user = user;
+ this.passwd = passwd;
+ }
+
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(user, passwd.toCharArray());
+ }
+
+ }
+
+}
diff --git a/adaptors/mdsal-resource/provider/src/main/resources/IPV4_ADDRESS_POOL.csv b/adaptors/mdsal-resource/provider/src/main/resources/IPV4_ADDRESS_POOL.csv
new file mode 100755
index 000000000..30ce117bc
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/resources/IPV4_ADDRESS_POOL.csv
@@ -0,0 +1,9 @@
+"192.168.1.2","OAM","AVAILABLE"
+"192.168.1.3","OAM","AVAILABLE"
+"192.168.1.4","OAM","AVAILABLE"
+"192.168.1.5","OAM","AVAILABLE"
+"192.168.1.6","OAM","AVAILABLE"
+"192.168.1.7","OAM","AVAILABLE"
+"192.168.1.8","OAM","AVAILABLE"
+"192.168.1.9","OAM","AVAILABLE"
+"192.168.1.10","OAM","AVAILABLE"
diff --git a/adaptors/mdsal-resource/provider/src/main/resources/OSGI-INF/blueprint/mdsal-resource-blueprint.xml b/adaptors/mdsal-resource/provider/src/main/resources/OSGI-INF/blueprint/mdsal-resource-blueprint.xml
new file mode 100755
index 000000000..9c691263c
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/resources/OSGI-INF/blueprint/mdsal-resource-blueprint.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 - 2018 AT&T 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=========================================================
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <bean id="propProvider" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.MdsalResourcePropertiesProviderImpl" />
+
+
+ <bean id="configResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource">
+ <argument ref="propProvider"/>
+ </bean>
+
+ <bean id="operResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource">
+ <argument ref="propProvider"/>
+ </bean>
+
+ <service ref="configResourceInstance">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource</value>
+ </interfaces>
+ </service>
+
+ <service ref="operResourceInstance">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource</value>
+ </interfaces>
+ </service>
+</blueprint>
diff --git a/adaptors/mdsal-resource/provider/src/main/resources/VLAN_ID_POOL.csv b/adaptors/mdsal-resource/provider/src/main/resources/VLAN_ID_POOL.csv
new file mode 100755
index 000000000..6c4b0f775
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/resources/VLAN_ID_POOL.csv
@@ -0,0 +1,22 @@
+"1100","IPAG","AVAILABLE",NULL
+"1101","IPAG","AVAILABLE",NULL
+"1102","IPAG","AVAILABLE",NULL
+"1103","IPAG","AVAILABLE",NULL
+"1104","IPAG","AVAILABLE",NULL
+"1105","IPAG","AVAILABLE",NULL
+"1106","IPAG","AVAILABLE",NULL
+"1107","IPAG","AVAILABLE",NULL
+"1108","IPAG","AVAILABLE",NULL
+"1109","IPAG","AVAILABLE",NULL
+"1110","IPAG","AVAILABLE",NULL
+"1200","VPE","AVAILABLE",NULL
+"1201","VPE","AVAILABLE",NULL
+"1202","VPE","AVAILABLE",NULL
+"1203","VPE","AVAILABLE",NULL
+"1204","VPE","AVAILABLE",NULL
+"1205","VPE","AVAILABLE",NULL
+"1206","VPE","AVAILABLE",NULL
+"1207","VPE","AVAILABLE",NULL
+"1208","VPE","AVAILABLE",NULL
+"1209","VPE","AVAILABLE",NULL
+"1210","VPE","AVAILABLE",NULL
diff --git a/adaptors/mdsal-resource/provider/src/main/resources/crtables.sql b/adaptors/mdsal-resource/provider/src/main/resources/crtables.sql
new file mode 100644
index 000000000..5ee75f4e4
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/resources/crtables.sql
@@ -0,0 +1,70 @@
+---
+-- ============LICENSE_START=======================================================
+-- openECOMP : SDN-C
+-- ================================================================================
+-- Copyright (C) 2017 AT&T 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=========================================================
+---
+
+CREATE TABLE sdnctl.VNF (
+vnf_id varchar(80) NOT NULL,
+vnf_name varchar(80) NOT NULL,
+vnf_type varchar(10) NOT NULL,
+orchestration_status varchar(20),
+heat_stack_id varchar(80),
+mso_catalog_key varchar(80),
+availability_zone varchar(80),
+aic_site_id varchar(80),
+oam_ipv4_address varchar(20),
+CONSTRAINT P_VNF PRIMARY KEY(vnf_id));
+
+CREATE TABLE sdnctl.VNF_NETWORK_CONNECTION (
+connection_uuid varchar(80) NOT NULL,
+vnf_id varchar(80) NOT NULL,
+connection_id varchar(80),
+connection_type varchar(20),
+neutron_network_id varchar(80),
+neutron_network_name varchar(80),
+orchestration_status varchar(20),
+switch_id varchar(40),
+heat_stack_id varchar(80),
+mso_catalog_key varchar(80),
+provider_network varchar(80),
+port_group_id varchar(80),
+port_group_name varchar(80),
+CONSTRAINT P_NETWORK_CONNECTION PRIMARY KEY(connection_uuid));
+
+CREATE TABLE sdnctl.VNF_NETWORK_CONNECTION_VLAN (
+vlan_uuid varchar(80) NOT NULL,
+vlan_id numeric(4) NOT NULL,
+vlan_type varchar(5) NOT NULL,
+connection_uuid varchar(80),
+CONSTRAINT P_VNF_NETWORK_CONNECTION_VLAN PRIMARY KEY(vlan_uuid));
+
+CREATE TABLE sdnctl.VLAN_ID_POOL (
+vlan_id numeric(4) NOT NULL,
+universe varchar(40) NOT NULL,
+status varchar(40) NOT NULL,
+vlan_uuid varchar(80),
+CONSTRAINT P_VLAN_ID_POOL PRIMARY KEY(vlan_id,universe));
+
+CREATE TABLE sdnctl.IPV4_ADDRESS_POOL (
+ipv4_addr varchar(20) NOT NULL,
+universe varchar(40) NOT NULL,
+status varchar(40) NOT NULL,
+CONSTRAINT P_IPV4_ADDRESS_POOL PRIMARY KEY(ipv4_addr, universe));
+
+
diff --git a/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties b/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties
new file mode 100644
index 000000000..47c8ebf77
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties
@@ -0,0 +1,27 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user=admin
+org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U
+org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host=localhost
+org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol=http
+org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port=8181
+
diff --git a/adaptors/mdsal-resource/provider/src/main/resources/org/opendaylight/blueprint/mdsal-resource-blueprint.xml b/adaptors/mdsal-resource/provider/src/main/resources/org/opendaylight/blueprint/mdsal-resource-blueprint.xml
new file mode 100755
index 000000000..9c691263c
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/resources/org/opendaylight/blueprint/mdsal-resource-blueprint.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ openECOMP : SDN-C
+ ================================================================================
+ Copyright (C) 2017 - 2018 AT&T 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=========================================================
+ -->
+
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <bean id="propProvider" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.MdsalResourcePropertiesProviderImpl" />
+
+
+ <bean id="configResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource">
+ <argument ref="propProvider"/>
+ </bean>
+
+ <bean id="operResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource">
+ <argument ref="propProvider"/>
+ </bean>
+
+ <service ref="configResourceInstance">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource</value>
+ </interfaces>
+ </service>
+
+ <service ref="operResourceInstance">
+ <interfaces>
+ <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource</value>
+ </interfaces>
+ </service>
+</blueprint>
diff --git a/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties b/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties
new file mode 100644
index 000000000..0abadc5c8
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties
@@ -0,0 +1,26 @@
+###
+# ============LICENSE_START=======================================================
+# openECOMP : SDN-C
+# ================================================================================
+# Copyright (C) 2017 AT&T 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=========================================================
+###
+
+org.onap.ccsdk.sli.adaptors.dbtype = jdbc
+org.onap.ccsdk.sli.adaptors.jdbc.url = jdbc:mysql://dbhost:3306/sdnctl
+org.onap.ccsdk.sli.adaptors.jdbc.database = sdnctl
+org.onap.ccsdk.sli.adaptors.jdbc.user = sdnctl
+org.onap.ccsdk.sli.adaptors.jdbc.password = gamma
diff --git a/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResourceTest.java b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResourceTest.java
new file mode 100644
index 000000000..f5b0bcf0c
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResourceTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T 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.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+
+import static org.junit.Assert.assertEquals;
+
+public class ConfigResourceTest {
+ ConfigResource configResource = new ConfigResource("http", "local",
+ "10001", "admin",
+ "password");
+
+ @Test
+ public void isAvailableNegativeTest() throws SvcLogicException {
+ SvcLogicContext ctx = new SvcLogicContext();
+ assertEquals(QueryStatus.NOT_FOUND, configResource.isAvailable
+ ("xyz", "key", "prefix", ctx));
+ }
+}
+
diff --git a/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestConfigResource.java b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestConfigResource.java
new file mode 100644
index 000000000..80563b96b
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestConfigResource.java
@@ -0,0 +1,31 @@
+package org.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import junit.framework.TestCase;
+
+import static org.mockito.Mockito.mock;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import static org.junit.Assert.assertNotNull;
+
+public class TestConfigResource extends TestCase {
+
+ public void test() throws Exception {
+
+ RestService restService = mock(RestService.class);
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ ConfigResource res = new ConfigResource(restService);
+
+ res.delete("my-resource", null, ctx);
+ res.notify("my-resource", "action", "key", ctx);
+ res.query("my-resource", false, "my-select", "mykey", "pfx", null, ctx);
+ res.release("my-resource", "mykey", ctx);
+ res.reserve("my-resource", "my-select", "mykey", "pfx", ctx);
+ res.exists("my-resource", "mykey", "pfx", ctx);
+ res.isAvailable("my-resource", "mykey", "pfx", ctx);
+ res.save("resource", false, false, null, null, null, ctx);
+ res.update("my-resource", "mykey", null, "pfx", ctx);
+ assertNotNull(res);
+ }
+
+}
diff --git a/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourcePropertiesProviderImpl.java b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourcePropertiesProviderImpl.java
new file mode 100644
index 000000000..7f05d1e5f
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourcePropertiesProviderImpl.java
@@ -0,0 +1,64 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2018 Samsung. 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.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Properties;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class TestMdsalResourcePropertiesProviderImpl {
+
+ MdsalResourcePropertiesProviderImpl mdsal;
+
+ @Before
+ public void setup() {
+ mdsal = new MdsalResourcePropertiesProviderImpl();
+ }
+
+
+ @Test
+ public void testGetProperties() {
+ Properties prop = mdsal.getProperties();
+
+ System.out.println("All Default Properties : " + prop);
+
+ assertEquals("localhost",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host"));
+ assertEquals("Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd"));
+ assertEquals("http",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol"));
+ assertEquals("8181",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port"));
+ assertEquals("admin",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user"));
+ }
+
+
+ @Test
+ public void testGetPropertie() throws IllegalStateException, IllegalArgumentException {
+ MdsalResourcePropertiesProviderImpl test = new MdsalResourcePropertiesProviderImpl();
+
+ mdsal.determinePropertiesFile(test);
+ assertNotNull(test);
+
+ }
+}
diff --git a/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestOperationalResource.java b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestOperationalResource.java
new file mode 100644
index 000000000..2e9798df1
--- /dev/null
+++ b/adaptors/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestOperationalResource.java
@@ -0,0 +1,31 @@
+package org.onap.ccsdk.sli.adaptors.resource.mdsal;
+
+import static org.mockito.Mockito.mock;
+
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
+
+public class TestOperationalResource extends TestCase {
+
+
+ public void test() throws Exception {
+
+ RestService restService = mock(RestService.class);
+ SvcLogicContext ctx = new SvcLogicContext();
+
+ OperationalResource res = new OperationalResource(restService);
+
+ res.delete("my-resource", null, ctx);
+ res.notify("my-resource", "action", "key", ctx);
+ res.query("my-resource", false, "my-select", "mykey", "pfx", null, ctx);
+ res.release("my-resource", "mykey", ctx);
+ res.reserve("my-resource", "my-select", "mykey", "pfx", ctx);
+ res.exists("my-resource", "mykey", "pfx", ctx);
+ res.isAvailable("my-resource", "mykey", "pfx", ctx);
+ res.save("resource", false, false, null, null, null, ctx);
+ res.update("my-resource", "mykey", null, "pfx", ctx);
+ assertNotNull(restService);
+ }
+}