Add factories for Ext tls parameters
[dcaegen2/platform.git] / mod / bpgenerator / src / main / java / org / onap / blueprintgenerator / models / blueprint / ResourceConfig.java
1 /*============LICENSE_START=======================================================
2  org.onap.dcae
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
10
11       http://www.apache.org/licenses/LICENSE-2.0
12
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=========================================================
19
20  */
21
22 package org.onap.blueprintgenerator.models.blueprint;
23
24 import java.util.LinkedHashMap;
25 import java.util.TreeMap;
26
27 import lombok.AllArgsConstructor;
28 import lombok.Builder;
29 import lombok.Getter;
30 import lombok.NoArgsConstructor;
31 import lombok.Setter;
32
33 //TODO: Auto-generated Javadoc
34 /* (non-Javadoc)
35 * @see java.lang.Object#toString()
36 */
37 @Getter @Setter
38
39 /* (non-Javadoc)
40 * @see java.lang.Object#toString()
41 */
42 @Builder
43
44 /**
45 * Instantiates a new resource config obj.
46 */
47 @NoArgsConstructor
48
49 /**
50 * Instantiates a new resource config obj.
51 *
52 * @param limits the limits
53 * @param requests the requests
54 */
55 @AllArgsConstructor
56
57 public class ResourceConfig {
58
59         /** The limits. */
60         private TreeMap<String, GetInput> limits;
61
62         /** The requests. */
63         private TreeMap<String, GetInput> requests;
64
65
66         /**
67          * Creates the resource config.
68          *
69          * @param inps the inps
70          * @param name the name
71          * @return the tree map
72          */
73         public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
74                 TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
75
76                 LinkedHashMap<String, Object> mi = new LinkedHashMap<String, Object>();
77                 mi.put("type", "string");
78                 mi.put("default", "128Mi");
79
80                 LinkedHashMap<String, Object> m = new LinkedHashMap<String, Object>();
81                 m.put("type", "string");
82                 m.put("default", "250m");
83
84
85                 if(!name.equals("")) {
86                         name = name + "_";
87                 }
88
89                 //set the limits
90                 TreeMap<String, GetInput> lim = new TreeMap<String, GetInput>();
91
92                 GetInput cpu = new GetInput();
93                 cpu.setBpInputName(name + "cpu_limit");
94                 lim.put("cpu", cpu);
95
96                 GetInput memL = new GetInput();
97                 memL.setBpInputName(name + "memory_limit");
98                 lim.put("memory", memL);
99
100                 retInputs.put(name + "cpu_limit", m);
101                 retInputs.put(name + "memory_limit", mi);
102
103                 this.setLimits(lim);
104
105                 //set the requests
106                 TreeMap<String, GetInput> req = new TreeMap<String, GetInput>();
107
108                 GetInput cpuR = new GetInput();
109                 cpuR.setBpInputName(name + "cpu_request");
110                 req.put("cpu", cpuR);
111
112                 GetInput memR = new GetInput();
113                 memR.setBpInputName(name + "memory_request");
114                 req.put("memory", memR);
115
116                 retInputs.put(name + "cpu_request", m);
117                 retInputs.put(name + "memory_request", mi);
118
119                 this.setRequests(req);
120
121                 return retInputs;
122         }
123 }
124