summaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
Diffstat (limited to 'mod')
-rw-r--r--mod/runtimeapi/Changelog.md5
-rw-r--r--mod/runtimeapi/pom.xml11
-rw-r--r--mod/runtimeapi/runtime-core/pom.xml14
-rw-r--r--mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClient.java28
-rw-r--r--mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImpl.java112
-rw-r--r--mod/runtimeapi/runtime-core/src/test/data/compspecs/vesWithDb.json452
-rw-r--r--mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImplTest.java67
-rw-r--r--mod/runtimeapi/runtime-web/pom.xml15
-rw-r--r--mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/controllers/GraphController.java25
-rw-r--r--mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java20
-rw-r--r--mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphActionsParser.java92
-rw-r--r--mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceHelmProxy.java120
-rw-r--r--mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceImpl.java66
-rw-r--r--mod/runtimeapi/runtime-web/src/main/resources/application.properties12
14 files changed, 947 insertions, 92 deletions
diff --git a/mod/runtimeapi/Changelog.md b/mod/runtimeapi/Changelog.md
index 3dd643c..5baa372 100644
--- a/mod/runtimeapi/Changelog.md
+++ b/mod/runtimeapi/Changelog.md
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [1.3.0] - 2021-09-16
+- [DCAEGEN2-2694] Integrate helm chart generator
+ - create a switch to toggle between blueprint and helm based deployment types
+- [DCAEGEN2-2805] Update commons-io version to 2.8.0
+
## [1.2.3]
- Update BPGenerator 1.7.3
- Update default k8splugin import
diff --git a/mod/runtimeapi/pom.xml b/mod/runtimeapi/pom.xml
index 11e5580..db6d2e2 100644
--- a/mod/runtimeapi/pom.xml
+++ b/mod/runtimeapi/pom.xml
@@ -34,7 +34,7 @@ limitations under the License.
</parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtimeapi</artifactId>
- <version>1.2.3</version>
+ <version>1.3.0</version>
<name>dcaegen2-platform-mod-runtimeapi</name>
<description>MOD Runtime API</description>
<properties>
@@ -42,6 +42,7 @@ limitations under the License.
<maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
<sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
+ <enforcer.skip>true</enforcer.skip>
</properties>
<profiles>
<profile>
@@ -66,7 +67,13 @@ limitations under the License.
</properties>
</profile>
</profiles>
-
+ <dependencies>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.8.0</version>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<!-- support sonar in multi-module project -->
diff --git a/mod/runtimeapi/runtime-core/pom.xml b/mod/runtimeapi/runtime-core/pom.xml
index 5514cc9..ff22a58 100644
--- a/mod/runtimeapi/runtime-core/pom.xml
+++ b/mod/runtimeapi/runtime-core/pom.xml
@@ -25,12 +25,12 @@ limitations under the License.
<parent>
<artifactId>runtimeapi</artifactId>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
- <version>1.2.3</version>
+ <version>1.3.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>runtime-core</artifactId>
- <version>1.2.3</version>
+ <version>1.3.0</version>
<dependencies>
<dependency>
@@ -48,11 +48,11 @@ limitations under the License.
<artifactId>blueprint-generator-onap</artifactId>
<version>1.7.3</version>
</dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20190722</version>
- </dependency>
+ <dependency>
+ <groupId>org.onap.dcaegen2.platform</groupId>
+ <artifactId>helmchartgenerator-core</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
diff --git a/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClient.java b/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClient.java
new file mode 100644
index 0000000..cc5fdca
--- /dev/null
+++ b/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClient.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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=========================================================
+ */
+
+package org.onap.dcae.runtime.core.helm;
+
+import java.io.File;
+
+public interface HelmChartGeneratorClient {
+
+ File generateHelmChart(String componentSpec);
+
+ void distribute(File helmChart);
+}
diff --git a/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImpl.java b/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImpl.java
new file mode 100644
index 0000000..49ca3de
--- /dev/null
+++ b/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImpl.java
@@ -0,0 +1,112 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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=========================================================
+ */
+
+package org.onap.dcae.runtime.core.helm;
+
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.io.FileUtils;
+import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.ChartBuilder;
+import org.onap.dcaegen2.platform.helmchartgenerator.distribution.ChartDistributor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+
+/**
+ * Implementation class for Helm Chart Generator Client
+ */
+@Slf4j
+@Component
+@ComponentScan(basePackages = "org.onap.dcaegen2.platform.helmchartgenerator")
+public class HelmChartGeneratorClientImpl implements HelmChartGeneratorClient {
+
+ @Autowired
+ private final ChartBuilder chartBuilder;
+
+ @Autowired
+ private final ChartDistributor distributor;
+
+ @Value("${helm.base.chart.template.location}")
+ private String templateLocation;
+
+ public HelmChartGeneratorClientImpl(ChartBuilder chartBuilder, ChartDistributor distributor) {
+ this.chartBuilder = chartBuilder;
+ this.distributor = distributor;
+ }
+
+ /**
+ * Generate Helm Chart for a component spec
+ * @param componentSpec component spec as String
+ * @return packaged helm chart
+ */
+ @Override
+ public File generateHelmChart(String componentSpec){
+ try {
+ return chartBuilder.build(createTempSpecFile(componentSpec),templateLocation,
+ createTempChartOutputLocation(), "");
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ throw new RuntimeException("Error while generating the helm chart.");
+ }
+ }
+
+ private String createTempChartOutputLocation() {
+ try {
+ return Files.createTempDirectory("chart").toAbsolutePath().toString();
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ throw new RuntimeException("Error creating a temporary chart dir.");
+ }
+ }
+
+ private String createTempSpecFile(String componentSpec) throws IOException{
+ File tmpFile = File.createTempFile("spec",".json");
+ try (FileWriter writer = new FileWriter(tmpFile)) {
+ writer.write(componentSpec);
+ }
+ return tmpFile.getAbsolutePath();
+ }
+
+ /**
+ * Distributes helm chart to Chart Museum
+ * @param helmChart packaged chart location
+ */
+ @Override
+ public void distribute(File helmChart) {
+ try {
+ distributor.distribute(helmChart);
+ }catch (Exception e){
+ throw e;
+ } finally {
+ removeChartLocally(helmChart);
+ }
+ }
+
+ private void removeChartLocally(File helmChart) {
+ try {
+ FileUtils.forceDelete(helmChart);
+ } catch (IOException e) {
+ log.warn("Could not delete a temporary helm chart " + helmChart.getName());
+ }
+ }
+}
diff --git a/mod/runtimeapi/runtime-core/src/test/data/compspecs/vesWithDb.json b/mod/runtimeapi/runtime-core/src/test/data/compspecs/vesWithDb.json
new file mode 100644
index 0000000..207be6d
--- /dev/null
+++ b/mod/runtimeapi/runtime-core/src/test/data/compspecs/vesWithDb.json
@@ -0,0 +1,452 @@
+{
+ "self": {
+ "version": "1.8.0",
+ "name": "dcae-ves-collector",
+ "description": "Collector for receiving VES events through restful interface",
+ "component_type": "docker"
+ },
+ "streams": {
+ "subscribes": [],
+ "publishes": [
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-fault"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-measurement"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-syslog"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-heartbeat"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-other"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-mobileflow"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-statechange"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-thresholdCrossingAlert"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-voicequality"
+ },
+ {
+ "format": "VES_specification",
+ "version": "5.28.4",
+ "type": "message router",
+ "config_key": "ves-sipsignaling"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-pnfRegistration"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-notification"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-perf3gpp"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-3gpp-fault-supervision"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-3gpp-provisioning"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-3gpp-heartbeat"
+ },
+ {
+ "format": "VES_specification",
+ "version": "7.30.2",
+ "type": "message router",
+ "config_key": "ves-3gpp-performance-assurance"
+ }
+ ]
+ },
+ "services": {
+ "calls": [],
+ "provides": [
+ {
+ "route": "/eventListener/v1",
+ "verb": "POST",
+ "request": {
+ "format": "VES_specification",
+ "version": "4.27.2"
+ },
+ "response": {
+ "format": "ves.coll.response",
+ "version": "1.0.0"
+ }
+ },
+ {
+ "route": "/eventListener/v2",
+ "verb": "POST",
+ "request": {
+ "format": "VES_specification",
+ "version": "4.27.2"
+ },
+ "response": {
+ "format": "ves.coll.response",
+ "version": "1.0.0"
+ }
+ },
+ {
+ "route": "/eventListener/v3",
+ "verb": "POST",
+ "request": {
+ "format": "VES_specification",
+ "version": "4.27.2"
+ },
+ "response": {
+ "format": "ves.coll.response",
+ "version": "1.0.0"
+ }
+ },
+ {
+ "route": "/eventListener/v4",
+ "verb": "POST",
+ "request": {
+ "format": "VES_specification",
+ "version": "4.27.2"
+ },
+ "response": {
+ "format": "ves.coll.response",
+ "version": "1.0.0"
+ }
+ },
+ {
+ "route": "/eventListener/v5",
+ "verb": "POST",
+ "request": {
+ "format": "VES_specification",
+ "version": "5.28.4"
+ },
+ "response": {
+ "format": "ves.coll.response",
+ "version": "1.0.0"
+ }
+ },
+ {
+ "route": "/eventListener/v7",
+ "verb": "POST",
+ "request": {
+ "format": "VES_specification",
+ "version": "7.30.2"
+ },
+ "response": {
+ "format": "ves.coll.response",
+ "version": "1.0.0"
+ }
+ }
+ ]
+ },
+ "parameters": [
+ {
+ "name": "streams_publishes",
+ "value": {
+ "ves-fault": {
+ "dmaap_info": {
+ "topic_url": "http://message-router:3904/events/unauthenticated.SEC_FAULT_OUTPUT"
+ },
+ "type": "message_router"
+ }
+ },
+ "description": "standard http port collector will open for listening;",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ }
+ ,
+ {
+ "name": "collector.service.port",
+ "value": 8080,
+ "description": "standard http port collector will open for listening;",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.service.secure.port",
+ "value": 8443,
+ "description": "secure http port collector will open for listening ",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": true
+ },
+ {
+ "name": "collector.keystore.file.location",
+ "value": "/opt/app/dcae-certificate/cert.jks",
+ "description": "fs location of keystore file in vm",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.keystore.passwordfile",
+ "value": "/opt/app/dcae-certificate/jks.pass",
+ "description": "location of keystore password file in vm",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.truststore.file.location",
+ "value": "/opt/app/dcae-certificate/trust.jks",
+ "description": "fs location of truststore file in vm",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.truststore.passwordfile",
+ "value": "/opt/app/dcae-certificate/trust.pass",
+ "description": "location of truststore password file in vm",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.dmaap.streamid",
+ "value": "fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling|notification=ves-notification|pnfRegistration=ves-pnfRegistration|3GPP-FaultSupervision=ves-3gpp-fault-supervision|3GPP-Heartbeat=ves-3gpp-heartbeat|3GPP-Provisioning=ves-3gpp-provisioning|3GPP-PerformanceAssurance=ves-3gpp-performance-assurance",
+ "description": "domain-to-streamid mapping used by VESCollector to distributes events based on domain. Both primary and secondary config_key are included for resilency (multiple streamid can be included commma separated). The streamids MUST match to topic config_keys. For single site without resiliency deployment - configkeys with -secondary suffix can be removed",
+ "sourced_at_deployment": true,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "auth.method",
+ "value": "noAuth",
+ "description": "Property to manage application mode, possible configurations: noAuth - default option - no security (http) , certOnly - auth by certificate (https), basicAuth - auth by basic auth username and password (https),certBasicAuth - auth by certificate and basic auth username / password (https),",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "header.authlist",
+ "value": "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy",
+ "description": "List of id and base 64 encoded password.For each onboarding VNF - unique userid and password should be assigned and communicated to VNF owner. Password value should be base64 encoded in config here",
+ "policy_editable": false,
+ "sourced_at_deployment": true,
+ "designer_editable": true
+ },
+ {
+ "name": "collector.schema.checkflag",
+ "value": 1,
+ "description": "Schema check validation flag. When enabled, collector will validate input VES events against VES Schema defined on collector.schema.file ",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.schema.file",
+ "value": "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.1.json\",\"v7\":\"./etc/CommonEventFormat_30.2.1_ONAP.json\"}",
+ "description": "VES schema file name per version used for validation",
+ "designer_editable": true,
+ "sourced_at_deployment": false,
+ "policy_editable": false
+ },
+ {
+ "name": "event.transform.flag",
+ "value": 1,
+ "description": "flag to enable tranformation rules defined under eventTransform.json; this is applicable when event tranformation rules preset should be activated for transforming <VES5.4 events to 5.4",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "tomcat.maxthreads",
+ "value": "200",
+ "description": "Tomcat control for concurrent request",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.externalSchema.checkflag",
+ "value": 1,
+ "description": "Schema stndDefined validation flag. When enabled, collector will validate stndDefined fields in stndDefined domain events against mapped local schemas listed in file from property collector.externalSchema.mappingFileLocation.",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": true
+ },
+ {
+ "name": "collector.externalSchema.schemasLocation",
+ "value": "./etc/externalRepo/",
+ "description": "External schemas repository. Path to schemas storage directory.",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.externalSchema.mappingFileLocation",
+ "value": "./etc/externalRepo/schema-map.json",
+ "description": "Path to JSON file containing mapping of externally located stndDefined schemas to local schema files.",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "event.externalSchema.schemaRefPath",
+ "value": "$.event.stndDefinedFields.schemaReference",
+ "description": "An internal path from validated JSON. Defines which field is taken as public schema reference, which is later mapped.",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "event.externalSchema.stndDefinedDataPath",
+ "value": "$.event.stndDefinedFields.data",
+ "description": "An internal path from validated JSON. Defines which field of event will be validated during stndDefined validation.",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ },
+ {
+ "name": "collector.description.api.version.location",
+ "value": "etc/api_version_description.json",
+ "description": "Path to the file containing description of api versions",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
+ }
+ ],
+ "auxilary": {
+ "helm": {
+ "applicationEnv": {
+ "PMSH_PG_URL": "dcae-pmsh-pg-primary",
+ "PMSH_PG_USERNAME": {
+ "secretUid": "pgUserCredsSecretUid",
+ "key": "login"
+ },
+ "PMSH_PG_PASSWORD": {
+ "secretUid": "pgUserCredsSecretUid",
+ "key": "password"
+ }
+ },
+ "service": {
+ "type": "NodePort",
+ "name": "dcae-ves-collector",
+ "has_internal_only_ports": true,
+ "ports": [
+ {
+ "name": "http",
+ "port": 8443,
+ "plain_port": 8080,
+ "port_protocol": "http",
+ "nodePort": 17,
+ "useNodePortExt": true
+ },
+ {
+ "name": "metrics",
+ "port": 4444,
+ "internal_only": true
+ }
+ ]
+ }
+ },
+ "healthcheck": {
+ "type": "http",
+ "interval": "15s",
+ "timeout": "1s",
+ "endpoint": "/healthcheck",
+ "port": 8080,
+ "initialDelaySeconds": 5
+ },
+ "volumes": [{
+ "config_volume": {
+ "name": "dcae-external-repo-configmap-schema-map"
+ },
+ "container": {
+ "bind": "/opt/app/VESCollector/etc/externalRepo/"
+ }
+ }, {
+ "config_volume": {
+ "name": "dcae-external-repo-configmap-sa88-rel16"
+ },
+ "container": {
+ "bind": "/opt/app/VESCollector/etc/externalRepo/3gpp/rep/sa5/MnS/blob/SA88-Rel16/OpenAPI/"
+ }
+ }],
+ "ports": [
+ "8080:0",
+ "8443:0"
+ ],
+ "log_info": {
+ "log_directory": "/opt/app/VESCollector/logs/"
+ },
+ "tls_info":{
+ "cert_directory":"/opt/app/dcae-certificate/",
+ "use_tls": true,
+ "use_external_tls": true
+ }
+ },
+ "policy_info":{
+ "policy":[
+ {
+ "node_label":"tca_policy_00",
+ "policy_model_id":"onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "policy_id":"tca_policy_id_10"
+ },
+ {
+ "node_label":"tca_policy_11",
+ "policy_id":"tca_policy_id_11",
+ "policy_model_id":"onap.policies.monitoring.cdap.tca.hi.lo.app"
+ }
+ ]
+ },
+ "artifacts": [
+ {
+ "type": "docker image",
+ "uri": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest"
+ }
+ ]
+} \ No newline at end of file
diff --git a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImplTest.java b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImplTest.java
new file mode 100644
index 0000000..da58550
--- /dev/null
+++ b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/helm/HelmChartGeneratorClientImplTest.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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=========================================================
+ */
+package org.onap.dcae.runtime.core.helm;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.dcaegen2.platform.helmchartgenerator.chartbuilder.ChartBuilder;
+import org.onap.dcaegen2.platform.helmchartgenerator.distribution.ChartDistributor;
+
+import java.io.File;
+import java.nio.file.Files;
+
+import static org.mockito.ArgumentMatchers.any;
+
+@RunWith(MockitoJUnitRunner.class)
+public class HelmChartGeneratorClientImplTest {
+
+ @Mock
+ private ChartBuilder chartBuilder;
+
+ @Mock
+ private ChartDistributor distributor;
+
+ private HelmChartGeneratorClientImpl client;
+
+ private File mockChartFile;
+
+ @Before
+ public void setUp() throws Exception {
+ client = new HelmChartGeneratorClientImpl(chartBuilder, distributor);
+ mockChartFile = Files.createTempFile("chart", ".tgz").toFile();
+ }
+
+ @Test
+ public void testGenerateHelmChart() throws Exception{
+ client.generateHelmChart("someSpec");
+ Mockito.verify(chartBuilder, Mockito.times(1)).build(any(), any(), any(), any());
+ }
+
+ @Test
+ public void testDistribute() throws Exception{
+ client.distribute(mockChartFile);
+ Mockito.verify(distributor, Mockito.times(1)).distribute(mockChartFile);
+ }
+
+}
diff --git a/mod/runtimeapi/runtime-web/pom.xml b/mod/runtimeapi/runtime-web/pom.xml
index 8b70ea4..f2f3515 100644
--- a/mod/runtimeapi/runtime-web/pom.xml
+++ b/mod/runtimeapi/runtime-web/pom.xml
@@ -24,10 +24,10 @@ limitations under the License.
<parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtimeapi</artifactId>
- <version>1.2.3</version>
+ <version>1.3.0</version>
</parent>
<artifactId>runtime-web</artifactId>
- <version>1.2.3-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>runtime-web</name>
<description>MOD Runtime Web Module</description>
@@ -35,7 +35,7 @@ limitations under the License.
<dependency>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>runtime-core</artifactId>
- <version>1.2.3</version>
+ <version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -74,11 +74,6 @@ limitations under the License.
<version>3.0.0</version>
</dependency>
<dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20190722</version>
- </dependency>
- <dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
@@ -121,7 +116,9 @@ limitations under the License.
<descriptorRef>artifact</descriptorRef>
</assembly>
<runCmds>
- <runCmd>groupadd -r dcaemod &amp;&amp; useradd -ms /bin/bash dcaemod -g dcaemod &amp;&amp; mkdir -p /maven/data &amp;&amp; chown -R dcaemod:dcaemod /maven/data</runCmd>
+ <runCmd>apt-get update &amp;&amp; apt-get install -y wget</runCmd>
+ <runCmd>wget https://get.helm.sh/helm-v3.0.2-linux-amd64.tar.gz &amp;&amp; tar xvf helm-v3.0.2-linux-amd64.tar.gz &amp;&amp; mv linux-amd64/helm /usr/local/bin/</runCmd>
+ <runCmd>groupadd -r dcaemod &amp;&amp; useradd -ms /bin/bash dcaemod -g dcaemod &amp;&amp; mkdir -p /maven/data &amp;&amp; chown -R dcaemod:dcaemod /maven/data</runCmd>
</runCmds>
<workdir>/maven</workdir>
<volumes>
diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/controllers/GraphController.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/controllers/GraphController.java
index fc222f2..484a426 100644
--- a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/controllers/GraphController.java
+++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/controllers/GraphController.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021 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.
@@ -17,28 +17,35 @@
*/
package org.onap.dcae.runtime.web.controllers;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
import org.onap.dcae.runtime.core.Edge;
import org.onap.dcae.runtime.core.FlowGraph;
-import org.onap.dcae.runtime.core.Node;
import org.onap.dcae.runtime.core.FlowGraphParser.BlueprintVessel;
+import org.onap.dcae.runtime.core.Node;
import org.onap.dcae.runtime.web.exception.MainGraphNotFoundException;
-import org.onap.dcae.runtime.web.models.*;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
import org.onap.dcae.runtime.web.models.DistributeGraphRequest;
import org.onap.dcae.runtime.web.models.GraphRequest;
+import org.onap.dcae.runtime.web.service.GraphService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-import org.onap.dcae.runtime.web.service.GraphServiceImpl;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
-import java.util.Map;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
@RestController
@RequestMapping(value = "/api/graph")
@@ -46,7 +53,7 @@ import java.util.List;
public class GraphController {
@Autowired
- private GraphServiceImpl graphService;
+ private GraphService graphService;
Logger logger = LoggerFactory.getLogger(GraphController.class);
diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java
index 789c9d1..d63deeb 100644
--- a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java
+++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/BlueprintInventory.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021 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.
@@ -17,6 +17,7 @@
*/
package org.onap.dcae.runtime.web.service;
+import org.json.JSONException;
import org.onap.dcae.runtime.core.FlowGraphParser.BlueprintVessel;
import org.onap.dcae.runtime.web.models.DashboardConfig;
import org.json.JSONObject;
@@ -46,7 +47,6 @@ public class BlueprintInventory {
JSONObject body = prepareBlueprintJsonObject(bpv.name, bpv.version, bpv.blueprint);
postToDashboard(body);
logger.info(String.format("Distributed: %s", bpv.toString()));
- //System.out.println(bpv.blueprint);
}
}
@@ -74,12 +74,16 @@ public class BlueprintInventory {
private JSONObject prepareBlueprintJsonObject(String blueprintName, int version, String blueprintContent) {
JSONObject blueprintJsonObject = new JSONObject();
- blueprintJsonObject.put("owner","dcae_mod");
- blueprintJsonObject.put("typeName",blueprintName);
- blueprintJsonObject.put("typeVersion",version);
- blueprintJsonObject.put("blueprintTemplate",blueprintContent);
- blueprintJsonObject.put("application","DCAE");
- blueprintJsonObject.put("component","dcae");
+ try {
+ blueprintJsonObject.put("owner","dcae_mod");
+ blueprintJsonObject.put("typeName",blueprintName);
+ blueprintJsonObject.put("typeVersion",version);
+ blueprintJsonObject.put("blueprintTemplate",blueprintContent);
+ blueprintJsonObject.put("application","DCAE");
+ blueprintJsonObject.put("component","dcae");
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
return blueprintJsonObject;
}
diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphActionsParser.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphActionsParser.java
new file mode 100644
index 0000000..5d290a7
--- /dev/null
+++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphActionsParser.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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=========================================================
+ */
+package org.onap.dcae.runtime.web.service;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.onap.dcae.runtime.core.Edge;
+import org.onap.dcae.runtime.core.EdgeLocation;
+import org.onap.dcae.runtime.core.FlowGraph;
+import org.onap.dcae.runtime.core.FlowGraphParser;
+import org.onap.dcae.runtime.core.Node;
+import org.onap.dcae.runtime.web.exception.ActionsNotDefinedException;
+import org.onap.dcae.runtime.web.models.Action;
+import org.onap.dcae.runtime.web.models.DistributeGraphRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * A helper class that parses the actions from the request and apply them to the main graph
+ */
+@Component
+public class GraphActionsParser {
+
+ @Autowired
+ private FlowGraphParser flowGraphParser;
+
+ void applyActionsToGraph(FlowGraph<Node, Edge> mainFlowGraph, DistributeGraphRequest distributeGraphRequest) {
+ if(distributeGraphRequest.getActions() == null){
+ throw new ActionsNotDefinedException("Action(s) must be defined in the request");
+ }
+ for(Action action : distributeGraphRequest.getActions()){
+ if(action.getCommand().equals("addnode")){
+ Node node = prepareNodeFromAddNAddNodeAction(action);
+ mainFlowGraph.addNode(node);
+ }
+ else if(action.getCommand().equals("addedge")) {
+ Edge edge = prepareEdgeFromAddEdgeAction(action);
+ Node srcNode = flowGraphParser.getNodeFromId(edge.getSrc().getNode());
+ Node tgtNode = flowGraphParser.getNodeFromId(edge.getTgt().getNode());
+ srcNode = fillPlaceholderIfNodeIsEmpty(srcNode);
+ tgtNode =fillPlaceholderIfNodeIsEmpty(tgtNode);
+ mainFlowGraph.addEdge(srcNode,tgtNode,edge);
+ }
+ }
+ }
+
+ private Node fillPlaceholderIfNodeIsEmpty(Node node) {
+ if (node == null) {
+ node = flowGraphParser.getNodeFromId("dummy_id");
+ }
+ return node;
+ }
+
+
+ private Edge prepareEdgeFromAddEdgeAction(Action action) {
+ ObjectMapper objectMapper = new ObjectMapper();
+ Edge edge = objectMapper.convertValue(action.getPayload(),Edge.class);
+ return edge;
+ }
+
+ private void fillPlaceholderIfLocaionsAreEmpty(Edge edge) {
+ if(edge.getSrc().getNode() == null && edge.getSrc().getPort() == null){
+ EdgeLocation src = new EdgeLocation("node-id-placeholder", "node-port-placeholder");
+ edge.setSrc(src);
+ }
+ if(edge.getTgt().getNode() == null && edge.getTgt().getPort() == null){
+ EdgeLocation tgt = new EdgeLocation("node-id-placeholder", "node-port-placeholder");
+ edge.setTgt(tgt);
+ }
+ }
+
+ private Node prepareNodeFromAddNAddNodeAction(Action action) {
+ String componentId = (String) action.getPayload().get("component_id");
+ String componentName = (String) action.getPayload().get("name");
+ String componentSpec = (String) action.getPayload().get("component_spec");
+ return new Node(componentId,componentName,componentSpec);
+ }
+}
diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceHelmProxy.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceHelmProxy.java
new file mode 100644
index 0000000..89c9d47
--- /dev/null
+++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceHelmProxy.java
@@ -0,0 +1,120 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 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=========================================================
+ */
+
+package org.onap.dcae.runtime.web.service;
+
+import org.onap.dcae.runtime.core.BlueprintData;
+import org.onap.dcae.runtime.core.Edge;
+import org.onap.dcae.runtime.core.FlowGraph;
+import org.onap.dcae.runtime.core.FlowGraphParser;
+import org.onap.dcae.runtime.core.Node;
+import org.onap.dcae.runtime.core.helm.HelmChartGeneratorClient;
+import org.onap.dcae.runtime.web.models.DistributeGraphRequest;
+import org.onap.dcae.runtime.web.models.GraphRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A proxy class which will be enable if artifact.type is set to HELM
+ */
+@Service
+@Primary
+@ConditionalOnProperty(
+ value="artifact.type",
+ havingValue = "HELM",
+ matchIfMissing = true)
+@ComponentScan(basePackages = "org.onap.dcae.runtime.core")
+public class GraphServiceHelmProxy implements GraphService {
+
+ @Autowired
+ private GraphService defaultGraphService;
+
+ @Autowired
+ private HelmChartGeneratorClient helmChartGeneratorClient;
+
+ @Autowired
+ private GraphActionsParser actionsParser;
+
+ /**
+ * returns a main graph
+ * @return main graph
+ */
+ @Override
+ public FlowGraph<Node, Edge> getMainGraph() {
+ return defaultGraphService.getMainGraph();
+ }
+
+ /**
+ * initialize a main graph
+ * @param mainGraph a main graph request
+ */
+ @Override
+ public boolean initializeMainGraph(GraphRequest mainGraph) {
+ return defaultGraphService.initializeMainGraph(mainGraph);
+ }
+
+ /**
+ * apply actions on the main graph and creates, distributes helm charts
+ * @param distributeGraphRequest distribute request
+ * @return list of distributed charts
+ */
+ @Override
+ public List<FlowGraphParser.BlueprintVessel> distribute(DistributeGraphRequest distributeGraphRequest) {
+ actionsParser.applyActionsToGraph(getMainGraph(), distributeGraphRequest);
+ return createHelmCharts();
+ }
+
+ public List<FlowGraphParser.BlueprintVessel> createHelmCharts() {
+ final FlowGraph<Node, Edge> flowGraph = getMainGraph();
+ List<FlowGraphParser.BlueprintVessel> blueprints = new ArrayList<>();
+ for(Node node : flowGraph.getNodes()){
+ if(node.getComponentId().equals("dummy_id")){
+ continue;
+ }
+ final File helmChart = helmChartGeneratorClient.generateHelmChart(node.getComponentSpec());
+ helmChartGeneratorClient.distribute(helmChart);
+ BlueprintData blueprintData = new BlueprintData("1", helmChart.getName());
+ node.setBlueprintData(blueprintData);
+ blueprints.add(createBlueprintVessel(helmChart));
+ }
+ return blueprints;
+ }
+
+ private FlowGraphParser.BlueprintVessel createBlueprintVessel(File helmChart) {
+ FlowGraphParser.BlueprintVessel bpv = new FlowGraphParser.BlueprintVessel();
+ bpv.blueprint = helmChart.getName();
+ bpv.version = 1;
+ bpv.name = helmChart.getName();
+ return bpv;
+ }
+
+ /**
+ * deletes main graph
+ */
+ @Override
+ public void deleteMainGraph() {
+ defaultGraphService.deleteMainGraph();
+ }
+}
diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceImpl.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceImpl.java
index f1329c1..94d4b40 100644
--- a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceImpl.java
+++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/service/GraphServiceImpl.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2021 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.
@@ -17,15 +17,15 @@
*/
package org.onap.dcae.runtime.web.service;
-import org.onap.dcae.runtime.core.*;
+import org.onap.dcae.runtime.core.Edge;
+import org.onap.dcae.runtime.core.FlowGraph;
+import org.onap.dcae.runtime.core.FlowGraphParser;
import org.onap.dcae.runtime.core.FlowGraphParser.BlueprintVessel;
-import org.onap.dcae.runtime.web.exception.ActionsNotDefinedException;
+import org.onap.dcae.runtime.core.Node;
import org.onap.dcae.runtime.web.exception.MainGraphAlreadyExistException;
import org.onap.dcae.runtime.web.exception.MainGraphNotFoundException;
-import org.onap.dcae.runtime.web.models.Action;
import org.onap.dcae.runtime.web.models.DistributeGraphRequest;
import org.onap.dcae.runtime.web.models.GraphRequest;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -46,6 +46,9 @@ public class GraphServiceImpl implements GraphService{
@Autowired
private FlowGraphParser flowGraphParser;
+ @Autowired
+ private GraphActionsParser actionsParser;
+
@Override
public FlowGraph<Node, Edge> getMainGraph() {
if(mainFlowGraph == null){
@@ -74,7 +77,7 @@ public class GraphServiceImpl implements GraphService{
public List<BlueprintVessel> distribute(DistributeGraphRequest distributeGraphRequest) {
//1.Iterate through list of actions
logger.info("applying actions to graph");
- applyActionsToGraph(distributeGraphRequest);
+ actionsParser.applyActionsToGraph(mainFlowGraph, distributeGraphRequest);
//2. generate blueprint from compspec of the node
logger.info("generating blueprints for the affected nodes");
@@ -99,56 +102,5 @@ public class GraphServiceImpl implements GraphService{
return flowGraphParser.createAndProcessBlueprints();
}
- private void applyActionsToGraph(DistributeGraphRequest distributeGraphRequest) {
- if(distributeGraphRequest.getActions() == null){
- throw new ActionsNotDefinedException("Action(s) must be defined in the request");
- }
- for(Action action : distributeGraphRequest.getActions()){
- if(action.getCommand().equals("addnode")){
- Node node = prepareNodeFromAddNAddNodeAction(action);
- mainFlowGraph.addNode(node);
- }
- else if(action.getCommand().equals("addedge")) {
- Edge edge = prepareEdgeFromAddEdgeAction(action);
- Node srcNode = flowGraphParser.getNodeFromId(edge.getSrc().getNode());
- Node tgtNode = flowGraphParser.getNodeFromId(edge.getTgt().getNode());
- srcNode = fillPlaceholderIfNodeIsEmpty(srcNode);
- tgtNode =fillPlaceholderIfNodeIsEmpty(tgtNode);
- mainFlowGraph.addEdge(srcNode,tgtNode,edge);
- }
- }
- }
-
- private Node fillPlaceholderIfNodeIsEmpty(Node node) {
- if (node == null) {
- node = flowGraphParser.getNodeFromId("dummy_id");
- }
- return node;
- }
-
-
- private Edge prepareEdgeFromAddEdgeAction(Action action) {
- ObjectMapper objectMapper = new ObjectMapper();
- Edge edge = objectMapper.convertValue(action.getPayload(),Edge.class);
- return edge;
- }
-
- private void fillPlaceholderIfLocaionsAreEmpty(Edge edge) {
- if(edge.getSrc().getNode() == null && edge.getSrc().getPort() == null){
- EdgeLocation src = new EdgeLocation("node-id-placeholder", "node-port-placeholder");
- edge.setSrc(src);
- }
- if(edge.getTgt().getNode() == null && edge.getTgt().getPort() == null){
- EdgeLocation tgt = new EdgeLocation("node-id-placeholder", "node-port-placeholder");
- edge.setTgt(tgt);
- }
- }
-
- private Node prepareNodeFromAddNAddNodeAction(Action action) {
- String componentId = (String) action.getPayload().get("component_id");
- String componentName = (String) action.getPayload().get("name");
- String componentSpec = (String) action.getPayload().get("component_spec");
- return new Node(componentId,componentName,componentSpec);
- }
}
diff --git a/mod/runtimeapi/runtime-web/src/main/resources/application.properties b/mod/runtimeapi/runtime-web/src/main/resources/application.properties
index f3b06aa..31d56d8 100644
--- a/mod/runtimeapi/runtime-web/src/main/resources/application.properties
+++ b/mod/runtimeapi/runtime-web/src/main/resources/application.properties
@@ -24,3 +24,15 @@ onap.import.postgresPlugin=https://nexus.onap.org/service/local/repositories/raw
onap.import.clampPlugin=https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/clamppolicyplugin/1.1.0/clamppolicyplugin_types.yaml
onap.import.dmaapPlugin= https://nexus.onap.org/content/repositories/raw/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml
+
+# The artifact type can be BLUEPRINT or HELM
+artifact.type=BLUEPRINT
+
+#set these properties if artifact.type is HELM
+helm.base.chart.template.location=./data/helm-base-template
+
+chartmuseum.baseurl=http://localhost:8081
+
+chartmuseum.auth.basic.username=
+
+chartmuseum.auth.basic.password=