From 17b1b97378d6a83e525e22ee2507d2a844e05fed Mon Sep 17 00:00:00 2001 From: ATT default cloud user Date: Thu, 31 Aug 2017 21:34:47 +0000 Subject: [PATCH] DMAAP-83 Initial code import Change-Id: I7807b0f59bd2acb55a2df98632112f28a9f64f74 Signed-off-by: ATT default cloud user --- Dockerfile | 27 ++++ LICENSE.txt | 21 +++ README.md | 83 ++++++++++++ misc/LocalKey | 27 ++++ misc/PolicyEngineApi.properties.tmpl | 14 ++ misc/dmaapbc | 152 +++++++++++++++++++++ misc/dmaapbc.properties.tmpl | 152 +++++++++++++++++++++ misc/doaction | 43 ++++++ misc/havecert.tmpl | 11 ++ misc/log4j.properties.tmpl | 11 ++ misc/opensource.env | 99 ++++++++++++++ misc/policyLogger.properties | 24 ++++ pom.xml | 248 +++++++++++++++++++++++++++++++++++ src/main/webapp/HelloJetty.html | 30 +++++ src/main/webapp/WEB-INF/log4j.xml | 45 +++++++ src/main/webapp/WEB-INF/web.xml | 38 ++++++ src/main/webapp/index.jsp | 28 ++++ 17 files changed, 1053 insertions(+) create mode 100644 Dockerfile create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 misc/LocalKey create mode 100644 misc/PolicyEngineApi.properties.tmpl create mode 100644 misc/dmaapbc create mode 100644 misc/dmaapbc.properties.tmpl create mode 100644 misc/doaction create mode 100644 misc/havecert.tmpl create mode 100644 misc/log4j.properties.tmpl create mode 100644 misc/opensource.env create mode 100644 misc/policyLogger.properties create mode 100644 pom.xml create mode 100644 src/main/webapp/HelloJetty.html create mode 100644 src/main/webapp/WEB-INF/log4j.xml create mode 100644 src/main/webapp/WEB-INF/web.xml create mode 100644 src/main/webapp/index.jsp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6ae667e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM java:openjdk-8-jre +MAINTAINER Dominic Lunanuova +ENV insdir /opt/app/dmaapbc +RUN \ + mkdir -p ${insdir}/lib \ + && mkdir -p ${insdir}/etc \ + && mkdir -p ${insdir}/logs \ + && mkdir -p ${insdir}/www && mkdir -p ${insdir}/www/doc \ + && mkdir -p ${insdir}/config \ + && mkdir -p ${insdir}/misc \ + && mkdir -p ${insdir}/bin +WORKDIR ${insdir} +USER root +COPY target/buscontroller.jar ${insdir}/lib/ +COPY target/deps/*.jar ${insdir}/lib/ +# COPY src/main/resources/log4j.properties ${insdir}/etc/ +# COPY www/ ${insdir}/www/ +# COPY target/site/apidocs/ ${insdir}/www/doc/ +COPY misc/LocalKey ${insdir}/etc/ +COPY misc/opensource.env ${insdir}/misc/ +COPY misc/*.tmpl ${insdir}/misc/ +COPY misc/dmaapbc ${insdir}/bin/ +RUN chmod +x ${insdir}/bin/* +COPY misc/doaction ${insdir}/bin/ + +VOLUME ${insdir}/log +CMD ["./bin/dmaapbc", "deploy" ] diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..9df2b59 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,21 @@ +/* + * ============LICENSE_START========================================== + * org.onap.dcae + * =================================================================== + * Copyright © 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============================================ + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * + */ diff --git a/README.md b/README.md new file mode 100644 index 0000000..5d118a0 --- /dev/null +++ b/README.md @@ -0,0 +1,83 @@ +DMaaP Bus Controller API +======================= + +Data Movement as a Platform (DMaaP) Bus Controller provides an API for other ONAP infrastructure components to provision DMaaP resources. +A typical DMaaP resource is a Data Router Feed or a Message Router Topic, and their associated publishers and subscribers. +Other infrastucture resources such as DR Nodes and MR Clusters are also provisioned through this API. + +### Build Instructions for a Continuous Integration environment using Jenkins + +When this component is included in a Continuous Integration environment, such as structured by the Linux Foundation, the artifacts can be created and deployed via Jenkins. The following maven targets are currently supported in the Build step: +``` +clean install +``` + + +### Build Instructions for external developers + +This project is organized as a mvn project for a jar package. +After cloning from this git repo: + +``` +mvn clean install +``` + + +### Docker Packaging + +We can utilize docker to build and register the buscontroller container in a local dev repository. +Note the Dockerfile follows ONAP convention of running app as root. + +``` + + +$ docker build -f ./Dockerfile . +``` + + +### ONAP deployment + +Details TBD. + +Prior to starting container, place environment specific vars in /tmp/docker-databus-controller.conf on the Docker host, +and map that file to /opt/app/config/conf. +Run the container which will run the dmaapbc deploy command, which will update the container runtime properties appropriately, and start the Bus Controller. + +For example, in ONAP Future Lab environment, /tmp/docker-databus-controller.conf looks like: +``` + +# DMaaP Bus Controller OpenSource environment vars +CONT_DOMAIN=demo.dmaap.onap.org +DMAAPBC_INSTANCE_NAME=ONAPfuture + +# The https port +# set to 0 if certificate is not ready +DMAAPBC_INT_HTTPS_PORT=0 + +DMAAPBC_KSTOREFILE=/opt/app/dcae-certificates +DMAAPBC_KSTOREPASS=foofoofoo +DMAAPBC_PVTKEYPASS=barbarbar + +DMAAPBC_PG_ENABLED=true +DMAAPBC_PGHOST=zldciad1vipstg00.simpledemo.openecomp.org +DMAAPBC_PGCRED=test234-ftl + +DMAAPBC_DRPROV_FQDN=zldciad1vidrps00.simpledemo.openecomp.org + +DMAAPBC_AAF_URL=https://aafapi.${CONT_DOMAIN}:8095/proxy/ + +DMAAPBC_TOPICMGR_USER=m99751@dmaapBC.openecomp.org +DMAAPBC_TOPICMGR_PWD=enc:zyRL9zbI0py3rJAjMS0dFOnYfEw_mJhO +DMAAPBC_ADMIN_USER=m99501@dcae.openecomp.org +DMAAPBC_ADMIN_PWD=enc:YEaHwOJrwhDY8a6usetlhbB9mEjUq9m + +DMAAPBC_PE_ENABLED=false +DMAAPBC_PE_AAF_ENV=TBD +``` +Then the following steps could be used to pull and run the Bus Controller. (onap-nexus is just an example) +``` +$ +$ docker pull ecomp-nexus:51212/dcae_dmaapbc:1.0.0 +$ docker run -d -p 18080:8080 -v /tmp/docker-databus-controller.conf:/opt/app/config/conf onap-nexus:51212/dmaap/buscontroller:1.0.0 +``` + diff --git a/misc/LocalKey b/misc/LocalKey new file mode 100644 index 0000000..38ede55 --- /dev/null +++ b/misc/LocalKey @@ -0,0 +1,27 @@ +7ntUvubggJ1h6AXwQENQScrnlqmLMno_583XufLsguAT11bnBk0DVLE2GtCZ0pNQzlR8I3PJ1_nZ +UEVQs1G_qZzV-MHQZvz54solEp8dNUVji4JUzP7WiPuJdvCX8vvGLc8-jOVzEJ2DAGmV3gNp60_F +jrKx7F7Dz-h94jWZ45rNn7-Re_BneSto6HiSj0DN_SKSNhE5z9Qf3tFyFLGIYmlQoxzbTYC38uN0 +FjAYuKz6W_pTLzyOjHNAagYwEjTUUU-ei-QA5pL20-oG3jSYGnj_V94kd8X5ncB1-nybUsy5OOvZ +huCxf9hSetn2fpIszkRcuFxaxiwubpmEWp2L_zovhcRI1OMFPIIK0IckRHD1a5CpFVzR7P5L7LQk +FErATsQkHsPS9BJN5wlj1EoIhA2uaELjXjmOqPQg76eyQqXXcMHRJTA6czbXPYfTQMQx1r2USC9o +HdoLT4-so7zARZidmYmvPPT9qvNisK6BF4M32K-_s6YyJspSEB1MscNPujsD7zczIsBct7BTRoeZ +CbtkskT_yFhQzdzdSMzFN_NJ7Yb9p3d1G4gSkj2rbA-BDybHHPij8k6-k-ipvi_T_LW9B_J8Jf5f +aRclZqVgwwSG-mUKUyk9bI3cVc-1P2ICUmr59EjuauDAtlMQL-hnTJUs1rUerh4Q7d4XgrNLjLHY +Oue8MEj24VSMl-f28DDIV1N6ODiBKDHUmdENsmlbqeNpzQxu7FoSbLu6gN6zDP8Jw4ck1NHEIv8H +ecUf-hBGdB0HINClaV9X2ycafWcmRY-NCzX65cp7a1Rpl1kCEW5u79LLN28aJeTzmriewhy87h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fgLF4PbRDklsAcsiT +P0xUdyWJ5slu87f9PunXDwQZWNv6haTIhVX7bilCDpRPbTbmimmE_C2J7tgV2EvazD7o8V_jeu0g +cnIpzRnaPG9l-uy2UKoxOXI4CSymcJoyV2xxC0SF7Q5quAhf3UGAdQUeFtHwxZtYiAMXLs06 \ No newline at end of file diff --git a/misc/PolicyEngineApi.properties.tmpl b/misc/PolicyEngineApi.properties.tmpl new file mode 100644 index 0000000..b49f7e9 --- /dev/null +++ b/misc/PolicyEngineApi.properties.tmpl @@ -0,0 +1,14 @@ +cat < etc/dmaapbc.properties + . misc/PolicyEngineApi.properties.tmpl > config/PolicyEngineApi.properties + set +x +} + +start() { + set -x + ID=`id -n -u` + GRP=`id -n -g` + if [ "$ID" != "$USER" ] + then + echo $COMPONENT must be started as user $USER not $ID + exit 1 + fi + if [ "$GRP" != "$USER" ] + then + echo $COMPONENT must be started as group $USER not $GRP + exit 1 + fi + cd $APP_ROOT + +# disable until we use certs +# if etc/havecert +# then + echo >/dev/null +# else +# echo No certificate file available. Cannot start +# exit 0 +# fi + PIDS=`pids` + if [ "$PIDS" != "" ] + then + echo $COMPONENT already running + exit 0 + fi + rm -f $APP_ROOT/etc/SHUTDOWN + + # JVM flags +#old line from Dockerfile...keep for reference only + FLAGS="-cp etc:lib/* -Dlog4j.configuration=etc/log4j.properties -Ddmaapbc.properties=etc/dmaapbc.properties -Dhttps.protocols=TLSv1.2 -Dhttps.cipherSuites=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" + nohup java $FLAGS $MAIN /dev/null 2>&1 & + sleep 5 + PIDS=`pids` + if [ "$PIDS" = "" ] + then + echo $COMPONENT startup failed + tail -100 $APP_ROOT/logs/dmaap*.log + else + echo $COMPONENT started + fi + set +x +} + +stop() { + ID=`id -n -u` + GRP=`id -n -g` + if [ "$ID" != "$USER" ] + then + echo $COMPONENT must be stopped as user $USER not $ID + exit 1 + fi + if [ "$GRP" != "$USER" ] + then + echo $COMPONENT must be stopped as group $USER not $GRP + exit 1 + fi + touch $APP_ROOT/etc/SHUTDOWN + PIDS=`pids` + if [ "$PIDS" != "" ] + then + sleep 5 + kill -9 $PIDS + sleep 5 + echo $COMPONENT stopped + else + echo $COMPONENT not running + fi +} + +status() { + PIDS=`pids` + if [ "$PIDS" != "" ] + then + echo $COMPONENT running + else + echo $COMPONENT not running + fi +} + +set -x +case "$1" in +'deploy') + config + start + wait + ;; +'start') + start + ;; +'stop') + stop + ;; +'restart') + stop + sleep 20 + start + ;; +'status') + status + ;; +*) + echo "Usage: $0 { start | stop | restart }" + exit 1 + ;; +esac +exit 0 diff --git a/misc/dmaapbc.properties.tmpl b/misc/dmaapbc.properties.tmpl new file mode 100644 index 0000000..9af0d7e --- /dev/null +++ b/misc/dmaapbc.properties.tmpl @@ -0,0 +1,152 @@ +cat </dev/null + cp dmaapbc.properties dmaapbc.properties.save 2>/dev/null + cp havecert havecert.save 2>/dev/null + ;; +'stop') + /opt/app/platform/init.d/dmaapbc stop + ;; +'start') + /opt/app/platform/init.d/dmaapbc start || exit 1 + ;; +'config') + /bin/bash log4j.properties.tmpl >log4j.properties + /bin/bash dmaapbc.properties.tmpl >dmaapbc.properties + /bin/bash havecert.tmpl >havecert + /bin/bash PolicyEngineApi.properties.tmpl > ../config/PolicyEngineApi.properties + echo "$AFTSWM_ACTION_NEW_VERSION" >VERSION.dmaapbc + chmod +x havecert + rm -f /opt/app/platform/rc.d/K90dmaapbc /opt/app/platform/rc.d/S10dmaapbc + ln -s ../init.d/dmaapbc /opt/app/platform/rc.d/K90dmaapbc + ln -s ../init.d/dmaapbc /opt/app/platform/rc.d/S10dmaapbc + ;; +'restore') + cp log4j.properties.save log4j.properties 2>/dev/null + cp dmaapbc.properties.save dmaapbc.properties 2>/dev/null + cp havecert.save havecert 2>/dev/null + ;; +'clean') + rm -f log4j.properties dmaapbc.properties havecert log4j.properties.save dmaapbc.properties.save havecert.save SHUTDOWN redirections.dat VERSION.dmaapbc + rm -f /opt/app/platform/rc.d/K90dmaapbc /opt/app/platform/rc.d/S10dmaapbc + ;; +*) + exit 1 + ;; +esac +done +exit 0 diff --git a/misc/havecert.tmpl b/misc/havecert.tmpl new file mode 100644 index 0000000..00a0a34 --- /dev/null +++ b/misc/havecert.tmpl @@ -0,0 +1,11 @@ +#!/bin/bash +cat <>${DMAAPBC_LOGS:-logs}/dmaapbc.log +exit 1 +!EOF diff --git a/misc/log4j.properties.tmpl b/misc/log4j.properties.tmpl new file mode 100644 index 0000000..0b689f4 --- /dev/null +++ b/misc/log4j.properties.tmpl @@ -0,0 +1,11 @@ +cat < + + 4.0.0 + org.onap.dmaap.buscontroller + buscontroller + ${artifact.version} + buscontroller + + + ecomp-releases + Open eCOMP Release Repository + ${nexusproxy}/${releases.path} + + + ecomp-snapshots + Open eCOMP Snapshot Repository + ${nexusproxy}/${snapshots.path} + + + ecomp-site + dav:${nexusproxy}/content/sites/site/org/onap/dmaap/dbcapi/${project.artifactId}/${project.version}/ + + + + + central + http://repo1.maven.org/maven2 + + + + buscontroller + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + true + + 1.7 + 1.7 + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8 + + + + + + org.apache.maven.plugins + maven-site-plugin + 3.6 + + + org.apache.maven.wagon + wagon-webdav-jackrabbit + 2.10 + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/deps + false + false + true + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ecomp-staging + ${nexusproxy} + 176c31dfe190a + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + [2.10,) + + copy-dependencies + + + + + + + + + + + + + + + + + + org.glassfish.jersey + jersey-bom + ${jersey.version} + pom + import + + + + + + io.swagger + swagger-core + 1.5.13 + + + io.swagger + swagger-jersey2-jaxrs + 1.5.13 + + + io.swagger + swagger-annotations + 1.5.13 + + + org.glassfish.jersey.containers + jersey-container-servlet-core + + + + + org.glassfish.jersey.media + jersey-media-moxy + + + log4j + log4j + 1.2.17 + + + org.eclipse.jetty + jetty-server + ${jettyVersion} + + + org.eclipse.jetty + jetty-servlet + ${jettyVersion} + compile + + + org.eclipse.jetty + jetty-servlets + ${jettyVersion} + compile + + + + com.googlecode.json-simple + json-simple + 1.1.1 + + + commons-codec + commons-codec + 1.6 + + + + org.postgresql + postgresql + 9.4.1208.jre7 + + + com.att.eelf + eelf-core + ${eelf.version} + + + org.onap.dmaap.dbcapi + dbcapi + 1.1.0-SNAPSHOT + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + false + org.umlgraph.doclet.UmlGraphDoc + + org.umlgraph + umlgraph + 5.6 + + -views + true + + + + + + 2.16 + UTF-8 + 9.3.7.v20160115 + 0.0.1 + 1.0.0-SNAPSHOT + https://nexus.onap.org + content/repositories/snapshots/ + content/repositories/releases/ + + Packaging Platform (DMaaP) Bus Controller API as a Docker container. + diff --git a/src/main/webapp/HelloJetty.html b/src/main/webapp/HelloJetty.html new file mode 100644 index 0000000..4d61636 --- /dev/null +++ b/src/main/webapp/HelloJetty.html @@ -0,0 +1,30 @@ + + + + + + +Index + + +Hello Jetty! + + diff --git a/src/main/webapp/WEB-INF/log4j.xml b/src/main/webapp/WEB-INF/log4j.xml new file mode 100644 index 0000000..4e4d5e9 --- /dev/null +++ b/src/main/webapp/WEB-INF/log4j.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..055fbf0 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,38 @@ + + + + + + + Jersey Web Application + org.glassfish.jersey.servlet.ServletContainer + + jersey.config.server.provider.packages + org.openecomp.dmaapBC + + 1 + + + Jersey Web Application + /webapi/* + + diff --git a/src/main/webapp/index.jsp b/src/main/webapp/index.jsp new file mode 100644 index 0000000..3c20e06 --- /dev/null +++ b/src/main/webapp/index.jsp @@ -0,0 +1,28 @@ +<%-- + ============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + 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========================================================= + --%> + + + +

Jersey RESTful Web Application!

+

Jersey resource +

Visit Project Jersey website + for more information on Jersey! + + -- 2.16.6