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