summaryrefslogtreecommitdiffstats
path: root/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint
diff options
context:
space:
mode:
Diffstat (limited to 'blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint')
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java42
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java66
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java43
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java13
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java4
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java272
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java125
-rw-r--r--blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java71
8 files changed, 448 insertions, 188 deletions
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
index e4f1230..5159814 100644
--- a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java
@@ -48,7 +48,7 @@ public class Appconfig {
return params;
}
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapAppconfig(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs) {
+ public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
retInputs = inps;
@@ -58,23 +58,26 @@ public class Appconfig {
//set the stream publishes
TreeMap<String, DmaapObj> streamPublishes = new TreeMap<String, DmaapObj>();
-
+ int counter = 0;
if(cs.getStreams().getPublishes().length != 0) {
for(Publishes p: cs.getStreams().getPublishes()) {
if(p.getType().equals("data_router") || p.getType().equals("data router")) {
//in this case the data router information gets added to the params so for now leave it alone
String config = p.getConfig_key();
DmaapObj pub = new DmaapObj();
- retInputs = pub.createOnapDmaapDRObj(retInputs, config, 'p');
+ String name = "feed" + counter;
+ retInputs = pub.createOnapDmaapDRObj(retInputs, config, 'p', "feed" + counter, name);
pub.setType(p.getType());
streamPublishes.put(config, pub);
} else if(p.getType().equals("message_router") || p.getType().equals("message router")) {
String config = p.getConfig_key();
DmaapObj pub = new DmaapObj();
- retInputs = pub.createOnapDmaapMRObj(retInputs, config, 'p');
+ String name = "topic" + counter;
+ retInputs = pub.createOnapDmaapMRObj(retInputs, config, 'p', "topic" + counter, name);
pub.setType(p.getType());
streamPublishes.put(config, pub);
}
+ counter++;
}
}
@@ -87,16 +90,19 @@ public class Appconfig {
//in this case the data router information gets added to the params so for now leave it alone
String config = s.getConfig_key();
DmaapObj sub = new DmaapObj();
- retInputs = sub.createOnapDmaapDRObj(retInputs, config, 'p');
+ String name = "feed" + counter;
+ retInputs = sub.createOnapDmaapDRObj(retInputs, config, 'p', "feed" + counter, name);
sub.setType(s.getType());
streamSubscribes.put(config, sub);
} else if(s.getType().equals("message_router") || s.getType().equals("message router")) {
String config = s.getConfig_key();
DmaapObj sub = new DmaapObj();
- retInputs = sub.createOnapDmaapMRObj(retInputs, config, 's');
+ String name = "topic" + counter;
+ retInputs = sub.createOnapDmaapMRObj(retInputs, config, 's', "topic" + counter, name);
sub.setType(s.getType());
streamSubscribes.put(config, sub);
}
+ counter++;
}
}
@@ -131,24 +137,20 @@ public class Appconfig {
else {
parameters.put(pName, p.getValue());
}
-
}
}
+ if(override != null) {
+ GetInput ov = new GetInput();
+ ov.setGet_input("service_component_name_override");
+ parameters.put("service_component_name_override", ov);
+ LinkedHashMap<String, Object> over = new LinkedHashMap<String, Object>();
+ over.put("type", "string");
+ over.put("default", override);
+ retInputs.put("service_component_name_override", over);
+ }
this.setParams(parameters);
return retInputs;
}
-// public void createTemplateAppconfig() {
-// //set service calls
-// CallsObj[] call = new CallsObj[0];
-// this.setService_calls(call);
-//
-// //set the stream publishes
-// TreeMap<String, DmaapObj> streamPublishes = new TreeMap<String, DmaapObj>();
-// this.setStream_publishes(streamPublishes);
-//
-// //set the stream subscribes
-// TreeMap<String, DmaapObj> streamSubscribes = new TreeMap<String, DmaapObj>();
-// this.setStream_subcribes(streamSubscribes);
-// }
+
}
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
index 861c820..06c42c5 100644
--- a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java
@@ -35,6 +35,7 @@ import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.blueprintgenerator.models.componentspec.Parameters;
import org.onap.blueprintgenerator.models.componentspec.Publishes;
import org.onap.blueprintgenerator.models.componentspec.Subscribes;
+import org.onap.blueprintgenerator.models.dmaapbp.DmaapBlueprint;
import org.onap.blueprintgenerator.models.onapbp.OnapBlueprint;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -60,29 +61,29 @@ public class Blueprint {
private String tosca_definitions_version;
+ private String description;
private ArrayList<String> imports;
-
private TreeMap<String, LinkedHashMap<String, Object>> inputs;
-
private TreeMap<String, Node> node_templates;
-
- public Blueprint createBlueprint(ComponentSpec cs, String name, char bpType, String importPath) {
+
+ public Blueprint createBlueprint(ComponentSpec cs, String name, char bpType, String importPath, String override) {
Blueprint bp = new Blueprint();
-
if(bpType == 'o') {
OnapBlueprint onap = new OnapBlueprint();
- bp = onap.createOnapBlueprint(cs, importPath);
+ bp = onap.createOnapBlueprint(cs, importPath, override);
+ bp = bp.setQuotations(bp);
+ }
+
+ if(bpType == 'd') {
+ DmaapBlueprint dmaap = new DmaapBlueprint();
+ bp = dmaap.createDmaapBlueprint(cs, importPath, override);
bp = bp.setQuotations(bp);
}
-// if(bpType == 't') {
-// bp.createBlueprintTemplate();
-// }
return bp;
}
-
public Blueprint setQuotations(Blueprint bp) {
for(String s: bp.getInputs().keySet()) {
LinkedHashMap<String, Object> temp = bp.getInputs().get(s);
@@ -96,51 +97,6 @@ public class Blueprint {
return bp;
}
-
-// public void createBlueprintTemplate() {
-// //set the tosca definition
-// this.setTosca_definitions_version("cloudify_dsl_1_3");
-//
-// //set the imports
-// Imports imps = new Imports();
-// this.setImports(imps.createOnapImports());
-//
-// //create the needed inputs and just add the default ones
-// TreeMap<String, LinkedHashMap<String, Object>> inputs = createTemplateInputs();
-// this.setInputs(inputs);
-//
-// //create a node template
-// TreeMap<String, Node> nodeTemplate = new TreeMap<String, Node>();
-// TemplateNode template = new TemplateNode();
-// template.createTemplateNode();
-// nodeTemplate.put("Blueprint_Template", template);
-// this.setNode_template(nodeTemplate);
-//
-//
-// }
-// //add tag, externam port, and replicas since they are in all the bps
-// public TreeMap<String, LinkedHashMap<String, Object>> createTemplateInputs() {
-// TreeMap<String, LinkedHashMap<String, Object>> inputs = new TreeMap<String, LinkedHashMap<String, Object>>();
-//
-// LinkedHashMap<String, Object> tag = new LinkedHashMap<String, Object>();
-// tag.put("type", "string");
-// tag.put("default", "{{ ONAPTEMPLATE_DOCKERREGURL_org_onap_dcaegen2_releases }}/onap/org.onap.dcaegen2.collectors.ves.vescollector:1.3.1");
-// inputs.put("tag_version", tag);
-//
-// LinkedHashMap<String, Object> port = new LinkedHashMap<String, Object>();
-// port.put("type", "string");
-// port.put("description", "Kubernetes node port on which collector is exposed");
-// port.put("default", "30235");
-// inputs.put("external_port", port);
-//
-// LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
-// rep.put("type", "integer");
-// rep.put("description", "number of instances");
-// rep.put("default", 1);
-// inputs.put("replicas", rep);
-//
-// return inputs;
-// }
public void blueprintToYaml(String outputPath, String bluePrintName, ComponentSpec cs) {
File outputFile;
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java
index 7a96100..10092c8 100644
--- a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java
@@ -25,34 +25,51 @@ import java.util.TreeMap;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
-import lombok.Getter; import lombok.Setter;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import lombok.Getter; import lombok.Setter;
+@JsonInclude(value=Include.NON_NULL)
@Getter @Setter
public class DmaapObj {
- private DmaapInfo dmaap_info;
+ private String dmaap_info;
private String type;
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
+ private GetInput pass;
+ private GetInput user;
+
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ LinkedHashMap<String, Object> stringType = new LinkedHashMap();
+ stringType.put("type", "string");
retInputs = inps;
-
+
//set the dmaapinfo
DmaapInfo info = new DmaapInfo();
- retInputs = info.createOnapDmaapMRInfo(retInputs, config, type);
- this.setDmaap_info(info);
-
+ String infoType = "<<" + n + ">>";
+ this.setDmaap_info(infoType);
+
+ //set username
+ GetInput u = new GetInput();
+ u.setGet_input(config + "_" + num +"_aaf_username");
+ this.setUser(u);
+ retInputs.put(config + "_" + num +"_aaf_username", stringType);
+
+ //set password
+ GetInput p = new GetInput();
+ p.setGet_input(config + "_" + num +"_aaf_password");
+ this.setPass(p);
+ retInputs.put(config + "_" + num +"_aaf_password", stringType);
+
return retInputs;
}
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type) {
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
retInputs = inps;
//set the dmaapinfo
DmaapInfo info = new DmaapInfo();
- retInputs = info.createOnapDmaapDRInfo(retInputs, config, type);
- this.setDmaap_info(info);
-
+ String infoType = "<<" + n + ">>";
+ this.setDmaap_info(infoType);
return retInputs;
}
}
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
index e4cea63..8bcdbbc 100644
--- a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java
@@ -42,20 +42,23 @@ import lombok.NoArgsConstructor;
@Getter @Setter
@JsonInclude(value=Include.NON_NULL)
public class Imports {
-
/** The imports. */
private ArrayList<String> imports;
public static ArrayList<String> createOnapImports() {
ArrayList<String> imps = new ArrayList<String>();
-
imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml");
imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml");
-
return imps;
}
-
+ public static ArrayList<String> createDmaapImports(){
+ ArrayList<String> imps = new ArrayList<String>();
+ imps.add("http://www.getcloudify.org/spec/cloudify/3.4/types.yaml");
+ imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R5/k8splugin/1.6.0/k8splugin_types.yaml");
+ imps.add("https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml");
+ return imps;
+ }
public static ArrayList<String> createImportsFromFile(String path) {
Imports imports = new Imports();
ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true));
@@ -65,12 +68,10 @@ public class Imports {
} catch (IOException e) {
throw new RuntimeException(e);
}
-
ArrayList<String> imps = new ArrayList<String>();
for(String s: imports.getImports()) {
imps.add(s);
}
-
return imps;
}
}
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
index 2688d9d..a3404f6 100644
--- a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java
@@ -30,11 +30,9 @@ import lombok.Getter; import lombok.Setter;
@Getter @Setter
public class Interfaces {
private Start start;
-
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapInterface(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
+ public TreeMap<String, LinkedHashMap<String, Object>> createInterface(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
retInputs = inps;
-
//create the start object
Start start = new Start();
retInputs = start.createOnapStart(retInputs, cs);
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
index 40770f3..6a06066 100644
--- a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java
@@ -1,31 +1,36 @@
/**============LICENSE_START=======================================================
org.onap.dcae
================================================================================
- Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+ Copyright (c) 2019 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
+ 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
+ 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=========================================================
+ 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.models.blueprint;
+import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
+import org.onap.blueprintgenerator.models.componentspec.Auxilary;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
import org.onap.blueprintgenerator.models.componentspec.HealthCheck;
+import org.onap.blueprintgenerator.models.componentspec.Publishes;
+import org.onap.blueprintgenerator.models.componentspec.Subscribes;
import org.onap.blueprintgenerator.models.componentspec.Volumes;
+import org.onap.blueprintgenerator.models.dmaapbp.DmaapStreams;
import org.onap.blueprintgenerator.models.onapbp.LogDirectory;
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -37,46 +42,54 @@ import lombok.Getter; import lombok.Setter;
@JsonInclude(value=Include.NON_NULL)
public class Properties {
private Appconfig application_config;
- private HealthCheck docker_config;
+ private Auxilary docker_config;
private Object image;
- private GetInput log_info;
+ private GetInput location_id;
+ private String service_component_type;
+ private TreeMap<String, Object> log_info;
private String dns_name;
private Object replicas;
private String name;
+ private GetInput topic_name;
+ private GetInput feed_name;
+ ArrayList<DmaapStreams> streams_publishes;
+ ArrayList<DmaapStreams> streams_subscribes;
+ private TreeMap<String, Object> tls_info;
+ private ResourceConfig resource_config;
+ private boolean useExisting;
- public TreeMap<String, LinkedHashMap<String, Object>> createOnapProperties(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs) {
+ public TreeMap<String, LinkedHashMap<String, Object>> createOnapProperties(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
retInputs = inps;
//set the image
GetInput image = new GetInput();
- image.setGet_input("tag_version");
+ image.setGet_input("image");
this.setImage(image);
LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
img.put("type", "string");
img.put("default", cs.getArtifacts()[0].getUri());
- retInputs.put("tag_version", img);
+ retInputs.put("image", img);
+
+ //set the location id
+ GetInput location = new GetInput();
+ location.setGet_input("location_id");
+ this.setLocation_id(location);
+ LinkedHashMap<String, Object> locMap = new LinkedHashMap();
+ locMap.put("type", "string");
+ locMap.put("default", "central");
//set the log info
GetInput logD = new GetInput();
logD.setGet_input("log_directory");
- this.setLog_info(logD);
- String logger = "";
- if(cs.getAuxilary().getVolumes() != null) {
- for(Volumes v: cs.getAuxilary().getVolumes()) {
- if(v.getContainer().getBind().contains("/opt/app/") && v.getContainer().getBind().contains("logs")) {
- logger = v.getContainer().getBind();
- }
- }
- }
+ TreeMap<String, Object> l = new TreeMap();
+ l.put("log_directory", logD);
+ this.setLog_info(l);
+ LinkedHashMap<String, Object> logMap = new LinkedHashMap();
+ logMap.put("type", "string");
+ logMap.put("default", "''");
+ retInputs.put("log_directory", logMap);
- LinkedHashMap<String, Object> logInp = new LinkedHashMap<String, Object>();
- logInp.put("type", "string");
- if(logger != "") {
- logInp.put("default", logger);
- }
- retInputs.put("log_directory", logInp);
-
//set the replicas
GetInput replica = new GetInput();
replica.setGet_input("replicas");
@@ -89,50 +102,181 @@ public class Properties {
//set the dns name
this.setDns_name(cs.getSelf().getName());
-
+
//set the name
this.setName(cs.getSelf().getName());
//set the docker config
- this.setDocker_config(cs.getAuxilary().getHealthcheck());
+ Auxilary aux = cs.getAuxilary();
+ if(aux.getPorts() != null) {
+ retInputs = aux.createPorts(retInputs);
+ }
+ this.setDocker_config(aux);
//set the app config
Appconfig app = new Appconfig();
- retInputs = app.createOnapAppconfig(retInputs, cs);
+ retInputs = app.createAppconfig(retInputs, cs, override);
this.setApplication_config(app);
+ //set the tls info
+ GetInput tls = new GetInput();
+ tls.setGet_input("use_tls");
+ GetInput cert = new GetInput();
+ cert.setGet_input("cert_directory");
+ TreeMap<String, Object> tlsInfo = new TreeMap();
+ tlsInfo.put("cert_directory", cert);
+ tlsInfo.put("use_tls", tls);
+ this.setTls_info(tlsInfo);
+
+ LinkedHashMap<String, Object> certMap = new LinkedHashMap();
+ certMap.put("type", "string");
+ certMap.put("default", "''");
+ retInputs.put("cert_directory", certMap);
+
+ LinkedHashMap<String, Object> useMap = new LinkedHashMap();
+ useMap.put("type", "boolean");
+ useMap.put("default", false);
+ retInputs.put("use_tls", useMap);
+
+ //set the reource config
+ ResourceConfig resource = new ResourceConfig();
+ retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ this.setResource_config(resource);
+
return retInputs;
}
-// public void createTemplateProperties(ComponentSpec cs) {
-// //create dummy inputs just for methods
-// TreeMap<String, LinkedHashMap<String, Object>> inps = new TreeMap<String, LinkedHashMap<String, Object>>();
-//
-// //set the image
-// GetInput image = new GetInput();
-// image.setGet_input("tag_version");
-// this.setImage(image);
-//
-// //set the log info
-// LogDirectory log = new LogDirectory();
-// log.setLog_directory("Log directory");
-// this.setLog_info(log);
-//
-// //set the replicas
-// GetInput replica = new GetInput();
-// replica.setGet_input("replicas");
-// this.setReplicas(replica);
-//
+ public TreeMap<String, LinkedHashMap<String, Object>> createDmaapProperties(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) {
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
+ retInputs = inps;
+
+ //set the image
+ GetInput image = new GetInput();
+ image.setGet_input("tag_version");
+ this.setImage(image);
+ LinkedHashMap<String, Object> img = new LinkedHashMap<String, Object>();
+ img.put("type", "string");
+ img.put("default", cs.getArtifacts()[0].getUri());
+ retInputs.put("tag_version", img);
+
+ //set the log info
+ GetInput logD = new GetInput();
+ logD.setGet_input("log_directory");
+ TreeMap<String, Object> l = new TreeMap();
+ l.put("log_directory", logD);
+ this.setLog_info(l);
+ LinkedHashMap<String, Object> logMap = new LinkedHashMap();
+ logMap.put("type", "string");
+ logMap.put("default", "''");
+ retInputs.put("log_directory", logMap);
+
+ //set service component type
+ String sType = cs.getSelf().getName();
+ sType = sType.replace('.', '-');
+ this.setService_component_type(sType);
+
+ //set the tls info
+ GetInput tls = new GetInput();
+ tls.setGet_input("use_tls");
+ GetInput cert = new GetInput();
+ cert.setGet_input("cert_directory");
+ TreeMap<String, Object> tlsInfo = new TreeMap();
+ tlsInfo.put("cert_directory", cert);
+ tlsInfo.put("use_tls", tls);
+ this.setTls_info(tlsInfo);
+
+ LinkedHashMap<String, Object> certMap = new LinkedHashMap();
+ certMap.put("type", "string");
+ certMap.put("default", "''");
+ retInputs.put("cert_directory", certMap);
+
+ LinkedHashMap<String, Object> useMap = new LinkedHashMap();
+ useMap.put("type", "boolean");
+ useMap.put("default", false);
+ retInputs.put("use_tls", useMap);
+
+ //set the replicas
+ GetInput replica = new GetInput();
+ replica.setGet_input("replicas");
+ this.setReplicas(replica);
+ LinkedHashMap<String, Object> rep = new LinkedHashMap<String, Object>();
+ rep.put("type", "integer");
+ rep.put("description", "number of instances");
+ rep.put("default", 1);
+ retInputs.put("replicas", rep);
+
// //set the dns name
-// this.setDns_name("blueprint_template");
-//
-// //set the docker config
-// this.setDocker_config(cs.getAuxilary().getHealthcheck());
-//
-// //set the app config
-// Appconfig app = new Appconfig();
-// app.createTemplateAppconfig();
-// this.setApplication_config(app);
-// }
+// this.setDns_name(cs.getSelf().getName());
+// //set the name
+// this.setName(cs.getSelf().getName());
+
+ //set the docker config
+ Auxilary aux = cs.getAuxilary();
+ if(aux.getPorts() != null) {
+ retInputs = aux.createPorts(retInputs);
+ }
+ this.setDocker_config(aux);
+
+ //set the appconfig
+ Appconfig app = new Appconfig();
+ retInputs = app.createAppconfig(retInputs, cs, override);
+ this.setApplication_config(app);
+
+ //set the stream publishes
+ ArrayList<DmaapStreams> pubStreams = new ArrayList();
+ int counter = 0;
+ if(cs.getStreams().getPublishes() != null) {
+ for(Publishes p: cs.getStreams().getPublishes()) {
+ if(p.getType().equals("message_router") || p.getType().equals("message router")) {
+ String topic = "topic" + counter;
+ DmaapStreams mrStreams = new DmaapStreams();
+ retInputs = mrStreams.createStreams(inps, cs, topic, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ pubStreams.add(mrStreams);
+ }
+ else if(p.getType().equals("data_router") || p.getType().equals("data router")){
+ String feed = "feed" + counter;
+ DmaapStreams drStreams = new DmaapStreams();
+ retInputs = drStreams.createStreams(inps, cs, feed, p.getType(), p.getConfig_key(), p.getRoute(), 'p');
+ pubStreams.add(drStreams);
+ }
+ counter++;
+ }
+ }
+
+ //set the stream subscribes
+ ArrayList<DmaapStreams> subStreams = new ArrayList();
+ if(cs.getStreams().getSubscribes() != null) {
+ for(Subscribes s: cs.getStreams().getSubscribes()) {
+ if(s.getType().equals("message_router") || s.getType().equals("message router")) {
+ String topic = "topic" + counter;
+ DmaapStreams mrStreams = new DmaapStreams();
+ retInputs = mrStreams.createStreams(inps, cs, topic, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ subStreams.add(mrStreams);
+ }
+ else if(s.getType().equals("data_router") || s.getType().equals("data router")){
+ String feed = "feed" + counter;
+ DmaapStreams drStreams = new DmaapStreams();
+ retInputs = drStreams.createStreams(inps, cs, feed, s.getType(), s.getConfig_key(), s.getRoute(), 's');
+ subStreams.add(drStreams);
+ }
+ counter++;
+ }
+ }
+
+ if(pubStreams.size() != 0) {
+ this.setStreams_publishes(pubStreams);
+ }
+ if(subStreams.size() != 0) {
+ this.setStreams_subscribes(subStreams);
+ }
+
+ //set the reource config
+ ResourceConfig resource = new ResourceConfig();
+ retInputs = resource.createResourceConfig(retInputs, cs.getSelf().getName());
+ this.setResource_config(resource);
+
+
+ return retInputs;
+ }
}
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
new file mode 100644
index 0000000..f1a9a17
--- /dev/null
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java
@@ -0,0 +1,125 @@
+/**============LICENSE_START=======================================================
+ org.onap.dcae
+ ================================================================================
+ Copyright (c) 2019 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.blueprintgenerator.models.blueprint;
+
+import java.util.LinkedHashMap;
+import java.util.TreeMap;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+//TODO: Auto-generated Javadoc
+/* (non-Javadoc)
+* @see java.lang.Object#toString()
+*/
+@Getter @Setter
+
+/* (non-Javadoc)
+* @see java.lang.Object#toString()
+*/
+@Builder
+
+/**
+* Instantiates a new resource config obj.
+*/
+@NoArgsConstructor
+
+/**
+* Instantiates a new resource config obj.
+*
+* @param limits the limits
+* @param requests the requests
+*/
+@AllArgsConstructor
+
+public class ResourceConfig {
+
+ /** The limits. */
+ private TreeMap<String, GetInput> limits;
+
+ /** The requests. */
+ private TreeMap<String, GetInput> requests;
+
+
+ /**
+ * Creates the resource config.
+ *
+ * @param inps the inps
+ * @param name the name
+ * @return the tree map
+ */
+ public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
+ TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
+
+ LinkedHashMap<String, Object> mi = new LinkedHashMap<String, Object>();
+ mi.put("type", "string");
+ mi.put("default", "128Mi");
+
+ LinkedHashMap<String, Object> m = new LinkedHashMap<String, Object>();
+ m.put("type", "string");
+ m.put("default", "250m");
+
+
+ if(!name.equals("")) {
+ name = name + "_";
+ }
+
+ //set the limits
+ TreeMap<String, GetInput> lim = new TreeMap<String, GetInput>();
+
+ GetInput cpu = new GetInput();
+ cpu.setGet_input(name + "cpu_limit");
+ lim.put("cpu", cpu);
+
+ GetInput memL = new GetInput();
+ memL.setGet_input(name + "memory_limit");
+ lim.put("memory", memL);
+
+ retInputs.put(name + "cpu_limit", m);
+ retInputs.put(name + "memory_limit", mi);
+
+ this.setLimits(lim);
+
+ //set the requests
+ TreeMap<String, GetInput> req = new TreeMap<String, GetInput>();
+
+ GetInput cpuR = new GetInput();
+ cpuR.setGet_input(name + "cpu_request");
+ req.put("cpu", cpuR);
+
+ GetInput memR = new GetInput();
+ memR.setGet_input(name + "memory_request");
+ req.put("memory", memR);
+
+ retInputs.put(name + "cpu_request", m);
+ retInputs.put(name + "memory_request", mi);
+
+ this.setRequests(req);
+
+ return retInputs;
+ }
+}
+
diff --git a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
index c831617..1c1cf6c 100644
--- a/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
+++ b/blueprint-generator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java
@@ -26,42 +26,59 @@ import java.util.TreeMap;
import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
import lombok.Getter; import lombok.Setter;
@Getter @Setter
+@JsonInclude(value=Include.NON_NULL)
public class StartInputs {
- private ArrayList<String> ports;
+ //private ArrayList<String> ports;
+ private GetInput envs;
public TreeMap<String, LinkedHashMap<String, Object>> createOnapStartInputs(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
retInputs = inps;
LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>();
-
- ArrayList<String> port = new ArrayList<String>();
- if(cs.getAuxilary().getPorts() != null) {
- for(String s: cs.getAuxilary().getPorts()) {
- //create the ports
- String portNumber = "";
- StringBuffer buf = new StringBuffer();
- for(int i = 0; i < s.length(); i++) {
- if(!(s.charAt(i) == ':')) {
- buf.append(s.charAt(i));
- }
- else {
- break;
- }
- }
- portNumber = buf.toString();
- String p = "concat: [" + '"' + portNumber + ":" + '"' +", {get_input: external_port }]";
- port.add(p);
- }
- }
- this.setPorts(port);
- //add the external port input
- stringType.put("type", "string");
- stringType.put("description", "Kubernetes node port on which collector is exposed");
- stringType.put("default", "'30235'");
- retInputs.put("external_port", stringType);
+
+// ArrayList<String> port = new ArrayList<String>();
+// String external = "";
+// if(cs.getAuxilary().getPorts() != null) {
+// for(String s: cs.getAuxilary().getPorts()) {
+// //create the ports
+// String portNumber = "";
+// StringBuffer buf = new StringBuffer();
+// for(int i = 0; i < s.length(); i++) {
+// if(!(s.charAt(i) == ':')) {
+// buf.append(s.charAt(i));
+// }
+// else {
+// external = s.replace(buf.toString() + ":", "");
+// break;
+// }
+// }
+// portNumber = buf.toString();
+// String p = "concat: [" + '"' + portNumber + ":" + '"' +", {get_input: external_port }]";
+// port.add(p);
+// }
+// }
+// this.setPorts(port);
+// //add the external port input
+// if(cs.getAuxilary().getPorts() != null) {
+// stringType.put("type", "string");
+// stringType.put("description", "Kubernetes node port on which collector is exposed");
+// stringType.put("default", "'" + external + "'") ;
+// retInputs.put("external_port", stringType);
+// }
+
+ //set the envs
+ GetInput env = new GetInput();
+ env.setGet_input("envs");
+ this.setEnvs(env);
+ LinkedHashMap<String, Object> eMap = new LinkedHashMap();
+ eMap.put("default", "{}");
+ retInputs.put("envs", eMap);
return retInputs;
}