summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2022-06-29 14:04:09 +0100
committerliamfallon <liam.fallon@est.tech>2022-06-30 14:07:23 +0100
commit8c8eb415ca57830d462cefbe8d659b3b98b6de7c (patch)
tree17ba597b4a5a8bfa5dae6251fef4c0494cdee1b7
parented439e7e8dafbdd87ace0604dc6230bb9563f995 (diff)
Fix simulator docker file and startup script
The nmodels-simulator startup script is updated to: - enable logging - allow overriding of keystore and truststore - allow overriding of configuration parameters - Follow the same conventions as other docker files and startup scripts - Add labelling - Provide default configuration Issue-ID: POLICY-4233 Change-Id: I6c25dc77c510a52ec298883f2534428807b1c253 Signed-off-by: liamfallon <liam.fallon@est.tech>
-rw-r--r--models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile40
-rw-r--r--models-sim/packages/models-simulator-docker/src/main/docker/simulators.sh42
-rw-r--r--models-sim/packages/models-simulator-tarball/src/main/assembly.xml1
-rw-r--r--models-sim/packages/models-simulator-tarball/src/main/resources/etc/simParameters.json110
4 files changed, 157 insertions, 36 deletions
diff --git a/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile b/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile
index 50f84d96c..c5832bfd7 100644
--- a/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile
+++ b/models-sim/packages/models-simulator-docker/src/main/docker/Dockerfile
@@ -22,11 +22,7 @@
# ============LICENSE_END=========================================================
#
-#
-# Docker file to build an image that runs the simulators
-#
-
-FROM onap/policy-jre-alpine:2.3.1
+FROM onap/policy-jre-alpine:2.4.3
LABEL maintainer="Policy Team"
LABEL org.opencontainers.image.title="Policy Models Simulator"
@@ -40,30 +36,22 @@ LABEL org.opencontainers.image.revision="${git.commit.id.abbrev}"
ARG POLICY_LOGS=/var/log/onap/policy/simulators
-ENV POLICY_HOME /opt/app/policy
-ENV POLICY_LOGS ${POLICY_LOGS}
+ENV POLICY_LOGS=$POLICY_LOGS
+ENV POLICY_HOME=$POLICY_HOME/simulators
-# Create DMaaP simulator user and group
-# Add simulator-specific directories and set ownership as the simulator user
-RUN mkdir -p ${POLICY_HOME}/simulators \
- && mkdir -p ${POLICY_HOME}/simulators/bin \
- && mkdir -p ${POLICY_LOGS} \
- && mkdir /packages
+RUN mkdir -p $POLICY_HOME $POLICY_LOGS $POLICY_HOME/bin && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
+ mkdir /packages
+COPY /maven/lib/models-simulator.tar.gz /packages
-# Unpack the tarball
-COPY /maven/* /packages
-RUN tar xvfz /packages/models-simulator.tar.gz --directory ${POLICY_HOME}/simulators \
+RUN tar xvfz /packages/models-simulator.tar.gz --directory ${POLICY_HOME} \
&& rm /packages/models-simulator.tar.gz
-# Ensure everything has the correct permissions
-# Copy scripts simulator user area
-COPY simulators.sh ${POLICY_HOME}/simulators/bin
-RUN find /opt/app -type d -perm 755 \
- && find /opt/app -type f -perm 644 \
- && chmod 755 ${POLICY_HOME}/simulators/bin/* \
- && chown -R policy:policy $POLICY_HOME $POLICY_LOGS
+WORKDIR $POLICY_HOME
+COPY simulators.sh bin/.
-USER policy:policy
+RUN chown -R policy:policy * && chmod 755 bin/*.sh && chown -R policy:policy /app
-ENV PATH ${POLICY_HOME}/simulators/bin:$PATH
-ENTRYPOINT [ "simulators.sh" ]
+USER policy
+WORKDIR $POLICY_HOME/bin
+ENTRYPOINT [ "./simulators.sh" ]
diff --git a/models-sim/packages/models-simulator-docker/src/main/docker/simulators.sh b/models-sim/packages/models-simulator-docker/src/main/docker/simulators.sh
index fdf680589..3d382a876 100644
--- a/models-sim/packages/models-simulator-docker/src/main/docker/simulators.sh
+++ b/models-sim/packages/models-simulator-docker/src/main/docker/simulators.sh
@@ -23,21 +23,43 @@
# ============LICENSE_END=========================================================
#
-if [ -z "$SIMULATOR_HOME" ]
-then
- SIMULATOR_HOME=${POLICY_HOME}/simulators
+KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
+TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
+KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
+TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
+
+if [ "$#" -ge 1 ]; then
+ CONFIG_FILE=$1
+else
+ CONFIG_FILE=${CONFIG_FILE}
+fi
+
+if [ -z "$CONFIG_FILE" ]; then
+ CONFIG_FILE="${POLICY_HOME}/etc/simParameters.json"
fi
-KEYSTORE="${SIMULATOR_HOME}/etc/ssl/policy-keystore"
-KEYSTORE_PASSWD="Pol1cy_0nap"
-TRUSTSTORE="${SIMULATOR_HOME}/etc/ssl/policy-truststore"
-TRUSTSTORE_PASSWD="Pol1cy_0nap"
+echo "Policy simulator config file: $CONFIG_FILE"
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
+ echo "overriding policy-truststore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
+ echo "overriding policy-keystore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
+ echo "overriding logback.xml"
+ cp -f "${POLICY_HOME}"/etc/mounted/logback.xml "${POLICY_HOME}"/etc/
+fi
${JAVA_HOME}/bin/java \
- -cp "${SIMULATOR_HOME}/etc:${SIMULATOR_HOME}/lib/*" \
+ -cp "${POLICY_HOME}/etc:${POLICY_HOME}/lib/*" \
+ -Dlogging.config="${POLICY_HOME}/etc/logback.xml" \
-Djavax.net.ssl.keyStore="${KEYSTORE}" \
-Djavax.net.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
-Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
-Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
- org.onap.policy.models.simulators.Main \
- ${SIMULATOR_HOME}/etc/mounted/simParameters.json
+ org.onap.policy.models.simulators.Main ${CONFIG_FILE}
diff --git a/models-sim/packages/models-simulator-tarball/src/main/assembly.xml b/models-sim/packages/models-simulator-tarball/src/main/assembly.xml
index 47395e122..430728b9e 100644
--- a/models-sim/packages/models-simulator-tarball/src/main/assembly.xml
+++ b/models-sim/packages/models-simulator-tarball/src/main/assembly.xml
@@ -51,6 +51,7 @@
</directory>
<includes>
<include>*.xml</include>
+ <include>*.json</include>
</includes>
<outputDirectory>etc</outputDirectory>
<lineEnding>unix</lineEnding>
diff --git a/models-sim/packages/models-simulator-tarball/src/main/resources/etc/simParameters.json b/models-sim/packages/models-simulator-tarball/src/main/resources/etc/simParameters.json
new file mode 100644
index 000000000..41fc90574
--- /dev/null
+++ b/models-sim/packages/models-simulator-tarball/src/main/resources/etc/simParameters.json
@@ -0,0 +1,110 @@
+{
+ "dmaapProvider": {
+ "name": "DMaaP simulator",
+ "topicSweepSec": 300
+ },
+ "restServers": [
+ {
+ "name": "DMaaP simulator",
+ "providerClass": "org.onap.policy.models.sim.dmaap.rest.DmaapSimRestControllerV1",
+ "host": "0.0.0.0",
+ "port": 3904,
+ "https": false
+ },
+ {
+ "name": "A&AI simulator",
+ "providerClass": "org.onap.policy.simulators.AaiSimulatorJaxRs",
+ "host": "0.0.0.0",
+ "port": 6666,
+ "https": false,
+ "userName": "policy@policy.onap.org",
+ "password": "demo123456!",
+ "resourceLocation": "/opt/app/policy/simulators/etc/mounted/aairesponse/"
+ },
+ {
+ "name": "SDNC simulator",
+ "providerClass": "org.onap.policy.simulators.SdncSimulatorJaxRs",
+ "host": "0.0.0.0",
+ "port": 6668,
+ "https": false
+ },
+ {
+ "name": "SO simulator",
+ "providerClass": "org.onap.policy.simulators.SoSimulatorJaxRs",
+ "host": "0.0.0.0",
+ "port": 6669,
+ "https": false,
+ "userName": "InfraPortalClient",
+ "password": "password1$"
+ },
+ {
+ "name": "VFC simulator",
+ "providerClass": "org.onap.policy.simulators.VfcSimulatorJaxRs",
+ "host": "0.0.0.0",
+ "port": 6670,
+ "https": false
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "APPC-CL",
+ "servers": ["${HOST_NAME}"],
+ "topicCommInfrastructure": "DMAAP",
+ "useHttps": false,
+ "apiKey": "some-key",
+ "apiSecret": "some-secret"
+ },
+ {
+ "topic": "APPC-LCM-WRITE",
+ "servers": ["${HOST_NAME}"],
+ "topicCommInfrastructure": "DMAAP",
+ "useHttps": false,
+ "apiKey": "some-key",
+ "apiSecret": "some-secret"
+ }
+ ],
+ "topicSources": [
+ {
+ "topic": "APPC-CL",
+ "servers": ["${HOST_NAME}"],
+ "topicCommInfrastructure": "DMAAP",
+ "useHttps": false,
+ "apiKey": "some-key",
+ "apiSecret": "some-secret"
+ },
+ {
+ "topic": "APPC-LCM-READ",
+ "servers": ["${HOST_NAME}"],
+ "topicCommInfrastructure": "DMAAP",
+ "useHttps": false,
+ "apiKey": "some-key",
+ "apiSecret": "some-secret"
+ }
+ ],
+ "topicServers": [
+ {
+ "name": "APPC Legacy simulator",
+ "providerClass": "org.onap.policy.simulators.AppcLegacyTopicServer",
+ "sink": "APPC-CL",
+ "source": "APPC-CL"
+ },
+ {
+ "name": "APPC-LCM simulator",
+ "providerClass": "org.onap.policy.simulators.AppcLcmTopicServer",
+ "sink": "APPC-LCM-WRITE",
+ "source": "APPC-LCM-READ"
+ }
+ ],
+ "grpcServer": {
+ "name": "CDS simulator",
+ "providerClass": "org.onap.policy.simulators.CdsSimulator",
+ "host": "0.0.0.0",
+ "port": 6680,
+ "timeout": 30,
+ "username": "ccsdkapps",
+ "password": "ccsdkapps",
+ "resourceLocation": "/opt/app/policy/simulators/etc/mounted/cdsresponse/",
+ "successRepeatCount": 0,
+ "requestedResponseDelayMs": 0
+ }
+}