From 7dbb6441c95aa5691a59dc918f864b4bf4e2e2ed Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Tue, 18 Jul 2017 20:35:53 -0400 Subject: [CCSDK-6] Populate seed code Add seed code for sli/plugins repository Changed groupId to org.onap.ccsdk.sli.plugins Updated to compile against CCSDK version of SLI Change-Id: Ib392530ea79b8544087692964bd65179896aa595 Signed-off-by: Dan Timoney --- properties-node/.gitignore | 34 +++++ properties-node/features/pom.xml | 135 ++++++++++++++++++++ .../features/src/main/resources/features.xml | 39 ++++++ properties-node/installer/pom.xml | 139 +++++++++++++++++++++ .../src/assembly/assemble_installer_zip.xml | 59 +++++++++ .../src/assembly/assemble_mvnrepo_zip.xml | 49 ++++++++ .../src/main/resources/scripts/install-feature.sh | 40 ++++++ properties-node/pom.xml | 43 +++++++ properties-node/provider/pom.xml | 89 +++++++++++++ .../org/openecomp/sdnc/prop/PropertiesNode.java | 97 ++++++++++++++ .../META-INF/spring/properties-node-context.xml | 32 +++++ .../spring/properties-node-osgi-context.xml | 32 +++++ 12 files changed, 788 insertions(+) create mode 100755 properties-node/.gitignore create mode 100755 properties-node/features/pom.xml create mode 100644 properties-node/features/src/main/resources/features.xml create mode 100755 properties-node/installer/pom.xml create mode 100644 properties-node/installer/src/assembly/assemble_installer_zip.xml create mode 100644 properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 properties-node/installer/src/main/resources/scripts/install-feature.sh create mode 100755 properties-node/pom.xml create mode 100755 properties-node/provider/pom.xml create mode 100644 properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java create mode 100644 properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml create mode 100644 properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml (limited to 'properties-node') diff --git a/properties-node/.gitignore b/properties-node/.gitignore new file mode 100755 index 00000000..b73caf31 --- /dev/null +++ b/properties-node/.gitignore @@ -0,0 +1,34 @@ +#####standard .git ignore entries##### + +## IDE Specific Files ## +org.eclipse.core.resources.prefs +.classpath +.project +.settings +.idea +.externalToolBuilders +maven-eclipse.xml +workspace + +## Compilation Files ## +*.class +**/target +target +target-ide +MANIFEST.MF + +## Misc Ignores (OS specific etc) ## +bin/ +dist +*~ +*.ipr +*.iml +*.iws +classes +out/ +.DS_STORE +.metadata + +## Folders which contain auto generated source code ## +yang-gen-config +yang-gen-sal diff --git a/properties-node/features/pom.xml b/properties-node/features/pom.xml new file mode 100755 index 00000000..159ac474 --- /dev/null +++ b/properties-node/features/pom.xml @@ -0,0 +1,135 @@ + + + 4.0.0 + + properties-node + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + properties-node-features + Properties Node - Features + + jar + + + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + + commons-lang + commons-lang + 2.6 + compile + + + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml + + runtime + + + + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/properties-node/features/src/main/resources/features.xml b/properties-node/features/src/main/resources/features.xml new file mode 100644 index 00000000..e89b333e --- /dev/null +++ b/properties-node/features/src/main/resources/features.xml @@ -0,0 +1,39 @@ + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + sdnc-sli + spring + spring-dm + mvn:org.openecomp.sdnc.plugins/properties-node-provider/${project.version} + + + + diff --git a/properties-node/installer/pom.xml b/properties-node/installer/pom.xml new file mode 100755 index 00000000..5749a9b9 --- /dev/null +++ b/properties-node/installer/pom.xml @@ -0,0 +1,139 @@ + + + 4.0.0 + + properties-node + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + + properties-node-installer + Properties node - Karaf Installer + pom + + + sdnc-properties-node + sdnc-properties-node + mvn:org.onap.ccsdk.sli.plugins/properties-node-features/${project.version}/xml/features + false + + + + + + org.onap.ccsdk.sli.plugins + properties-node-features + ${project.version} + features + xml + + + * + * + + + + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + + + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk.sli + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + + + diff --git a/properties-node/installer/src/assembly/assemble_installer_zip.xml b/properties-node/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 00000000..e278872a --- /dev/null +++ b/properties-node/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,59 @@ + + + + + + installer_zip + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 00000000..1edacdb6 --- /dev/null +++ b/properties-node/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,49 @@ + + + + + + mvnrepo_zip + + zip + + + + false + + + + target/assembly/ + . + + + + + + + + diff --git a/properties-node/installer/src/main/resources/scripts/install-feature.sh b/properties-node/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 00000000..9a47d222 --- /dev/null +++ b/properties-node/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +### +# ============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========================================================= +### + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/properties-node/pom.xml b/properties-node/pom.xml new file mode 100755 index 00000000..8d6af7c5 --- /dev/null +++ b/properties-node/pom.xml @@ -0,0 +1,43 @@ + + + + org.onap.ccsdk.sli.plugins + sdnc-plugins + 0.0.1-SNAPSHOT + + + 4.0.0 + pom + + org.onap.ccsdk.sli.plugins + properties-node + 0.0.1-SNAPSHOT + + Properties Node + This is an implementation of DG Execute Node that reads property file and + puts the properties in the DG context + + + + + org.onap.ccsdk.sli.plugins + properties-node-features + features + xml + ${project.version} + + + org.onap.ccsdk.sli.plugins + properties-node-provider + ${project.version} + + + + + + provider + features + installer + + + diff --git a/properties-node/provider/pom.xml b/properties-node/provider/pom.xml new file mode 100755 index 00000000..43369adf --- /dev/null +++ b/properties-node/provider/pom.xml @@ -0,0 +1,89 @@ + + + 4.0.0 + + org.onap.ccsdk.sli.plugins + properties-node + 0.0.1-SNAPSHOT + + org.onap.ccsdk.sli.plugins + 0.0.1-SNAPSHOT + properties-node-provider + bundle + Properties Node - Provider + http://maven.apache.org + + UTF-8 + + + + junit + junit + test + + + org.springframework + spring-test + ${spring.version} + test + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + compile + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + org.onap.ccsdk.sli.prop + org.onap.ccsdk.sli.prop + * + + + + + + + + + + + + diff --git a/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java b/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java new file mode 100644 index 00000000..9856b194 --- /dev/null +++ b/properties-node/provider/src/main/java/org/openecomp/sdnc/prop/PropertiesNode.java @@ -0,0 +1,97 @@ +/*- + * ============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.prop; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +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.SvcLogicJavaPlugin; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class PropertiesNode implements SvcLogicJavaPlugin { + + private static final Logger log = LoggerFactory.getLogger(PropertiesNode.class); + + public void readProperties(Map paramMap, SvcLogicContext ctx) throws SvcLogicException { + String fileName = parseParam(paramMap, "fileName", true, null); + String contextPrefix = parseParam(paramMap, "contextPrefix", false, null); + + try { + Properties pp = new Properties(); + InputStream in = new FileInputStream(fileName); + pp.load(in); + for (Object key : pp.keySet()) { + String pfx = contextPrefix != null ? contextPrefix + '.' : ""; + String name = (String) key; + String value = pp.getProperty(name); + if (value != null && value.trim().length() > 0) { + ctx.setAttribute(pfx + name, value.trim()); + log.info("+++ " + pfx + name + ": [" + value + "]"); + } + } + } catch (IOException e) { + throw new SvcLogicException("Cannot read property file: " + fileName + ": " + e.getMessage(), e); + } + } + + private String parseParam(Map paramMap, String name, boolean required, String def) + throws SvcLogicException { + String s = paramMap.get(name); + + if (s == null || s.trim().length() == 0) { + if (!required) + return def; + throw new SvcLogicException("Parameter " + name + " is required in PropertiesNode"); + } + + s = s.trim(); + String value = ""; + int i = 0; + int i1 = s.indexOf('%'); + while (i1 >= 0) { + int i2 = s.indexOf('%', i1 + 1); + if (i2 < 0) + throw new SvcLogicException("Cannot parse parameter " + name + ": " + s + ": no matching %"); + + String varName = s.substring(i1 + 1, i2); + String varValue = System.getenv(varName); + if (varValue == null) + varValue = ""; + + value += s.substring(i, i1); + value += varValue; + + i = i2 + 1; + i1 = s.indexOf('%', i); + } + value += s.substring(i); + + log.info("Parameter " + name + ": " + value); + return value; + } +} diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml new file mode 100644 index 00000000..a53ea141 --- /dev/null +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-context.xml @@ -0,0 +1,32 @@ + + + + + + + + + diff --git a/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml new file mode 100644 index 00000000..7d74fd4f --- /dev/null +++ b/properties-node/provider/src/main/resources/META-INF/spring/properties-node-osgi-context.xml @@ -0,0 +1,32 @@ + + + + + + + + -- cgit 1.2.3-korg