Add support for config_volume in blueprint generator 44/117144/6
authorTomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>
Wed, 27 Jan 2021 07:12:10 +0000 (08:12 +0100)
committerTomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>
Wed, 27 Jan 2021 14:28:49 +0000 (15:28 +0100)
Change-Id: I8160df49d20722d393eacd27049aabbb637ae6f1
Issue-ID: DCAEGEN2-2546
Signed-off-by: Tomasz Pietruszkiewicz <tomasz.pietruszkiewicz@nokia.com>
mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/ConfigVolume.java [new file with mode: 0644]
mod/bpgenerator/common/src/main/java/org/onap/blueprintgenerator/model/componentspec/common/Volumes.java
mod/bpgenerator/onap/src/test/java/org/onap/blueprintgenerator/test/OnapTestUtils.java
mod/bpgenerator/onap/src/test/resources/componentspecs/ves.json
mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json
mod/runtimeapi/runtime-core/src/test/data/blueprints/helloworld_no_edits.yaml
mod/runtimeapi/runtime-web/src/test/data/compspecs/componentSpec_hello_world.json

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 (file)
index 0000000..23842cc
--- /dev/null
@@ -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;
+
+}
index 9e9f9b1..3dd756f 100644 (file)
@@ -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;
index 01845ab..4b37ed8 100644 (file)
@@ -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());
     }
 
     /**
index 822a7b1..8a64e71 100644 (file)
         "host": {
           "path": "/opt/logs/DCAE/VESCollector/etc"
         }
+      },
+      {
+        "container": { "bind": "/opt/app/etc/config" },
+        "config_volume": { "name":"myConfig" }
       }
     ],
     "ports": [
index 7d576c0..56dbf3a 100644 (file)
           "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" }
+            ]
           }
         }
       },
       ],
       "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": {
index 2bf4bea..6198f36 100644 (file)
@@ -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:
index cd394f8..62470ef 100644 (file)
                        "host": {
                                "path": "/opt/data/DCAE/helloworldpm/vcc-archive"
                        }
-               }
+               },
+                       {
+                               "container": { "bind": "/opt/app/etc/config" },
+                               "config_volume": { "name":"myConfig" }
+                       }
                
         ]        
     },