1 /*============LICENSE_START=======================================================
3 ================================================================================
4 Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
5 Copyright (c) 2020 Nokia. All rights reserved.
6 ================================================================================
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
11 http://www.apache.org/licenses/LICENSE-2.0
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 ============LICENSE_END=========================================================
22 package org.onap.blueprintgenerator.models.blueprint;
24 import java.util.ArrayList;
25 import java.util.LinkedHashMap;
26 import java.util.TreeMap;
28 import org.onap.blueprintgenerator.core.PgaasNodeBuilder;
29 import org.onap.blueprintgenerator.models.componentspec.Auxilary;
30 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
32 import com.fasterxml.jackson.annotation.JsonInclude;
33 import com.fasterxml.jackson.annotation.JsonInclude.Include;
35 import lombok.Getter; import lombok.Setter;
38 @JsonInclude(value=Include.NON_NULL)
39 public class StartInputs {
40 private ArrayList<String> ports;
43 public TreeMap<String, LinkedHashMap<String, Object>> createOnapStartInputs(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
44 TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
47 ArrayList<String> portList = new ArrayList();
48 Auxilary aux = cs.getAuxilary();
50 if (aux.getPorts() != null) {
52 for(Object p : aux.getPorts()) {
53 String[] ports = p.toString().split(":");
55 = String.format("concat: [\"%s:\", {get_input: external_port_%d}]"
57 portList.add(internal);
59 LinkedHashMap<String, Object> portType = new LinkedHashMap();
60 portType.put("type", "string");
61 portType.put("default", ports[1]);
62 retInputs.put("external_port_" + count, portType);
69 this.setPorts(portList);
70 // ArrayList<String> port = new ArrayList<String>();
71 // String external = "";
72 // if(cs.getAuxilary().getPorts() != null) {
73 // for(String s: cs.getAuxilary().getPorts()) {
75 // String portNumber = "";
76 // StringBuffer buf = new StringBuffer();
77 // for(int i = 0; i < s.length(); i++) {
78 // if(!(s.charAt(i) == ':')) {
79 // buf.append(s.charAt(i));
82 // external = s.replace(buf.toString() + ":", "");
86 // portNumber = buf.toString();
87 // String p = "concat: [" + '"' + portNumber + ":" + '"' +", {get_input: external_port }]";
91 // this.setPorts(port);
92 // //add the external port input
93 // if(cs.getAuxilary().getPorts() != null) {
94 // stringType.put("type", "string");
95 // stringType.put("description", "Kubernetes node port on which collector is exposed");
96 // stringType.put("default", "'" + external + "'") ;
97 // retInputs.put("external_port", stringType);
101 LinkedHashMap<String, Object> eMap = new LinkedHashMap();
102 if(cs.getAuxilary().getDatabases() != null){
103 //set db env variables
104 LinkedHashMap<String, Object> envVars = PgaasNodeBuilder.getEnvVariables(cs.getAuxilary().getDatabases());
105 this.setEnvs(envVars);
106 eMap.put("default", "&envs {}");
109 GetInput env = new GetInput();
110 env.setBpInputName("envs");
112 eMap.put("default", "{}");
114 retInputs.put("envs", eMap);