aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/policy-clamp-docker/pom.xml6
-rw-r--r--packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile8
-rw-r--r--packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile7
-rw-r--r--packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile3
-rw-r--r--packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile7
-rw-r--r--packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh18
-rw-r--r--packages/policy-clamp-docker/src/main/docker/dcae-participant.sh6
-rw-r--r--packages/policy-clamp-docker/src/main/docker/kubernetes-participant.sh16
-rw-r--r--packages/policy-clamp-docker/src/main/docker/policy-participant.sh6
-rw-r--r--packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml13
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json53
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml54
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json70
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.yaml55
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml54
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json76
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml33
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml24
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml22
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml24
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml24
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java202
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java79
-rw-r--r--runtime-controlloop/src/main/resources/application.yaml24
-rw-r--r--runtime/extra/sql/bulkload/create-db.sql6
-rw-r--r--runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml35
-rw-r--r--runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml28
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java47
-rw-r--r--runtime/src/test/resources/http-cache/example/node_template.json44
-rw-r--r--runtime/src/test/resources/http-cache/third_party_proxy.py25
30 files changed, 766 insertions, 303 deletions
diff --git a/packages/policy-clamp-docker/pom.xml b/packages/policy-clamp-docker/pom.xml
index 576c95de6..16c416126 100644
--- a/packages/policy-clamp-docker/pom.xml
+++ b/packages/policy-clamp-docker/pom.xml
@@ -111,6 +111,12 @@
<outputDirectory>/lib</outputDirectory>
<outputFileNameMapping>policy-controlloop-runtime.tar.gz</outputFileNameMapping>
</dependencySet>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.clamp:policy-clamp-runtime-controlloop</include>
+ </includes>
+ <outputFileNameMapping>app.jar</outputFileNameMapping>
+ </dependencySet>
</dependencySets>
</inline>
</assembly>
diff --git a/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile b/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile
index bd5000686..3d57418e5 100644
--- a/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile
+++ b/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile
@@ -33,14 +33,18 @@ ENV POLICY_HOME=$POLICY_HOME/clamp
RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
mkdir /packages
-COPY /maven/* /packages
+COPY /maven/lib/policy-controlloop-runtime.tar.gz /packages
+
RUN tar xvfz /packages/policy-controlloop-runtime.tar.gz --directory $POLICY_HOME && \
rm /packages/policy-controlloop-runtime.tar.gz
WORKDIR $POLICY_HOME
COPY controlloop-runtime.sh bin/.
+COPY /maven/app.jar /app
-RUN chown -R policy:policy * && chmod 755 bin/*.sh
+RUN chown -R policy:policy * && \
+ chmod 755 bin/*.sh && \
+ chown -R policy:policy /app
USER policy
WORKDIR $POLICY_HOME/bin
diff --git a/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile
index 368b9348a..ed09c50d3 100644
--- a/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile
+++ b/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile
@@ -34,15 +34,16 @@ RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
mkdir /packages
COPY /maven/lib/dcae-participant.tar.gz /packages
+
RUN tar xvfz /packages/dcae-participant.tar.gz --directory $POLICY_HOME && \
- rm /packages/dcae-participant.tar.gz && \
- rm -rf $POLICY_HOME/lib
+ rm /packages/dcae-participant.tar.gz
WORKDIR $POLICY_HOME
COPY dcae-participant.sh bin/.
COPY /maven/app.jar /app
-RUN chown -R policy:policy * && chmod 755 bin/*.sh && \
+RUN chown -R policy:policy * && \
+ chmod 755 bin/*.sh && \
chown -R policy:policy /app
USER policy
diff --git a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile
index 63209d75f..d08e14fff 100644
--- a/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile
+++ b/packages/policy-clamp-docker/src/main/docker/KubernetesParticipantDockerfile
@@ -36,8 +36,7 @@ RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
COPY /maven/lib/kubernetes-participant.tar.gz /packages
RUN tar xvfz /packages/kubernetes-participant.tar.gz --directory $POLICY_HOME && \
- rm /packages/kubernetes-participant.tar.gz && \
- rm -rf $POLICY_HOME/lib
+ rm /packages/kubernetes-participant.tar.gz
WORKDIR $POLICY_HOME
COPY kubernetes-participant.sh bin/.
diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile
index 3c2082202..8eca34d42 100644
--- a/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile
+++ b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile
@@ -34,15 +34,16 @@ RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
mkdir /packages
COPY /maven/lib/policy-participant.tar.gz /packages
+
RUN tar xvfz /packages/policy-participant.tar.gz --directory $POLICY_HOME && \
- rm /packages/policy-participant.tar.gz && \
- rm -rf $POLICY_HOME/lib
+ rm /packages/policy-participant.tar.gz
WORKDIR $POLICY_HOME
COPY policy-participant.sh bin/.
COPY /maven/app.jar /app
-RUN chown -R policy:policy * && chmod 755 bin/*.sh && \
+RUN chown -R policy:policy * && \
+ chmod 755 bin/*.sh && \
chown -R policy:policy /app
USER policy
diff --git a/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh b/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh
index 8d64fa5a4..6d12e590a 100644
--- a/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh
+++ b/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh
@@ -32,7 +32,7 @@ else
fi
if [ -z "$CONFIG_FILE" ]; then
- CONFIG_FILE="${POLICY_HOME}/etc/ClRuntimeParameters.json"
+ CONFIG_FILE="${POLICY_HOME}/etc/ClRuntimeParameters.yaml"
fi
echo "Policy clamp config file: $CONFIG_FILE"
@@ -48,15 +48,17 @@ if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
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/
+ echo "overriding logback xml files"
+ cp -f "${POLICY_HOME}"/etc/mounted/logback*.xml "${POLICY_HOME}"/etc/
fi
-$JAVA_HOME/bin/java -cp "${POLICY_HOME}/etc:${POLICY_HOME}/lib/*" \
- -Dlogback.configurationFile="${POLICY_HOME}/etc/logback.xml" \
- -Djavax.net.ssl.keyStore="${KEYSTORE}" \
+touch /app/app.jar
+mkdir -p "${POLICY_HOME}"/config/
+cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/ClRuntimeParameters.yaml
+
+$JAVA_HOME/bin/java -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.clamp.controlloop.runtime.main.startstop.Main \
- -c "${CONFIG_FILE}"
+ -jar /app/app.jar \
+ --spring.config.location="${POLICY_HOME}/config/ClRuntimeParameters.yaml"
diff --git a/packages/policy-clamp-docker/src/main/docker/dcae-participant.sh b/packages/policy-clamp-docker/src/main/docker/dcae-participant.sh
index 4acb17b39..620fa42cd 100644
--- a/packages/policy-clamp-docker/src/main/docker/dcae-participant.sh
+++ b/packages/policy-clamp-docker/src/main/docker/dcae-participant.sh
@@ -32,7 +32,7 @@ else
fi
if [ -z "$CONFIG_FILE" ]; then
- CONFIG_FILE="${POLICY_HOME}/etc/DcaeParticipantParameters.json"
+ CONFIG_FILE="${POLICY_HOME}/etc/DcaeParticipantParameters.yaml"
fi
echo "Policy clamp config file: $CONFIG_FILE"
@@ -54,11 +54,11 @@ fi
touch /app/app.jar
mkdir -p "${POLICY_HOME}"/config/
-cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/
+cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/DcaeParticipantParameters.yaml
$JAVA_HOME/bin/java -Djavax.net.ssl.keyStore="${KEYSTORE}" \
-Djavax.net.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
-Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
-Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
-jar /app/app.jar \
- --participant.file="${POLICY_HOME}/config/DcaeParticipantParameters.json"
+ --spring.config.location="${POLICY_HOME}/config/DcaeParticipantParameters.yaml"
diff --git a/packages/policy-clamp-docker/src/main/docker/kubernetes-participant.sh b/packages/policy-clamp-docker/src/main/docker/kubernetes-participant.sh
index 50995de3b..cb5ae9251 100644
--- a/packages/policy-clamp-docker/src/main/docker/kubernetes-participant.sh
+++ b/packages/policy-clamp-docker/src/main/docker/kubernetes-participant.sh
@@ -25,7 +25,17 @@ TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
+if [ "$#" -eq 1 ]; then
+ CONFIG_FILE=$1
+else
+ CONFIG_FILE=${CONFIG_FILE}
+fi
+
+if [ -z "$CONFIG_FILE" ]; then
+ CONFIG_FILE="${POLICY_HOME}/etc/KubernetesParticipantParameters.yaml"
+fi
+echo "Policy clamp config file: $CONFIG_FILE"
if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
echo "overriding policy-truststore"
@@ -42,8 +52,12 @@ if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
cp -f "${POLICY_HOME}"/etc/mounted/logback*.xml "${POLICY_HOME}"/etc/
fi
+mkdir -p "${POLICY_HOME}"/config/
+cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/KubernetesParticipantParameters.yaml
+
$JAVA_HOME/bin/java -Dserver.ssl.keyStore="${KEYSTORE}" \
-Dserver.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
-Dserver.ssl.trustStore="${TRUSTSTORE}" \
-Dserver.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
- -jar /app/app.jar
+ -jar /app/app.jar \
+ --spring.config.location="${POLICY_HOME}/config/KubernetesParticipantParameters.yaml"
diff --git a/packages/policy-clamp-docker/src/main/docker/policy-participant.sh b/packages/policy-clamp-docker/src/main/docker/policy-participant.sh
index 2e7a7d54b..7949fab72 100644
--- a/packages/policy-clamp-docker/src/main/docker/policy-participant.sh
+++ b/packages/policy-clamp-docker/src/main/docker/policy-participant.sh
@@ -32,7 +32,7 @@ else
fi
if [ -z "$CONFIG_FILE" ]; then
- CONFIG_FILE="${POLICY_HOME}/etc/PolicyParticipantParameters.json"
+ CONFIG_FILE="${POLICY_HOME}/etc/PolicyParticipantParameters.yaml"
fi
echo "Policy clamp config file: $CONFIG_FILE"
@@ -54,11 +54,11 @@ fi
touch /app/app.jar
mkdir -p "${POLICY_HOME}"/config/
-cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/
+cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/PolicyParticipantParameters.yaml
$JAVA_HOME/bin/java -Djavax.net.ssl.keyStore="${KEYSTORE}" \
-Djavax.net.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
-Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
-Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
-jar /app/app.jar \
- --participant.file="${POLICY_HOME}/config/PolicyParticipantParameters.json"
+ --spring.config.location="${POLICY_HOME}/config/PolicyParticipantParameters.yaml"
diff --git a/packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml b/packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml
index 6e8cd454a..598c0cb3d 100644
--- a/packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml
+++ b/packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml
@@ -24,24 +24,13 @@
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
- <dependencySets>
- <dependencySet>
- <useProjectArtifact>true</useProjectArtifact>
- <outputDirectory>${file.separator}lib</outputDirectory>
- <unpack>false</unpack>
- <scope>runtime</scope>
- <includes>
- <include>*:jar</include>
- </includes>
- </dependencySet>
- </dependencySets>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/resources/etc
</directory>
<includes>
- <include>*.json</include>
<include>*.xml</include>
+ <include>*.yaml</include>
</includes>
<outputDirectory>${file.separator}etc</outputDirectory>
<lineEnding>unix</lineEnding>
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json b/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json
deleted file mode 100644
index a6a3ff0f8..000000000
--- a/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json
+++ /dev/null
@@ -1,53 +0,0 @@
-{
- "name": "ControlLoopRuntimeGroup",
- "restServerParameters": {
- "host": "0.0.0.0",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "https": false,
- "aaf": false
- },
- "participantParameters": {
- "heartBeatMs": 120000,
- "updateParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- },
- "stateChangeParameters": {
- "maxRetryCount": 1,
- "maxWaitMs": 30000
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.mariadb.jdbc.Driver",
- "databaseUrl": "jdbc:mariadb://mariadb:3306/controlloop",
- "databaseUser": "policy",
- "databasePassword": "P01icY",
- "persistenceUnit": "CommissioningMariaDb"
- },
- "topicParameterGroup": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [ "message-router" ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [ "message-router" ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [ "message-router" ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
-}
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml
new file mode 100644
index 000000000..3970d15f1
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.yaml
@@ -0,0 +1,54 @@
+spring:
+ security:
+ user:
+ name: healthcheck
+ password: zb!XztG34
+ http:
+ converters:
+ preferred-json-mapper: gson
+
+security:
+ enable-csrf: false
+
+server:
+ port: 6969
+ servlet:
+ context-path: /onap/controlloop
+ error:
+ path: /error
+
+
+runtime:
+ supervisionScannerIntervalSec: 1000
+ participantClUpdateIntervalSec: 1000
+ participantClStateChangeIntervalSec: 1000
+ participantParameters:
+ heartBeatMs: 120000
+ updateParameters:
+ maxRetryCount: 1
+ maxWaitMs: 30000
+ stateChangeParameters:
+ maxRetryCount: 1
+ maxWaitMs: 30000
+ databaseProviderParameters:
+ name: PolicyProviderParameterGroup
+ implementation: org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl
+ databaseDriver: org.mariadb.jdbc.Driver
+ databaseUrl: jdbc:mariadb://${mariadb.host:mariadb}:${mariadb.port:3306}/controlloop
+ databaseUser: policy
+ databasePassword: P01icY
+ persistenceUnit: CommissioningMariaDb
+ topicParameterGroup:
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json b/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json
deleted file mode 100644
index f3ff62325..000000000
--- a/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json
+++ /dev/null
@@ -1,70 +0,0 @@
-{
- "name": "ControlLoopParticipantDcae",
- "clampClientParameters": {
- "clientName": "Clamp",
- "hostname": "0.0.0.0",
- "port": 8443,
- "userName": "admin",
- "password": "password",
- "useHttps": true,
- "allowSelfSignedCerts": false
- },
- "consulClientParameters": {
- "clientName": "Consul",
- "hostname": "consul",
- "port": 31321,
- "userName": "admin",
- "password": "password",
- "useHttps": false
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "DCAEParticipant0",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
- "version": "2.3.4"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.mariadb.jdbc.Driver",
- "databaseUrl": "jdbc:mariadb://mariadb:3306/policyadmin",
- "databaseUser": "policy_user",
- "databasePassword": "policy_user",
- "persistenceUnit": "PolicyMariaDb"
- }
-}
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.yaml
new file mode 100644
index 000000000..5eedb9db4
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.yaml
@@ -0,0 +1,55 @@
+
+participant:
+ name: ControlLoopParticipantDcae
+ clampClientEndPoints:
+ status: /restservices/clds/v2/loop/getstatus/
+ create: /restservices/clds/v2/loop/create/%s?templateName=%s
+ deploy: /restservices/clds/v2/loop/deploy/
+ stop: /restservices/clds/v2/loop/stop/
+ delete: /restservices/clds/v2/loop/delete/
+ undeploy: /restservices/clds/v2/loop/undeploy/
+ clampClientParameters:
+ clientName: Clamp
+ hostname: 0.0.0.0
+ port: 8443
+ userName: admin
+ password: password
+ https: true
+ aaf: false
+ consulClientEndPoints:
+ deploy: "/v1/kv/dcae-pmsh:"
+ consulClientParameters:
+ clientName: Consul
+ hostname: consul
+ port: 31321
+ userName: admin
+ password: password
+ https: false
+ aaf: false
+ intermediaryParameters:
+ name: Participant parameters
+ reportingTimeIntervalMs: 120000
+ description: Participant Description
+ participantId:
+ name: DCAEParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
+ version: 2.3.4
+ clampControlLoopTopics:
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ checkCount: 10
+ secCount: 10
+ jsonBodyConsulPath: src/main/resources/parameters/consul.json
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml
new file mode 100644
index 000000000..d91cc7394
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/KubernetesParticipantParameters.yaml
@@ -0,0 +1,54 @@
+spring:
+ security:
+ user:
+ name: healthcheck
+ password: zb!XztG34
+security:
+ enable-csrf: false
+
+participant:
+ localChartDirectory: /var/helm-manager/local-charts
+ infoFileName: CHART_INFO.json
+ intermediaryParameters:
+ reportingTimeIntervalMs: 120000
+ description: Participant Description
+ participantId:
+ name: K8sParticipant0
+ version: 1.0.0
+ participantType:
+ name: org.onap.k8s.controlloop.K8SControlLoopParticipant
+ version: 2.3.4
+ clampControlLoopTopics:
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "loggers,logfile,health,info,metrics,threaddump,heapdump"
+server:
+ # Configuration of the HTTP/REST server. The parameters are defined and handled by the springboot framework.
+ # See springboot documentation.
+ port: 8083
+
+logging:
+ # Configuration of logging
+ level:
+ ROOT: INFO
+ org.springframework: ERROR
+ org.springframework.data: ERROR
+ org.springframework.web.reactive.function.client.ExchangeFunctions: ERROR
+ file:
+ name: /var/log/helm-manager/application.log
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json b/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json
deleted file mode 100644
index e2eb067d9..000000000
--- a/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json
+++ /dev/null
@@ -1,76 +0,0 @@
-{
- "name":"ParticipantParameterGroup",
- "participantStatusParameters":{
- "timeIntervalMs":10000,
- "description":"Participant Status",
- "participantId":{
- "name": "PolicyParticipant0",
- "version":"1.0.0"
- },
- "participantType":{
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version":"2.3.1"
- },
- "participantDefinition":{
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version":"2.3.1"
- }
- },
- "intermediaryParameters": {
- "name": "Participant parameters",
- "reportingTimeInterval": 120000,
- "description": "Participant Description",
- "participantId": {
- "name": "PolicyParticipant0",
- "version": "1.0.0"
- },
- "participantType": {
- "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
- "version": "2.3.1"
- },
- "clampControlLoopTopics": {
- "topicSources": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap",
- "fetchTimeout": 15000
- }
- ],
- "topicSinks": [
- {
- "topic": "POLICY-CLRUNTIME-PARTICIPANT",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- },
- {
- "topic": "POLICY-NOTIFICATION",
- "servers": [
- "message-router"
- ],
- "topicCommInfrastructure": "dmaap"
- }
- ]
- }
- },
- "databaseProviderParameters": {
- "name": "PolicyProviderParameterGroup",
- "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
- "databaseDriver": "org.mariadb.jdbc.Driver",
- "databaseUrl": "jdbc:mariadb://mariadb:3306/policyadmin",
- "databaseUser": "policy_user",
- "databasePassword": "policy_user",
- "persistenceUnit": "PolicyMariaDb"
- }
-}
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml b/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml
new file mode 100644
index 000000000..1ea5d68c0
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.yaml
@@ -0,0 +1,33 @@
+
+participant:
+ policyApiParameters:
+ clientName: api
+ hostname: policy-api
+ port: 6969
+ userName: healthcheck
+ password: zb!XztG34
+ https: true
+ allowSelfSignedCerts: true
+ intermediaryParameters:
+ reportingTimeIntervalMs: 120000
+ description: Participant Description
+ participantId:
+ name: org.onap.PM_Policy
+ version: 1.0.0
+ participantType:
+ name: org.onap.policy.controlloop.PolicyControlLoopParticipant
+ version: 2.3.1
+ clampControlLoopTopics:
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:message-router}
+ topicCommInfrastructure: dmaap
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml
index 115170e2c..a873f76b3 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-dcae/src/main/resources/config/application.yaml
@@ -1,3 +1,5 @@
+server:
+ port: 8081
participant:
name: ControlLoopParticipantDcae
@@ -37,15 +39,19 @@ participant:
name: org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant
version: 2.3.4
clampControlLoopTopics:
- topicSources[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
- fetchTimeout: 15000
- topicSinks[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
checkCount: 10
secCount: 10
jsonBodyConsulPath: src/main/resources/parameters/consul.json
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
index 68a1afd1a..a27c33d44 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/resources/config/application.yaml
@@ -19,15 +19,19 @@ participant:
name: org.onap.k8s.controlloop.K8SControlLoopParticipant
version: 2.3.4
clampControlLoopTopics:
- topicSources[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
- fetchTimeout: 15000
- topicSinks[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
management:
endpoints:
diff --git a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
index ef158ce97..32cd28cd3 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-policy/src/main/resources/config/application.yaml
@@ -1,3 +1,5 @@
+server:
+ port: 8082
participant:
policyApiParameters:
@@ -18,12 +20,16 @@ participant:
name: org.onap.policy.controlloop.PolicyControlLoopParticipant
version: 2.3.1
clampControlLoopTopics:
- topicSources[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
- fetchTimeout: 15000
- topicSinks[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
index 917c50db4..c26749b4d 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/config/application.yaml
@@ -5,7 +5,7 @@ spring:
password: zb!XztG34
server:
- port: 6969
+ port: 8084
servlet:
context-path: /onap/participantsim
error:
@@ -22,12 +22,16 @@ participant:
name: org.onap.PM_CDS_Blueprint
version: 1.0.0
clampControlLoopTopics:
- topicSources[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
- fetchTimeout: 15000
- topicSinks[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
index d9dee50bc..891d42072 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -23,10 +23,10 @@ package org.onap.policy.clamp.controlloop.runtime.commissioning;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
-import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -42,6 +42,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaProperty;
import org.onap.policy.models.tosca.authorative.concepts.ToscaRelationshipType;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
@@ -181,6 +182,171 @@ public class CommissioningProvider {
}
/**
+ * Get the initial node types with common or instance properties.
+ *
+ * @param fullNodeTypes map of all the node types in the specified template
+ * @param common boolean to indicate whether common or instance properties are required
+ * @return node types map that only has common properties
+ * @throws PfModelException on errors getting node type with common properties
+ */
+ private Map<String, ToscaNodeType> getInitialNodeTypesMap(
+ Map<String, ToscaNodeType> fullNodeTypes, boolean common) {
+
+ var tempNodeTypesMap = new HashMap<String, ToscaNodeType>();
+
+ fullNodeTypes.forEach((key, nodeType) -> {
+ var tempToscaNodeType = new ToscaNodeType();
+ tempToscaNodeType.setName(key);
+
+ var resultantPropertyMap = findCommonOrInstancePropsInNodeTypes(
+ nodeType, common);
+
+ if (!resultantPropertyMap.isEmpty()) {
+ tempToscaNodeType.setProperties(resultantPropertyMap);
+ tempNodeTypesMap.put(key, tempToscaNodeType);
+ }
+ });
+ return tempNodeTypesMap;
+ }
+
+ private Map<String, ToscaProperty> findCommonOrInstancePropsInNodeTypes(
+ ToscaNodeType nodeType, boolean common) {
+
+ var tempCommonPropertyMap = new HashMap<String, ToscaProperty>();
+ var tempInstancePropertyMap = new HashMap<String, ToscaProperty>();
+
+ nodeType.getProperties().forEach((propKey, prop) -> {
+
+ if (prop.getMetadata() != null) {
+ prop.getMetadata().forEach((k, v) -> {
+ if (k.equals("common") && v.equals("true") && common) {
+ tempCommonPropertyMap.put(propKey, prop);
+ } else if (k.equals("common") && v.equals("false") && !common) {
+ tempInstancePropertyMap.put(propKey, prop);
+ }
+
+ });
+ } else {
+ tempInstancePropertyMap.put(propKey, prop);
+ }
+ });
+
+ if (tempCommonPropertyMap.isEmpty() && !common) {
+ return tempInstancePropertyMap;
+ } else {
+ return tempCommonPropertyMap;
+ }
+ }
+
+ /**
+ * Get the node types derived from those that have common properties.
+ *
+ * @param initialNodeTypes map of all the node types in the specified template
+ * @param filteredNodeTypes map of all the node types that have common or instance properties
+ * @return all node types that have common properties including their children
+ * @throws PfModelException on errors getting node type with common properties
+ */
+ private Map<String, ToscaNodeType> getFinalNodeTypesMap(
+ Map<String, ToscaNodeType> initialNodeTypes,
+ Map<String, ToscaNodeType> filteredNodeTypes) {
+ for (var i = 0; i < initialNodeTypes.size(); i++) {
+ initialNodeTypes.forEach((key, nodeType) -> {
+ var tempToscaNodeType = new ToscaNodeType();
+ tempToscaNodeType.setName(key);
+
+ if (filteredNodeTypes.get(nodeType.getDerivedFrom()) != null) {
+ tempToscaNodeType.setName(key);
+
+ var finalProps = new HashMap<String, ToscaProperty>(
+ filteredNodeTypes.get(nodeType.getDerivedFrom()).getProperties());
+
+ tempToscaNodeType.setProperties(finalProps);
+ } else {
+ return;
+ }
+ filteredNodeTypes.putIfAbsent(key, tempToscaNodeType);
+
+ });
+ }
+ return filteredNodeTypes;
+ }
+
+ /**
+ * Get the requested node types with common or instance properties.
+ *
+ * @param common boolean indicating common or instance properties
+ * @param name the name of the definition to get, null for all definitions
+ * @param version the version of the definition to get, null for all definitions
+ * @return the node types with common or instance properties
+ * @throws PfModelException on errors getting node type properties
+ */
+ private Map<String, ToscaNodeType> getCommonOrInstancePropertiesFromNodeTypes(
+ boolean common, String name, String version)
+ throws PfModelException {
+ var serviceTemplates = new ToscaServiceTemplates();
+ serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
+ var tempNodeTypesMap =
+ this.getInitialNodeTypesMap(serviceTemplates.getServiceTemplates().get(0).getNodeTypes(), common);
+
+ return this.getFinalNodeTypesMap(
+ serviceTemplates.getServiceTemplates().get(0).getNodeTypes(), tempNodeTypesMap);
+
+ }
+
+ /**
+ * Get node templates with appropriate common or instance properties added.
+ *
+ * @param initialNodeTemplates map of all the node templates in the specified template
+ * @param nodeTypeProps map of all the node types that have common or instance properties including children
+ * @return all node templates with appropriate common or instance properties added
+ * @throws PfModelException on errors getting map of node templates with common or instance properties added
+ */
+ private Map<String, ToscaNodeTemplate> getDerivedCommonOrInstanceNodeTemplates(
+ Map<String, ToscaNodeTemplate> initialNodeTemplates,
+ Map<String, ToscaNodeType> nodeTypeProps) {
+
+ var finalNodeTemplatesMap = new HashMap<String, ToscaNodeTemplate>();
+
+ initialNodeTemplates.forEach((templateKey, template) -> {
+ if (nodeTypeProps.containsKey(template.getType())) {
+ var finalMergedProps = new HashMap<String, Object>();
+
+ nodeTypeProps.get(template.getType()).getProperties().forEach(finalMergedProps::putIfAbsent);
+
+ template.setProperties(finalMergedProps);
+
+ finalNodeTemplatesMap.put(templateKey, template);
+ } else {
+ return;
+ }
+ });
+ return finalNodeTemplatesMap;
+ }
+
+ /**
+ * Get node templates with common properties added.
+ *
+ * @param common boolean indicating common or instance properties to be used
+ * @param name the name of the definition to use, null for all definitions
+ * @param version the version of the definition to use, null for all definitions
+ * @return the nodes templates with common or instance properties
+ * @throws PfModelException on errors getting common or instance properties from node_templates
+ */
+ public Map<String, ToscaNodeTemplate> getNodeTemplatesWithCommonOrInstanceProperties(
+ boolean common, String name, String version) throws PfModelException {
+
+ var commonOrInstanceNodeTypeProps =
+ this.getCommonOrInstancePropertiesFromNodeTypes(common, name, version);
+
+ var serviceTemplates = new ToscaServiceTemplates();
+ serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
+
+ return this.getDerivedCommonOrInstanceNodeTemplates(
+ serviceTemplates.getServiceTemplates().get(0).getToscaTopologyTemplate().getNodeTemplates(),
+ commonOrInstanceNodeTypeProps);
+ }
+
+ /**
* Get the requested control loop definitions.
*
* @param name the name of the definition to get, null for all definitions
@@ -195,6 +361,30 @@ public class CommissioningProvider {
}
/**
+ * Get the tosca service template with only required sections.
+ *
+ * @param name the name of the template to get, null for all definitions
+ * @param version the version of the template to get, null for all definitions
+ * @return the tosca service template
+ * @throws PfModelException on errors getting tosca service template
+ */
+ public Map<String, Object> getToscaServiceTemplateReduced(String name, String version) throws PfModelException {
+ var serviceTemplates = new ToscaServiceTemplates();
+ serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
+
+ ToscaServiceTemplate fullTemplate = serviceTemplates.getServiceTemplates().get(0);
+
+ var template = new HashMap<String, Object>();
+ template.put("tosca_definitions_version", fullTemplate.getToscaDefinitionsVersion());
+ template.put("data_types", fullTemplate.getDataTypes());
+ template.put("policy_types", fullTemplate.getPolicyTypes());
+ template.put("node_types", fullTemplate.getNodeTypes());
+ template.put("topology_template", fullTemplate.getToscaTopologyTemplate());
+
+ return template;
+ }
+
+ /**
* Get the requested json schema.
*
* @param section section of the tosca service template to get schema for
@@ -203,9 +393,9 @@ public class CommissioningProvider {
* @throws JsonProcessingException on errors generating the schema
*/
public String getToscaServiceTemplateSchema(String section) throws PfModelException, JsonProcessingException {
- ObjectMapper mapper = new ObjectMapper();
+ var mapper = new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
- SchemaFactoryWrapper visitor = new SchemaFactoryWrapper();
+ var visitor = new SchemaFactoryWrapper();
switch (section) {
case "data_types":
@@ -234,9 +424,7 @@ public class CommissioningProvider {
mapper.acceptJsonFormatVisitor(mapper.constructType(ToscaServiceTemplate.class), visitor);
}
- JsonSchema jsonSchema = visitor.finalSchema();
- String response = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema);
-
- return response;
+ var jsonSchema = visitor.finalSchema();
+ return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema);
}
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
index 67c615dcd..8fe3c0c88 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
@@ -347,10 +347,10 @@ public class CommissioningController extends AbstractRestController {
required = false) String version) {
try {
- ObjectMapper mapper = new ObjectMapper();
+ var mapper = new ObjectMapper();
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
- String response = mapper.writerWithDefaultPrettyPrinter()
- .writeValueAsString(provider.getToscaServiceTemplate(name, version));
+ var response = mapper.writerWithDefaultPrettyPrinter()
+ .writeValueAsString(provider.getToscaServiceTemplateReduced(name, version));
return ResponseEntity.ok().body(response);
@@ -436,6 +436,79 @@ public class CommissioningController extends AbstractRestController {
}
/**
+ * Retrieves the Common or Instance Properties for the specified Tosca Service Template.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param common a flag, true to get common properties, false to get instance properties
+ * @param name the name of the tosca service template to retrieve
+ * @param version the version of the tosca service template to get
+ * @return the specified tosca service template or section Json Schema
+ */
+ // @formatter:off
+ @GetMapping(value = "/commission/getCommonOrInstanceProperties",
+ produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
+ @ApiOperation(value = "Query details of the requested tosca service template common or instance properties",
+ notes = "Queries details of the requested commissioned tosca service template json common"
+ + "or instance properties, returning all tosca service template common or instance property details",
+ response = ToscaServiceTemplate.class,
+ tags = {"Clamp Control Loop Commissioning API"},
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
+ )
+ // @formatter:on
+ public ResponseEntity<?> queryToscaServiceCommonOrInstanceProperties(
+ @RequestHeader(
+ name = REQUEST_ID_NAME,
+ required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Flag, true for common properties, false for instance", required = false) @RequestParam(
+ value = "common",
+ defaultValue = "false",
+ required = false) boolean common,
+ @ApiParam(value = "Tosca service template name", required = false) @RequestParam(
+ value = "name",
+ required = false) String name,
+ @ApiParam(value = "Tosca service template version", required = true) @RequestParam(
+ value = "version",
+ required = false) String version) {
+ try {
+ return ResponseEntity.ok().body(provider.getNodeTemplatesWithCommonOrInstanceProperties(
+ common, name, version));
+
+ } catch (PfModelRuntimeException | PfModelException e) {
+ LOGGER.warn("Get of common or instance properties failed", e);
+ var resp = new CommissioningResponse();
+ resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
+ return ResponseEntity.status(e.getErrorResponse().getResponseCode().getStatusCode()).body(resp);
+ }
+ }
+
+ /**
* Queries the elements of a specific control loop.
*
* @param requestId request ID used in ONAP logging
diff --git a/runtime-controlloop/src/main/resources/application.yaml b/runtime-controlloop/src/main/resources/application.yaml
index 1d36b6724..d0e5500d6 100644
--- a/runtime-controlloop/src/main/resources/application.yaml
+++ b/runtime-controlloop/src/main/resources/application.yaml
@@ -31,17 +31,21 @@ runtime:
name: PolicyProviderParameterGroup
implementation: org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl
databaseDriver: org.mariadb.jdbc.Driver
- databaseUrl: jdbc:mariadb://${mariadb.host:mariadb}:${mariadb.port:3306}/controlloop
+ databaseUrl: jdbc:mariadb://${mariadb.host:localhost}:${mariadb.port:3306}/controlloop
databaseUser: policy
databasePassword: P01icY
persistenceUnit: CommissioningMariaDb
topicParameterGroup:
- topicSources[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
- fetchTimeout: 15000
- topicSinks[0]:
- topic: POLICY-CLRUNTIME-PARTICIPANT
- servers[0]: ${topicServer:message-router}
- topicCommInfrastructure: dmaap
+ topicSources:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ -
+ topic: POLICY-CLRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
diff --git a/runtime/extra/sql/bulkload/create-db.sql b/runtime/extra/sql/bulkload/create-db.sql
index ea4d97c1b..5fa34ca04 100644
--- a/runtime/extra/sql/bulkload/create-db.sql
+++ b/runtime/extra/sql/bulkload/create-db.sql
@@ -7,5 +7,9 @@ USE `cldsdb4`;
DROP USER 'clds';
CREATE USER 'clds';
GRANT ALL on cldsdb4.* to 'clds' identified by 'sidnnd83K' with GRANT OPTION;
+CREATE DATABASE `controlloop`;
+USE `controlloop`;
+DROP USER 'policy';
+CREATE USER 'policy';
+GRANT ALL on controlloop.* to 'policy' identified by 'P01icY' with GRANT OPTION;
FLUSH PRIVILEGES;
-
diff --git a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
index 01ee071ee..677ec64c9 100644
--- a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -1724,6 +1724,41 @@
</route>
</get>
+ <get uri="/v2/toscaControlLoop/getCommonOrInstanceProperties" outType="java.lang.String" bindingMode="off" produces="application/json">
+ <route>
+ <removeHeaders pattern="*"
+ excludePattern="name|version|requestId|common"/>
+ <doTry>
+ <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'GET Common Properties ')"/>
+ <to uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','read')"/>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setProperty name="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-common-or-instance-properties"/>
+ <to uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/>
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/>
+ <log loggingLevel="ERROR"
+ message="GET Common Or Instance Properties request failed: ${exception.stacktrace}"/>
+ <setHeader name="CamelHttpResponseCode">
+ <constant>500</constant>
+ </setHeader>
+ <setBody>
+ <simple>GET Common Properties FAILED</simple>
+ </setBody>
+ </doCatch>
+ </doTry>
+ </route>
+ </get>
+
<post uri="/v2/toscaControlLoop/postToscaInstantiation"
type="java.lang.String"
consumes="plain/text"
diff --git a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
index 2c063f105..ff39200b7 100644
--- a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
+++ b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
@@ -238,4 +238,32 @@
</doFinally>
</doTry>
</route>
+ <route id="get-common-or-instance-properties">
+ <from uri="direct:get-common-or-instance-properties"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Getting Common Or Instance Properties"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('ControlLoop', 'Getting Common Or Instance Properties')"/>
+ <setHeader name="CamelHttpMethod">
+ <constant>GET</constant>
+ </setHeader>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setProperty name="common">
+ <simple>${header.common}</simple>
+ </setProperty>
+ <log loggingLevel="INFO"
+ message="Endpoint to get Common Or Instance Properties: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/getCommonOrInstanceProperties"></log>
+ <toD
+ uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/commission/getCommonOrInstanceProperties?common=${exchangeProperty[common]}&amp;bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.controlloop.runtime.userName}}&amp;authPassword={{clamp.config.controlloop.runtime.password}}&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <convertBodyTo type="java.lang.String"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
</routes>
diff --git a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java
index a1eaf27d0..f4e171174 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java
@@ -147,4 +147,51 @@ public class RuntimeCommissioningResponseTestItCase {
assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
.is2xxSuccessful()).isTrue();
}
+
+ @Test
+ public void testGetCommonOrInstancePropertiesCommonTrue() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send("direct:get-common-or-instance-properties", ExchangeBuilder.anExchange(camelContext)
+ .withProperty("name", "ToscaServiceTemplate")
+ .withProperty("version", "1.0.0")
+ .withProperty("common", true)
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+ .is2xxSuccessful()).isTrue();
+ }
+
+ @Test
+ public void testGetCommonOrInstancePropertiesCommonFalse() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send("direct:get-common-or-instance-properties", ExchangeBuilder.anExchange(camelContext)
+ .withProperty("name", "ToscaServiceTemplate")
+ .withProperty("version", "1.0.0")
+ .withProperty("common", false)
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+ .is2xxSuccessful()).isTrue();
+ }
+
+ @Test
+ public void testGetCommonOrInstancePropertiesCommonMissing() {
+ ProducerTemplate prodTemplate = camelContext.createProducerTemplate();
+
+ Exchange exchangeResponse =
+ prodTemplate.send("direct:get-common-or-instance-properties", ExchangeBuilder.anExchange(camelContext)
+ .withProperty("name", "ToscaServiceTemplate")
+ .withProperty("version", "1.0.0")
+ .withProperty("raiseHttpExceptionFlag", "true")
+ .build());
+
+ assertThat(HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
+ .is2xxSuccessful()).isTrue();
+ }
}
diff --git a/runtime/src/test/resources/http-cache/example/node_template.json b/runtime/src/test/resources/http-cache/example/node_template.json
new file mode 100644
index 000000000..fdbfe8563
--- /dev/null
+++ b/runtime/src/test/resources/http-cache/example/node_template.json
@@ -0,0 +1,44 @@
+{
+ "org.onap.domain.pmsh.PMSHControlLoopDefinition": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3",
+ "derived_from": null,
+ "metadata": {},
+ "description": "Control loop for Performance Management Subscription Handling",
+ "type": "org.onap.policy.clamp.controlloop.ControlLoop",
+ "type_version": "1.0.0",
+ "properties": {
+ "elements": [
+ {
+ "name": "org.onap.domain.pmsh.PMSH_DCAEMicroservice",
+ "version": "1.2.3"
+ },
+ {
+ "name": "org.onap.domain.pmsh.PMSH_MonitoringPolicyControlLoopElement",
+ "version": "1.2.3"
+ },
+ {
+ "name": "org.onap.domain.pmsh.PMSH_OperationalPolicyControlLoopElement",
+ "version": "1.2.3"
+ }
+ ],
+ "provider": "Ericsson"
+ },
+ "requirements": null,
+ "capabilities": null,
+ "identifier": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "type_identifier": {
+ "name": "org.onap.policy.clamp.controlloop.ControlLoop",
+ "version": "1.0.0"
+ },
+ "key": {
+ "name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "version": "1.2.3"
+ },
+ "defined_name": "org.onap.domain.pmsh.PMSHControlLoopDefinition",
+ "defined_version": "1.2.3"
+ }
+}
diff --git a/runtime/src/test/resources/http-cache/third_party_proxy.py b/runtime/src/test/resources/http-cache/third_party_proxy.py
index 2a28c65d3..013388197 100644
--- a/runtime/src/test/resources/http-cache/third_party_proxy.py
+++ b/runtime/src/test/resources/http-cache/third_party_proxy.py
@@ -294,16 +294,24 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
return True
elif (self.path.startswith("/onap/controlloop/v2/commission/elements")) and http_type == "GET":
- print "self.path start with /commission/elements Control Loop Elements, generating response json..."
- #jsondata = json.loads(self.data_string)
- jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSH_DCAEMicroservice\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]"
- self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
+ if not _file_available:
+ print "self.path start with /commission/elements Control Loop Elements, generating response json..."
+ jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSH_DCAEMicroservice\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]"
+ self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
return True
elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "GET":
- print "self.path start with /commission control loop definition, generating response json..."
- #jsondata = json.loads(self.data_string)
- jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSHControlLoopDefinition\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]"
- self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
+ if not _file_available:
+ print "self.path start with /commission control loop definition, generating response json..."
+ #jsondata = json.loads(self.data_string)
+ jsonGenerated = "[{\"name\": ,\"org.onap.domain.pmsh.PMSHControlLoopDefinition\": [{ \"version\": \"1.2.3\", \"derived_from\": null }]}]"
+ self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
+ return True
+ elif (self.path.startswith("/onap/controlloop/v2/commission/getCommonOrInstanceProperties")) and http_type == "GET":
+ if not _file_available:
+ print "self.path start with /commission getting common properties, generating response json..."
+ with open("example/node_template.json", "r") as f:
+ jsonGenerated = f.read()
+ self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
return True
elif (self.path.startswith("/onap/controlloop/v2/commission")) and http_type == "POST":
print "self.path start with POST /onap/controlloop/v2/commission, copying body to response ..."
@@ -318,7 +326,6 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler):
print "self.path start with /commission Decommissioning, generating response json..."
jsonGenerated = "{\"errorDetails\": null,\"affectedControlLoopDefinitions\": [{ \"name\": \"ToscaServiceTemplateSimple\", \"version\": \"1.0.0\" }]}"
self._create_cache(jsonGenerated, cached_file_folder, cached_file_header, cached_file_content)
-
return True
else:
return False