diff options
author | Dan Timoney <dtimoney@att.com> | 2021-02-17 15:25:45 -0500 |
---|---|---|
committer | Dan Timoney <dtimoney@att.com> | 2021-02-18 16:05:55 -0500 |
commit | 69e393da4cce52a0491fffff2dc81fbe59aeca08 (patch) | |
tree | 404cc750fa69ba2a89c7a2fce921da34db5edda4 /adaptors | |
parent | 56c27daf1656fd6436f8c818c771cf803079e1ea (diff) |
Add new EnvProperties class
Added new class EnvProperties, which extends java.util.Properties
and supports property values containing embedded environment
variable references. Updated code to use this class to load
svclogic.properties, and updated dmaap listener to use
that class to load dmaap listener configuration.
Issue-ID: SDNC-1482
Signed-off-by: Dan Timoney <dtimoney@att.com>
Change-Id: I7538b719631d8c10c27d059aeb4f70ce92760ebd
Diffstat (limited to 'adaptors')
16 files changed, 50 insertions, 41 deletions
diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java index 9facab82c..b38e75195 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIRequest.java @@ -53,6 +53,7 @@ import java.util.TreeSet; import org.apache.commons.lang.StringUtils; import org.onap.aai.inventory.v21.GenericVnf; import org.onap.ccsdk.sli.adaptors.aai.data.AAIDatum; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -194,7 +195,7 @@ public abstract class AAIRequest { try { Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8); - Properties properties = new Properties(); + Properties properties = new EnvProperties(); properties.load(reader); LOG.info("loaded " + properties.size()); diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java index 4d51550a3..747688746 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIService.java @@ -81,6 +81,7 @@ import org.onap.ccsdk.sli.core.sli.MetricLogger; 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.utils.common.EnvProperties; import org.onap.aai.inventory.v21.GenericVnf; import org.onap.aai.inventory.v21.PhysicalLink; import org.onap.aai.inventory.v21.ResultData; @@ -322,7 +323,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe } private static Properties getProperties(URL url) { - Properties properties = new Properties(); + Properties properties = new EnvProperties(); try { properties.load(url.openStream()); } catch (IOException exc) { @@ -491,7 +492,7 @@ public class AAIService extends AAIDeclarations implements AAIClient, SvcLogicRe } InputStream is = null; - Properties props = new Properties(); + Properties props = new EnvProperties(); try { if(LOG.isDebugEnabled()) diff --git a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java index 743f975b6..edc2e850d 100755 --- a/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java +++ b/adaptors/aai-service/provider/src/main/java/org/onap/ccsdk/sli/adaptors/aai/AAIServiceProvider.java @@ -37,6 +37,7 @@ import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; import org.onap.ccsdk.sli.core.utils.common.BundleContextFileResolver; import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -110,7 +111,7 @@ public class AAIServiceProvider implements UtilsProvider { final File propertiesFile = determinePropertiesFile(); if (propertiesFile != null) { try(FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); if(properties.containsKey(AAICLIENT_PROPERTY_NAME)) { diff --git a/adaptors/aai-service/provider/src/main/resources/aaiclient.properties b/adaptors/aai-service/provider/src/main/resources/aaiclient.properties index 979537f8e..3fd79d0c9 100755 --- a/adaptors/aai-service/provider/src/main/resources/aaiclient.properties +++ b/adaptors/aai-service/provider/src/main/resources/aaiclient.properties @@ -27,11 +27,11 @@ # Certificate keystore and truststore # org.onap.ccsdk.sli.adaptors.aai.ssl.trust=/opt/onap/ccsdk/data/stores/truststore.onap.client.jks -org.onap.ccsdk.sli.adaptors.aai.ssl.trust.psswd=adminadmin +org.onap.ccsdk.sli.adaptors.aai.ssl.trust.psswd=${AAI_TRUSTSTORE_PASSWORD:-adminadmin}` org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=true -org.onap.ccsdk.sli.adaptors.aai.client.name=SDNC -org.onap.ccsdk.sli.adaptors.aai.client.psswd=SDNC +org.onap.ccsdk.sli.adaptors.aai.client.name=${AAI_CLIENT_NAME:-SDNC} +org.onap.ccsdk.sli.adaptors.aai.client.psswd=${AAI_CLIENT_PASSWORD:-SDNC} org.onap.ccsdk.sli.adaptors.aai.application=CCSDK # diff --git a/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java b/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java index 482aaf8e5..36eec6a4b 100755 --- a/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java +++ b/adaptors/ansible-adapter/ansible-adapter-bundle/src/main/java/org/onap/ccsdk/sli/adaptors/ansible/impl/AnsibleAdapterPropertiesProviderImpl.java @@ -33,6 +33,7 @@ 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.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,7 @@ public class AnsibleAdapterPropertiesProviderImpl implements AnsibleAdapterPrope final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -101,7 +102,7 @@ public class AnsibleAdapterPropertiesProviderImpl implements AnsibleAdapterPrope InputStream propStr = getClass().getResourceAsStream("/" + ANSIBLEADAPTER_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); 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 index e9e006f17..eee5f099f 100755 --- 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 @@ -33,6 +33,7 @@ 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.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,7 @@ public class MdsalResourcePropertiesProviderImpl implements MdsalResourcePropert final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -101,7 +102,7 @@ public class MdsalResourcePropertiesProviderImpl implements MdsalResourcePropert InputStream propStr = getClass().getResourceAsStream("/" + MDSALRESOURCE_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); diff --git a/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties b/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties index 47c8ebf77..4e348b3c8 100644 --- a/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties +++ b/adaptors/mdsal-resource/provider/src/main/resources/mdsal-resource.properties @@ -19,8 +19,8 @@ # ============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-user=${ODL_USER:-admin} +org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd=${ODL_PASSWORD:-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/svclogic.properties b/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties index 0abadc5c8..2c91a05d0 100644 --- a/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties +++ b/adaptors/mdsal-resource/provider/src/main/resources/svclogic.properties @@ -20,7 +20,7 @@ ### 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 +org.onap.ccsdk.sli.adaptors.jdbc.url = jdbc:mysql://dbhost:3306/${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.database = ${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.user = ${MYSQL_USER} +org.onap.ccsdk.sli.adaptors.jdbc.password = ${MYSQL_PASSWORD} diff --git a/adaptors/netbox-client/provider/pom.xml b/adaptors/netbox-client/provider/pom.xml index 483e80868..93eedd92d 100644 --- a/adaptors/netbox-client/provider/pom.xml +++ b/adaptors/netbox-client/provider/pom.xml @@ -22,7 +22,7 @@ <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> <version>2.1.1-SNAPSHOT</version> - <relativePath/> + <relativePath /> </parent> <groupId>org.onap.ccsdk.sli.adaptors</groupId> @@ -33,15 +33,15 @@ <name>ccsdk-sli-adaptors :: netbox-client :: ${project.artifactId}</name> <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.onap.ccsdk.sli.core</groupId> - <artifactId>sli-core-artifacts</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sli-core-artifacts</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> </dependencyManagement> <dependencies> diff --git a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java index 9b4751e64..643a2dbed 100644 --- a/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java +++ b/adaptors/netbox-client/provider/src/main/java/org/onap/ccsdk/sli/adaptors/netbox/property/NetboxProperties.java @@ -20,6 +20,8 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.Properties; + +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -52,7 +54,7 @@ public class NetboxProperties { } private void loadProps() { - properties = new Properties(); + properties = new EnvProperties(); // Try to load config from dir final String ccsdkConfigDir = System.getProperty(PROPERTIES_DIR_KEY, DEFAULT_PROPERTIES_DIR) + "/" + NETBOX_PROPERTY_FILE_NAME; diff --git a/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java b/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java index 7c9f6f161..f55390c39 100755 --- a/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java +++ b/adaptors/sql-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/sql/SqlResourcePropertiesProviderImpl.java @@ -33,6 +33,7 @@ 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.EnvProperties; import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -89,7 +90,7 @@ public class SqlResourcePropertiesProviderImpl implements SqlResourcePropertiesP final File propertiesFile = determinePropertiesFile(this); if (propertiesFile != null) { try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); + properties = new EnvProperties(); properties.load(fileInputStream); } catch (final IOException e) { LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), @@ -101,7 +102,7 @@ public class SqlResourcePropertiesProviderImpl implements SqlResourcePropertiesP InputStream propStr = getClass().getResourceAsStream("/" + SQLRESOURCE_PROP_FILE_NAME); if (propStr != null) { - properties = new Properties(); + properties = new EnvProperties(); try { properties.load(propStr); propStr.close(); diff --git a/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties b/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties index ac32f7734..0e3714eb6 100755 --- a/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties +++ b/adaptors/sql-resource/provider/src/main/resources/sql-resource.properties @@ -19,5 +19,5 @@ # ============LICENSE_END========================================================= ### -org.openecomp.sdnc.resource.sql.cryptkey=QtfJMKggVk +org.onap.sdnc.resource.sql.cryptkey=${SQL_CRYPTKEY:-duMmyCrYptkEy} diff --git a/adaptors/sql-resource/provider/src/main/resources/svclogic.properties b/adaptors/sql-resource/provider/src/main/resources/svclogic.properties index 18718b869..65f3b2315 100644 --- a/adaptors/sql-resource/provider/src/main/resources/svclogic.properties +++ b/adaptors/sql-resource/provider/src/main/resources/svclogic.properties @@ -21,10 +21,10 @@ org.onap.ccsdk.sli.adaptors.dbtype=jdbc org.onap.ccsdk.sli.adaptors.jdbc.hosts=sdnctldb01,sdnctldb02 -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 +org.onap.ccsdk.sli.adaptors.jdbc.url=jdbc:mysql://DBHOST:3306/${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.database=${MYSQL_DATABASE} +org.onap.ccsdk.sli.adaptors.jdbc.user=${MYSQL_USER} +org.onap.ccsdk.sli.adaptors.jdbc.password=${MYSQL_PASSWORD} org.onap.ccsdk.sli.adaptors.jdbc.connection.name=sdnctldb01 org.onap.ccsdk.sli.adaptors.jdbc.connection.timeout=50 diff --git a/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java b/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java index 2863c6c96..4bf991e22 100755 --- a/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java +++ b/adaptors/sql-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/sql/ITCaseSqlResource.java @@ -29,6 +29,7 @@ import java.util.Properties; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus; +import org.onap.ccsdk.sli.core.utils.common.EnvProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,7 +46,7 @@ public class ITCaseSqlResource extends TestCase { public void testExists() throws Exception { - Properties props = new Properties(); + Properties props = new EnvProperties(); InputStream propStr = getClass().getResourceAsStream("/svclogic.properties"); if (propStr == null) { fail("src/test/resources/svclogic.properties missing"); diff --git a/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties b/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties index ac32f7734..0e3714eb6 100755 --- a/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties +++ b/adaptors/sql-resource/provider/src/test/resources/sql-resource.properties @@ -19,5 +19,5 @@ # ============LICENSE_END========================================================= ### -org.openecomp.sdnc.resource.sql.cryptkey=QtfJMKggVk +org.onap.sdnc.resource.sql.cryptkey=${SQL_CRYPTKEY:-duMmyCrYptkEy} diff --git a/adaptors/sql-resource/provider/src/test/resources/svclogic.properties b/adaptors/sql-resource/provider/src/test/resources/svclogic.properties index 6504e1aec..80c025359 100644 --- a/adaptors/sql-resource/provider/src/test/resources/svclogic.properties +++ b/adaptors/sql-resource/provider/src/test/resources/svclogic.properties @@ -21,11 +21,11 @@ org.onap.ccsdk.sli.dbtype=jdbc org.onap.ccsdk.sli.jdbc.hosts=sdnctldb01 -org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/sdnctl +org.onap.ccsdk.sli.jdbc.url=jdbc:mysql://dbhost:3306/${MYSQL_DATABASE} org.onap.ccsdk.sli.jdbc.driver=org.mariadb.jdbc.Driver -org.onap.ccsdk.sli.jdbc.database=sdnctl -org.onap.ccsdk.sli.jdbc.user=sdnctl -org.onap.ccsdk.sli.jdbc.password=gamma +org.onap.ccsdk.sli.jdbc.database=${MYSQL_DATABASE} +org.onap.ccsdk.sli.jdbc.user=${MYSQL_USER} +org.onap.ccsdk.sli.jdbc.password=${MYSQL_PASSWORD} org.onap.ccsdk.sli.jdbc.connection.name=sdnctldb01 org.onap.ccsdk.sli.jdbc.connection.timeout=50 org.onap.ccsdk.sli.jdbc.request.timeout=100 |