bp-gen code clone from cli repo
[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  ================================================================================
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.LinkedHashMap;
24 import java.util.TreeMap;
25
26 import com.fasterxml.jackson.annotation.JsonInclude;
27
28 import lombok.AllArgsConstructor;
29 import lombok.Builder;
30 import lombok.Getter;
31 import lombok.NoArgsConstructor;
32 import lombok.Setter;
33
34 //TODO: Auto-generated Javadoc
35 /* (non-Javadoc)
36 * @see java.lang.Object#toString()
37 */
38 @Getter @Setter
39
40 /* (non-Javadoc)
41 * @see java.lang.Object#toString()
42 */
43 @Builder
44
45 /**
46 * Instantiates a new resource config obj.
47 */
48 @NoArgsConstructor
49
50 /**
51 * Instantiates a new resource config obj.
52 *
53 * @param limits the limits
54 * @param requests the requests
55 */
56 @AllArgsConstructor
57
58 public class ResourceConfig {
59
60         /** The limits. */
61         private TreeMap<String, GetInput> limits;
62
63         /** The requests. */
64         private TreeMap<String, GetInput> requests;
65
66
67         /**
68          * Creates the resource config.
69          *
70          * @param inps the inps
71          * @param name the name
72          * @return the tree map
73          */
74         public TreeMap<String, LinkedHashMap<String, Object>> createResourceConfig(TreeMap<String, LinkedHashMap<String, Object>> inps, String name){
75                 TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps;
76
77                 LinkedHashMap<String, Object> mi = new LinkedHashMap<String, Object>();
78                 mi.put("type", "string");
79                 mi.put("default", "128Mi");
80
81                 LinkedHashMap<String, Object> m = new LinkedHashMap<String, Object>();
82                 m.put("type", "string");
83                 m.put("default", "250m");
84
85
86                 if(!name.equals("")) {
87                         name = name + "_";
88                 }
89
90                 //set the limits
91                 TreeMap<String, GetInput> lim = new TreeMap<String, GetInput>();
92
93                 GetInput cpu = new GetInput();
94                 cpu.setGet_input(name + "cpu_limit");
95                 lim.put("cpu", cpu);
96
97                 GetInput memL = new GetInput();
98                 memL.setGet_input(name + "memory_limit");
99                 lim.put("memory", memL);
100
101                 retInputs.put(name + "cpu_limit", m);
102                 retInputs.put(name + "memory_limit", mi);
103
104                 this.setLimits(lim);
105
106                 //set the requests
107                 TreeMap<String, GetInput> req = new TreeMap<String, GetInput>();
108
109                 GetInput cpuR = new GetInput();
110                 cpuR.setGet_input(name + "cpu_request");
111                 req.put("cpu", cpuR);
112
113                 GetInput memR = new GetInput();
114                 memR.setGet_input(name + "memory_request");
115                 req.put("memory", memR);
116
117                 retInputs.put(name + "cpu_request", m);
118                 retInputs.put(name + "memory_request", mi);
119
120                 this.setRequests(req);
121
122                 return retInputs;
123         }
124 }
125