From 9b30373a6f1b1bc123250a9a598bc7a164b7e9b7 Mon Sep 17 00:00:00 2001 From: Vijay Venkatesh Kumar Date: Wed, 8 Jan 2020 17:13:22 +0000 Subject: bp-gen code clone from cli repo dcaegen2/platform/mod will host all design component code cli/component-json-schemas and cli/dcae-cli already moved original cli repo will be marked as RO after this is merged Change-Id: Ie88dbd273d218c89a95afe0e58742a948c04eae5 Signed-off-by: Vijay Venkatesh Kumar Issue-ID: DCAEGEN2-1852 Issue-ID: DCAEGEN2-1860 Signed-off-by: Vijay Venkatesh Kumar --- .../models/blueprint/Appconfig.java | 156 ++++++++++++ .../models/blueprint/Blueprint.java | 211 +++++++++++++++ .../models/blueprint/ConcatObj.java | 57 +++++ .../models/blueprint/DmaapInfo.java | 99 ++++++++ .../models/blueprint/DmaapObj.java | 75 ++++++ .../models/blueprint/GetInput.java | 29 +++ .../models/blueprint/GetProperty.java | 55 ++++ .../models/blueprint/Imports.java | 77 ++++++ .../models/blueprint/Interfaces.java | 42 +++ .../blueprintgenerator/models/blueprint/Node.java | 28 ++ .../models/blueprint/Properties.java | 282 +++++++++++++++++++++ .../models/blueprint/ResourceConfig.java | 125 +++++++++ .../blueprintgenerator/models/blueprint/Start.java | 49 ++++ .../models/blueprint/StartInputs.java | 85 +++++++ .../models/blueprint/TemplateNode.java | 69 +++++ 15 files changed, 1439 insertions(+) create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java create mode 100644 mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java (limited to 'mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint') diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java new file mode 100644 index 0000000..6d5b7d7 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java @@ -0,0 +1,156 @@ +/**============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 org.onap.blueprintgenerator.models.componentspec.CallsObj; +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 com.fasterxml.jackson.annotation.JsonAnyGetter; + + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class Appconfig { + private CallsObj[] service_calls; + private TreeMap streams_publishes; + private TreeMap streams_subscribes; + private TreeMap params; + + @JsonAnyGetter + public TreeMap getParams(){ + return params; + } + + public TreeMap> createAppconfig(TreeMap> inps, ComponentSpec cs, String override) { + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + + //set service calls + CallsObj[] call = new CallsObj[0]; + this.setService_calls(call); + + //set the stream publishes + TreeMap streamPublishes = new TreeMap(); + 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(); + 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(); + String name = "topic" + counter; + retInputs = pub.createOnapDmaapMRObj(retInputs, config, 'p', "topic" + counter, name); + pub.setType(p.getType()); + streamPublishes.put(config, pub); + } + counter++; + } + } + + //set the stream publishes + TreeMap streamSubscribes = new TreeMap(); + + if(cs.getStreams().getSubscribes().length != 0) { + for(Subscribes s: cs.getStreams().getSubscribes()) { + if(s.getType().equals("data_router") || s.getType().equals("data router")) { + //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(); + 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(); + String name = "topic" + counter; + retInputs = sub.createOnapDmaapMRObj(retInputs, config, 's', "topic" + counter, name); + sub.setType(s.getType()); + streamSubscribes.put(config, sub); + } + counter++; + } + } + + this.setStreams_publishes(streamPublishes); + this.setStreams_subscribes(streamSubscribes); + + //set the parameters into the appconfig + TreeMap parameters = new TreeMap(); + for(Parameters p: cs.getParameters()) { + String pName = p.getName(); + if(p.isSourced_at_deployment()) { + GetInput paramInput = new GetInput(); + paramInput.setGet_input(pName); + parameters.put(pName, paramInput); + + if(!p.getValue().equals("")) { + LinkedHashMap inputs = new LinkedHashMap(); + inputs.put("type", "string"); + inputs.put("default", p.getValue()); + retInputs.put(pName, inputs); + } else { + LinkedHashMap inputs = new LinkedHashMap(); + inputs.put("type", "string"); + retInputs.put(pName, inputs); + } + } else { + if(p.getType() == "string") { + String val =(String) p.getValue(); + val = '"' + val + '"'; + parameters.put(pName, val); + } + 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 over = new LinkedHashMap(); + over.put("type", "string"); + over.put("default", override); + retInputs.put("service_component_name_override", over); + } + this.setParams(parameters); + return retInputs; + } + + +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java new file mode 100644 index 0000000..06c42c5 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java @@ -0,0 +1,211 @@ +/**============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.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.TreeMap; +import java.util.regex.Pattern; + +import org.onap.blueprintgenerator.core.Fixes; +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; +import com.fasterxml.jackson.core.JsonProcessingException; +//import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + + + +@Getter @Setter +@JsonInclude(JsonInclude.Include.NON_NULL) + +public class Blueprint { + + + private String tosca_definitions_version; + + private String description; + + private ArrayList imports; + + private TreeMap> inputs; + + private TreeMap node_templates; + + 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, override); + bp = bp.setQuotations(bp); + } + + if(bpType == 'd') { + DmaapBlueprint dmaap = new DmaapBlueprint(); + bp = dmaap.createDmaapBlueprint(cs, importPath, override); + bp = bp.setQuotations(bp); + } + return bp; + } + public Blueprint setQuotations(Blueprint bp) { + for(String s: bp.getInputs().keySet()) { + LinkedHashMap temp = bp.getInputs().get(s); + if(temp.get("type") == "string") { + String def = (String) temp.get("default"); + def = '"' + def + '"'; + temp.replace("default", def); + bp.getInputs().replace(s, temp); + } + } + + return bp; + } + + public void blueprintToYaml(String outputPath, String bluePrintName, ComponentSpec cs) { + File outputFile; + + if(bluePrintName.equals("")) { + String name = cs.getSelf().getName(); + if(name.contains(".")) { + name = name.replaceAll(Pattern.quote("."), "_"); + } + if(name.contains(" ")) { + name = name.replaceAll(" ", ""); + } + String file = name + ".yaml"; + + + outputFile = new File(outputPath, file); + outputFile.getParentFile().mkdirs(); + try { + outputFile.createNewFile(); + } catch (IOException e) { + + throw new RuntimeException(e); + } + } else { + if(bluePrintName.contains(" ") || bluePrintName.contains(".")) { + bluePrintName = bluePrintName.replaceAll(Pattern.quote("."), "_"); + bluePrintName = bluePrintName.replaceAll(" ", ""); + } + String file = bluePrintName + ".yaml"; + outputFile = new File(outputPath, file); + outputFile.getParentFile().mkdirs(); + try { + outputFile.createNewFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + String version = "#blueprint_version: " + cs.getSelf().getVersion() + '\n'; + String description = "#description: " + cs.getSelf().getDescription() + '\n'; + + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new FileWriter(outputFile, false)); + } catch (IOException e1) { + throw new RuntimeException(e1); + } + if(writer != null) { + try { + writer.write(description); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + writer.write(version); + } catch (IOException e) { + throw new RuntimeException(e); + } + try { + writer.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + + //read the translated blueprint into the file + ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); + + PrintWriter out = null; + try { + out = new PrintWriter(new BufferedWriter(new FileWriter(outputFile, true))); + } catch (IOException e) { + throw new RuntimeException(e); + } + + try { + if(out != null) { + blueprintMapper.writeValue(out, this); + out.close(); + } + } catch (IOException e) { + + throw new RuntimeException(e); + } + + + Fixes fix = new Fixes(); + try { + fix.fixSingleQuotes(outputFile); + } catch (IOException e) { + throw new RuntimeException(e); + } + + System.out.println("Blueprint created"); + } + + + public String blueprintToString() { + String ret = ""; + + ObjectMapper blueprintMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); + try { + ret = blueprintMapper.writerWithDefaultPrettyPrinter().writeValueAsString(this); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + + + return ret; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java new file mode 100644 index 0000000..edc257c --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ConcatObj.java @@ -0,0 +1,57 @@ +/**============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.ArrayList; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonRawValue; + +import lombok.Getter; import lombok.Setter; +import lombok.NoArgsConstructor; + +// TODO: Auto-generated Javadoc +/** + * The Class ConcatObj. + */ +@JsonIgnoreProperties(ignoreUnknown = true) + +/* (non-Javadoc) + * @see java.lang.Object#toString() + */ +@Getter @Setter +//@Builder + +/** + * Instantiates a new concat obj. + */ +@NoArgsConstructor +@JsonInclude(value=Include.NON_NULL) + +public class ConcatObj { + + /** The concat. */ + private ArrayList concat; +} + diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java new file mode 100644 index 0000000..97dafc7 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapInfo.java @@ -0,0 +1,99 @@ +/**============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.ArrayList; +import java.util.LinkedHashMap; +import java.util.TreeMap; + +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 DmaapInfo { + private GetInput topic_url; + private GetInput username; + private GetInput password; + private GetInput location; + private GetInput delivery_url; + private GetInput subscriber_id; + + public TreeMap> createOnapDmaapMRInfo(TreeMap> inps, String config, char type) { + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + LinkedHashMap stringType = new LinkedHashMap(); + stringType.put("type", "string"); + + config = config.replaceAll("-", "_"); + if(type == 'p') { + config = config + "_publish_url"; + } + else if(type == 's') { + config = config+ "_subscribe_url"; + } + + GetInput topic = new GetInput(); + topic.setGet_input(config); + this.setTopic_url(topic); + + retInputs.put(config, stringType); + + return retInputs; + } + + public TreeMap> createOnapDmaapDRInfo(TreeMap> inps, String config, char type) { + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + LinkedHashMap stringType = new LinkedHashMap(); + stringType.put("type", "string"); + + GetInput username = new GetInput(); + username.setGet_input(config + "_" + "username"); + this.setUsername(username); + retInputs.put(config + "_" + "username", stringType); + + GetInput password = new GetInput(); + password.setGet_input(config + "_" + "password"); + this.setPassword(password); + retInputs.put(config + "_" + "password", stringType); + + GetInput location = new GetInput(); + location.setGet_input(config + "_" + "location"); + this.setLocation(location); + retInputs.put(config + "_" + "location", stringType); + + GetInput deliveryUrl = new GetInput(); + deliveryUrl.setGet_input(config + "_" + "delivery_url"); + this.setDelivery_url(deliveryUrl); + retInputs.put(config + "_" + "delivery_url", stringType); + + GetInput subscriberID = new GetInput(); + subscriberID.setGet_input(config + "_" + "subscriber_id"); + this.setSubscriber_id(subscriberID); + retInputs.put(config + "_" + "subscriber_id", stringType); + + + return retInputs; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java new file mode 100644 index 0000000..10092c8 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java @@ -0,0 +1,75 @@ +/**============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 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; +@JsonInclude(value=Include.NON_NULL) +@Getter @Setter +public class DmaapObj { + private String dmaap_info; + private String type; + private GetInput pass; + private GetInput user; + + public TreeMap> createOnapDmaapMRObj(TreeMap> inps, String config, char type, String n, String num) { + TreeMap> retInputs = new TreeMap>(); + LinkedHashMap stringType = new LinkedHashMap(); + stringType.put("type", "string"); + retInputs = inps; + + //set the dmaapinfo + DmaapInfo info = new DmaapInfo(); + 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> createOnapDmaapDRObj(TreeMap> inps, String config, char type, String n, String num) { + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + + //set the dmaapinfo + DmaapInfo info = new DmaapInfo(); + String infoType = "<<" + n + ">>"; + this.setDmaap_info(infoType); + return retInputs; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java new file mode 100644 index 0000000..e7980c8 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetInput.java @@ -0,0 +1,29 @@ +/**============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 lombok.Getter; import lombok.Setter; + +@Getter @Setter +public class GetInput { + + private Object get_input; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java new file mode 100644 index 0000000..1f9bf1c --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/GetProperty.java @@ -0,0 +1,55 @@ +/**============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.ArrayList; + + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.Getter; import lombok.Setter; +import lombok.NoArgsConstructor; + +// TODO: Auto-generated Javadoc +/** + * The Class GetProperty. + */ +@JsonIgnoreProperties(ignoreUnknown = true) + +/* (non-Javadoc) + * @see java.lang.Object#toString() + */ +@Getter @Setter +//@Builder + +/** + * Instantiates a new gets the property. + */ +@NoArgsConstructor +@JsonInclude(value=Include.NON_NULL) + +public class GetProperty { + + /** The get property. */ + private ArrayList get_property; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java new file mode 100644 index 0000000..8bcdbbc --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Imports.java @@ -0,0 +1,77 @@ +/**============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.io.File; +import java.io.IOException; +import java.util.ArrayList; + + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; +import lombok.AllArgsConstructor; +import lombok.Getter; import lombok.Setter; +import lombok.NoArgsConstructor; + + + +@Getter @Setter +@JsonInclude(value=Include.NON_NULL) +public class Imports { + /** The imports. */ + private ArrayList imports; + + public static ArrayList createOnapImports() { + ArrayList imps = new ArrayList(); + 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 createDmaapImports(){ + ArrayList imps = new ArrayList(); + 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 createImportsFromFile(String path) { + Imports imports = new Imports(); + ObjectMapper importMapper = new ObjectMapper(new YAMLFactory().configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true)); + File importPath = new File(path); + try { + imports = importMapper.readValue(importPath, Imports.class); + } catch (IOException e) { + throw new RuntimeException(e); + } + ArrayList imps = new ArrayList(); + for(String s: imports.getImports()) { + imps.add(s); + } + return imps; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java new file mode 100644 index 0000000..a3404f6 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Interfaces.java @@ -0,0 +1,42 @@ +/**============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 org.onap.blueprintgenerator.models.componentspec.ComponentSpec; + +import lombok.Getter; import lombok.Setter; + +@Getter @Setter +public class Interfaces { + private Start start; + public TreeMap> createInterface(TreeMap> inps, ComponentSpec cs){ + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + //create the start object + Start start = new Start(); + retInputs = start.createOnapStart(retInputs, cs); + this.setStart(start); + return retInputs; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java new file mode 100644 index 0000000..bac795f --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Node.java @@ -0,0 +1,28 @@ +/**============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 lombok.Getter; import lombok.Setter; + +@Getter @Setter +public class Node { + private String type; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java new file mode 100644 index 0000000..25c4c53 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java @@ -0,0 +1,282 @@ +/**============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.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; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +import lombok.Getter; import lombok.Setter; + +@Getter @Setter +@JsonInclude(value=Include.NON_NULL) +public class Properties { + private Appconfig application_config; + private Auxilary docker_config; + private Object image; + private GetInput location_id; + private String service_component_type; + private TreeMap log_info; + private String dns_name; + private Object replicas; + private String name; + private GetInput topic_name; + private GetInput feed_name; + ArrayList streams_publishes; + ArrayList streams_subscribes; + private TreeMap tls_info; + private ResourceConfig resource_config; + //private boolean useExisting; + + public TreeMap> createOnapProperties(TreeMap> inps, ComponentSpec cs, String override) { + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + + //set the image + GetInput image = new GetInput(); + image.setGet_input("image"); + this.setImage(image); + LinkedHashMap img = new LinkedHashMap(); + img.put("type", "string"); + img.put("default", cs.getArtifacts()[0].getUri()); + retInputs.put("image", img); + + //set the location id + GetInput location = new GetInput(); + location.setGet_input("location_id"); + this.setLocation_id(location); + LinkedHashMap locMap = new LinkedHashMap(); + locMap.put("type", "string"); + locMap.put("default", "central"); + + //set the log info + GetInput logD = new GetInput(); + logD.setGet_input("log_directory"); + TreeMap l = new TreeMap(); + l.put("log_directory", logD); + this.setLog_info(l); + LinkedHashMap logMap = new LinkedHashMap(); + logMap.put("type", "string"); + logMap.put("default", "''"); + retInputs.put("log_directory", logMap); + + //set the replicas + GetInput replica = new GetInput(); + replica.setGet_input("replicas"); + this.setReplicas(replica); + LinkedHashMap rep = new LinkedHashMap(); + 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(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 app config + Appconfig app = new Appconfig(); + 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 tlsInfo = new TreeMap(); + tlsInfo.put("cert_directory", cert); + tlsInfo.put("use_tls", tls); + this.setTls_info(tlsInfo); + + LinkedHashMap certMap = new LinkedHashMap(); + certMap.put("type", "string"); + certMap.put("default", "''"); + retInputs.put("cert_directory", certMap); + + LinkedHashMap 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 TreeMap> createDmaapProperties(TreeMap> inps, ComponentSpec cs, String override) { + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + + //set the image + GetInput image = new GetInput(); + image.setGet_input("tag_version"); + this.setImage(image); + LinkedHashMap img = new LinkedHashMap(); + 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 l = new TreeMap(); + l.put("log_directory", logD); + this.setLog_info(l); + LinkedHashMap 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 tlsInfo = new TreeMap(); + tlsInfo.put("cert_directory", cert); + tlsInfo.put("use_tls", tls); + this.setTls_info(tlsInfo); + + LinkedHashMap certMap = new LinkedHashMap(); + certMap.put("type", "string"); + certMap.put("default", "''"); + retInputs.put("cert_directory", certMap); + + LinkedHashMap 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 rep = new LinkedHashMap(); + 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(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 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 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/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/ResourceConfig.java new file mode 100644 index 0000000..f1a9a17 --- /dev/null +++ b/mod/bpgenerator/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 limits; + + /** The requests. */ + private TreeMap requests; + + + /** + * Creates the resource config. + * + * @param inps the inps + * @param name the name + * @return the tree map + */ + public TreeMap> createResourceConfig(TreeMap> inps, String name){ + TreeMap> retInputs = inps; + + LinkedHashMap mi = new LinkedHashMap(); + mi.put("type", "string"); + mi.put("default", "128Mi"); + + LinkedHashMap m = new LinkedHashMap(); + m.put("type", "string"); + m.put("default", "250m"); + + + if(!name.equals("")) { + name = name + "_"; + } + + //set the limits + TreeMap lim = new TreeMap(); + + 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 req = new TreeMap(); + + 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/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java new file mode 100644 index 0000000..d9c885d --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Start.java @@ -0,0 +1,49 @@ +/**============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 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 Start { + private StartInputs inputs; + private LinkedHashMap envs; + + public TreeMap> createOnapStart(TreeMap> inps, ComponentSpec cs) { + TreeMap> retInputs = inps; + retInputs = inps; + + //create the start inputs + StartInputs inputs = new StartInputs(); + inputs.createOnapStartInputs(retInputs, cs); + this.setInputs(inputs); + + return retInputs; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java new file mode 100644 index 0000000..1c1cf6c --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java @@ -0,0 +1,85 @@ +/**============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.ArrayList; +import java.util.LinkedHashMap; +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 ports; + private GetInput envs; + + public TreeMap> createOnapStartInputs(TreeMap> inps, ComponentSpec cs){ + TreeMap> retInputs = new TreeMap>(); + retInputs = inps; + LinkedHashMap stringType = new LinkedHashMap(); + +// ArrayList port = new ArrayList(); +// 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 eMap = new LinkedHashMap(); + eMap.put("default", "{}"); + retInputs.put("envs", eMap); + + return retInputs; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java new file mode 100644 index 0000000..7137cdb --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TemplateNode.java @@ -0,0 +1,69 @@ +/**============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 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.onapbp.OnapNode; + +import lombok.Getter; import lombok.Setter; + + +public class TemplateNode extends OnapNode{ + +// public void createTemplateNode() { +// //dummy inputs just used for the inputs so i can reuse code +// TreeMap> inps = new TreeMap>(); +// +// //create a dummy componentspec to set the values later on +// ComponentSpec cs = new ComponentSpec(); +// Auxilary aux = new Auxilary(); +// HealthCheck health = new HealthCheck(); +// health.setEndpoint("/healthcheck"); +// health.setInterval("15s"); +// health.setTimeout("1s"); +// health.setType("https"); +// aux.setHealthcheck(health); +// String[] ports = new String[1]; +// ports[0] = "9999:9999"; +// aux.setPorts(ports); +// cs.setAuxilary(aux); +// +// //set the type +// this.setType("dcae.nodes.ContainerizedPlatformComponent"); +// +// //set the interface +// Interfaces inter = new Interfaces(); +// inter.createOnapInterface(inps, cs); +// TreeMap interfaces = new TreeMap(); +// interfaces.put("cloudify.interfaces.lifecycle", inter); +// this.setInterfaces(interfaces); +// +// +// //create the properties +// Properties props = new Properties(); +// props.createTemplateProperties(cs); +// this.setProperties(props); +// } +} -- cgit 1.2.3-korg