Commit for the blueprint generator java tool
[dcaegen2/platform/cli.git] / blueprint-generator / src / main / java / org / onap / blueprintgenerator / models / blueprint / StartInputs.java
1 /**============LICENSE_START======================================================= 
2  org.onap.dcae 
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 
9
10       http://www.apache.org/licenses/LICENSE-2.0 
11
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========================================================= 
18
19 */
20
21 package org.onap.blueprintgenerator.models.blueprint;
22
23 import java.util.ArrayList;
24 import java.util.LinkedHashMap;
25 import java.util.TreeMap;
26
27 import org.onap.blueprintgenerator.models.componentspec.ComponentSpec;
28
29 import lombok.Getter; import lombok.Setter;
30
31 @Getter @Setter
32 public class StartInputs {
33         private ArrayList<String> ports;
34
35         public TreeMap<String, LinkedHashMap<String, Object>> createOnapStartInputs(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){
36                 TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>();
37                 retInputs = inps;
38                 LinkedHashMap<String, Object> stringType  = new LinkedHashMap<String, Object>();
39                 
40                 ArrayList<String> port = new ArrayList<String>();
41                 if(cs.getAuxilary().getPorts() != null) {
42                         for(String s: cs.getAuxilary().getPorts()) {
43                                 //create the ports
44                                 String portNumber = "";
45                                 StringBuffer buf = new StringBuffer();
46                                 for(int i = 0; i < s.length(); i++) {
47                                         if(!(s.charAt(i) == ':')) {
48                                                 buf.append(s.charAt(i));
49                                         }
50                                         else {
51                                                 break;
52                                         }
53                                 }
54                                 portNumber = buf.toString();
55                                 String p = "concat: [" + '"' + portNumber + ":" + '"' +", {get_input: external_port }]";
56                                 port.add(p);
57                         }
58                 }
59                 this.setPorts(port);
60                 //add the external port input
61                 stringType.put("type", "string");
62                 stringType.put("description", "Kubernetes node port on which collector is exposed");
63                 stringType.put("default", "'30235'");
64                 retInputs.put("external_port", stringType);
65
66                 return retInputs;
67         }
68 }