summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/ConfigVolume.java36
-rw-r--r--mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java5
-rw-r--r--mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java3
-rw-r--r--mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java175
-rw-r--r--mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java7
-rw-r--r--mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json4
-rw-r--r--mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json55
-rw-r--r--mod/onboardingapi/ChangeLog.md8
-rw-r--r--mod/onboardingapi/dcae_cli/_version.py2
-rw-r--r--mod/onboardingapi/pom.xml3
-rw-r--r--mod/runtimeapi/runtime-core/src/test/data/blueprints/helloworld_no_edits.yaml4
-rw-r--r--mod/runtimeapi/runtime-web/src/test/data/compspecs/componentSpec_hello_world.json6
12 files changed, 293 insertions, 15 deletions
diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/ConfigVolume.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/ConfigVolume.java
new file mode 100644
index 0000000..23842cc
--- /dev/null
+++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/ConfigVolume.java
@@ -0,0 +1,36 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2021 Nokia. 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.blueprintgenerator.model.componentspec.common;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+@Data
+@JsonInclude(value = JsonInclude.Include.NON_NULL)
+@EqualsAndHashCode
+public class ConfigVolume {
+
+ private String name;
+
+}
diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java
index 9e9f9b1..3dd756f 100644
--- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java
+++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * Copyright (c) 2021 Nokia. 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.
@@ -25,6 +26,7 @@ package org.onap.blueprintgenerator.model.componentspec.common;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -44,6 +46,9 @@ public class Volumes {
private Host host;
+ @JsonProperty("config_volume")
+ private ConfigVolume configVolume;
+
private String type;
private String name;
diff --git a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java
index 0526f48..a84afb6 100644
--- a/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java
+++ b/mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/service/base/BlueprintHelperService.java
@@ -178,7 +178,7 @@ public class BlueprintHelperService {
* <p>
* Default input type: "string".
*
- * @param inputType Input type, supported: "boolean", "integer"
+ * @param inputType Input type, supported: "boolean", "integer", "number"
* @param defaultValue Default value of Type
* @return
*/
@@ -187,6 +187,7 @@ public class BlueprintHelperService {
case "boolean":
return createBooleanInput(defaultValue);
case "integer":
+ case "number":
return createIntegerInput(defaultValue);
default:
return createStringInput(defaultValue);
diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java
new file mode 100644
index 0000000..61f9353
--- /dev/null
+++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/service/common/AppConfigServiceTest.java
@@ -0,0 +1,175 @@
+/*
+ *
+ * * ============LICENSE_START=======================================================
+ * * org.onap.dcae
+ * * ================================================================================
+ * * Copyright (c) 2021 Nokia 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.blueprintgenerator.service.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.onap.blueprintgenerator.model.common.Appconfig;
+import org.onap.blueprintgenerator.model.common.GetInput;
+import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
+import org.onap.blueprintgenerator.model.componentspec.common.Parameters;
+import org.onap.blueprintgenerator.service.InfoService;
+import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
+import org.onap.blueprintgenerator.service.common.kafka.KafkaStreamService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {AppConfigService.class, BlueprintHelperService.class, DmaapService.class,
+ InfoService.class, StreamService.class, KafkaStreamService.class},
+ initializers = ConfigFileApplicationContextInitializer.class)
+public class AppConfigServiceTest {
+
+ private static final String TEST_PARAMETER_NAME = "testParameter";
+ private static final String INPUTS = "inputs";
+ private static final String TYPE = "type";
+ private static final String DEFAULT = "default";
+
+ private static final String PARAMETERS_TYPE_STRING = "string";
+ private static final String PARAMETERS_TYPE_INTEGER = "integer";
+ private static final String PARAMETERS_TYPE_BOOLEAN = "boolean";
+ private static final String PARAMETERS_TYPE_NUMBER = "number";
+
+ private static final String STRING_INPUT_TYPE = "string";
+ private static final String INTEGER_INPUT_TYPE = "integer";
+ private static final String BOOLEAN_INPUT_TYPE = "boolean";
+ private static final String UNKNOWN_TYPE = "test_unknown_type";
+
+ private static final boolean BOOLEAN_TEST_VALUE = true;
+ private static final String TEST_STRING_VALUE = "testValue";
+ private static final String APP_CONFIG = "appconfig";
+
+ @Autowired
+ private AppConfigService appConfigService;
+
+ private OnapComponentSpec componentSpec;
+
+ @Before
+ public void setUp() {
+ componentSpec = Mockito.mock(OnapComponentSpec.class);
+ }
+
+ @Test
+ public void shouldCreateStringInputForStringParameter() {
+
+ mockParameters(PARAMETERS_TYPE_STRING, TEST_STRING_VALUE);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(STRING_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(TEST_STRING_VALUE, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateStringInputForUnknownParameter() {
+
+ mockParameters(UNKNOWN_TYPE, TEST_STRING_VALUE);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(STRING_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(TEST_STRING_VALUE, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateBooleanInputForBooleanParameter() {
+
+ mockParameters(PARAMETERS_TYPE_BOOLEAN, BOOLEAN_TEST_VALUE);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(BOOLEAN_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(BOOLEAN_TEST_VALUE, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateIntegerInputForIntegerParameter() {
+
+ mockParameters(PARAMETERS_TYPE_INTEGER, 123);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(INTEGER_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(123, createdParameters.get(DEFAULT));
+ }
+
+ @Test
+ public void shouldCreateIntegerInputForNumberParameter() {
+
+ mockParameters(PARAMETERS_TYPE_NUMBER, 123);
+ Map<String, LinkedHashMap<String, Object>> inputs = new HashMap<>();
+
+ Map<String, Object> appConfig = appConfigService.createAppconfig(inputs, componentSpec, false);
+ Map<String, Object> createdInputs = (Map<String, Object>) appConfig.get(INPUTS);
+ Map<String, Object> createdParameters = (Map<String, Object>) createdInputs.get(TEST_PARAMETER_NAME);
+
+
+ assertAppConfigContainsParameterWithCorrectInputName(appConfig);
+ assertEquals(INTEGER_INPUT_TYPE, createdParameters.get(TYPE));
+ assertEquals(123, createdParameters.get(DEFAULT));
+ }
+
+ private void assertAppConfigContainsParameterWithCorrectInputName(Map<String, Object> appConfig) {
+ Appconfig appConfigModel = (Appconfig) appConfig.get(APP_CONFIG);
+ Object bpInputName = ((GetInput) appConfigModel.getParams().get(TEST_PARAMETER_NAME)).getBpInputName();
+ assertEquals(bpInputName, TEST_PARAMETER_NAME);
+ }
+
+ private void mockParameters(String type, Object value) {
+ Parameters testParameter = new Parameters();
+ testParameter.setName(TEST_PARAMETER_NAME);
+ testParameter.setType(type);
+ testParameter.setSourced_at_deployment(true);
+ testParameter.setValue(value);
+ Parameters[] parametersArray = new Parameters[1];
+ parametersArray[0] = testParameter;
+ when(componentSpec.getParameters()).thenReturn(parametersArray);
+ }
+}
diff --git a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java
index 01845ab..4b37ed8 100644
--- a/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java
+++ b/mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java
@@ -4,6 +4,7 @@
* * org.onap.dcae
* * ================================================================================
* * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+ * * Copyright (c) 2021 Nokia. 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.
@@ -44,6 +45,7 @@ import org.springframework.stereotype.Component;
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -364,6 +366,11 @@ public class OnapTestUtils extends BlueprintGeneratorTests {
assertNotNull(
type + " Blueprint:NodeTemplates:DockerConfig:LiveHealthcheck Section is NULL",
onapVolumes);
+ assertNotNull(type + " Blueprint:NodeTemplates:DockerConfig:Volumes:ConfigVolume:GetName Section is NULL", Arrays.stream(onapVolumes)
+ .filter(c -> c.getConfigVolume() != null)
+ .filter(c -> c.getName() != null)
+ .filter(c -> c.equals("myConfig"))
+ .findAny());
}
/**
diff --git a/mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json b/mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json
index 822a7b1..8a64e71 100644
--- a/mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json
+++ b/mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json
@@ -316,6 +316,10 @@
"host": {
"path": "/opt/logs/DCAE/VESCollector/etc"
}
+ },
+ {
+ "container": { "bind": "/opt/app/etc/config" },
+ "config_volume": { "name":"myConfig" }
}
],
"ports": [
diff --git a/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json b/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json
index 7d576c0..56dbf3a 100644
--- a/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json
+++ b/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json
@@ -874,17 +874,10 @@
"type": "array",
"items": {
"type": "object",
- "properties": {
- "host":{
- "type":"object",
- "path": {"type": "string"}
- },
- "container":{
- "type":"object",
- "bind": { "type": "string"},
- "mode": { "type": "string"}
- }
- }
+ "oneOf": [
+ { "$ref": "#/definitions/host_path_volume" },
+ { "$ref": "#/definitions/config_map_volume" }
+ ]
}
}
},
@@ -893,6 +886,46 @@
],
"additionalProperties": false
},
+ "host_path_volume": {
+ "type": "object",
+ "properties": {
+ "host": {
+ "type": "object",
+ "path": {
+ "type": "string"
+ }
+ },
+ "container": {
+ "type": "object",
+ "bind": {
+ "type": "string"
+ },
+ "mode": {
+ "type": "string"
+ }
+ }
+ }
+ },
+ "config_map_volume": {
+ "type": "object",
+ "properties": {
+ "config_volume": {
+ "type": "object",
+ "name": {
+ "type": "string"
+ }
+ },
+ "container": {
+ "type": "object",
+ "bind": {
+ "type": "string"
+ },
+ "mode": {
+ "type": "string"
+ }
+ }
+ }
+ },
"docker_healthcheck_http": {
"properties": {
"type": {
diff --git a/mod/onboardingapi/ChangeLog.md b/mod/onboardingapi/ChangeLog.md
index 28578d2..4413ded 100644
--- a/mod/onboardingapi/ChangeLog.md
+++ b/mod/onboardingapi/ChangeLog.md
@@ -5,6 +5,14 @@ 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/).
+## [2.12.4]
+
+* Update component-spec-schema to support: kafka stream subscribes and publishes, config maps as volumes
+
+## [2.12.3]
+
+* Add Python 3.8 support
+* Use Integration base image
## [2.12.1]
diff --git a/mod/onboardingapi/dcae_cli/_version.py b/mod/onboardingapi/dcae_cli/_version.py
index cc7b983..7081b3b 100644
--- a/mod/onboardingapi/dcae_cli/_version.py
+++ b/mod/onboardingapi/dcae_cli/_version.py
@@ -19,4 +19,4 @@
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
# -*- coding: utf-8 -*-
-__version__ = "2.12.3"
+__version__ = "2.12.4"
diff --git a/mod/onboardingapi/pom.xml b/mod/onboardingapi/pom.xml
index e8f97a0..796816f 100644
--- a/mod/onboardingapi/pom.xml
+++ b/mod/onboardingapi/pom.xml
@@ -3,6 +3,7 @@
================================================================================
Copyright (c) 2017-2020 AT&T Intellectual Property. All rights reserved.
Copyright 2020 Deutsche Telekom. All rights reserved.
+Copyright 2021 Nokia 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.
@@ -23,7 +24,7 @@ limitations under the License.
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>dcaegen2-platform-mod-onboardingapi</artifactId>
<name>dcaegen2-platform-mod-onboardingapi</name>
- <version>2.12.3-SNAPSHOT</version>
+ <version>2.12.4-SNAPSHOT</version>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
diff --git a/mod/runtimeapi/runtime-core/src/test/data/blueprints/helloworld_no_edits.yaml b/mod/runtimeapi/runtime-core/src/test/data/blueprints/helloworld_no_edits.yaml
index 2bf4bea..6198f36 100644
--- a/mod/runtimeapi/runtime-core/src/test/data/blueprints/helloworld_no_edits.yaml
+++ b/mod/runtimeapi/runtime-core/src/test/data/blueprints/helloworld_no_edits.yaml
@@ -181,6 +181,10 @@ node_templates:
bind: /opt/app/vcc/archive/data
host:
path: /opt/data/DCAE/helloworldpm/vcc-archive
+ - container:
+ bind: /opt/app/etc/config
+ config_volume:
+ name: myConfig
image:
get_input: image
location_id:
diff --git a/mod/runtimeapi/runtime-web/src/test/data/compspecs/componentSpec_hello_world.json b/mod/runtimeapi/runtime-web/src/test/data/compspecs/componentSpec_hello_world.json
index cd394f8..62470ef 100644
--- a/mod/runtimeapi/runtime-web/src/test/data/compspecs/componentSpec_hello_world.json
+++ b/mod/runtimeapi/runtime-web/src/test/data/compspecs/componentSpec_hello_world.json
@@ -126,7 +126,11 @@
"host": {
"path": "/opt/data/DCAE/helloworldpm/vcc-archive"
}
- }
+ },
+ {
+ "container": { "bind": "/opt/app/etc/config" },
+ "config_volume": { "name":"myConfig" }
+ }
]
},