Sonar fixes in bpgenerator models/blueprints package
[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
75                 LinkedHashMap<String, Object> mi = new LinkedHashMap<>();
76                 mi.put("type", "string");
77                 mi.put("default", "128Mi");
78
79                 LinkedHashMap<String, Object> m = new LinkedHashMap<>();
80                 m.put("type", "string");
81                 m.put("default", "250m");
82
83
84                 if(!name.equals("")) {
85                         name = name + "_";
86                 }
87
88                 //set the limits
89                 TreeMap<String, GetInput> lim = new TreeMap<>();
90
91                 GetInput cpu = new GetInput();
92                 cpu.setBpInputName(name + "cpu_limit");
93                 lim.put("cpu", cpu);
94
95                 GetInput memL = new GetInput();
96                 memL.setBpInputName(name + "memory_limit");
97                 lim.put("memory", memL);
98
99                 inps.put(name + "cpu_limit", m);
100                 inps.put(name + "memory_limit", mi);
101
102                 this.setLimits(lim);
103
104                 //set the requests
105                 TreeMap<String, GetInput> req = new TreeMap<>();
106
107                 GetInput cpuR = new GetInput();
108                 cpuR.setBpInputName(name + "cpu_request");
109                 req.put("cpu", cpuR);
110
111                 GetInput memR = new GetInput();
112                 memR.setBpInputName(name + "memory_request");
113                 req.put("memory", memR);
114
115                 inps.put(name + "cpu_request", m);
116                 inps.put(name + "memory_request", mi);
117
118                 this.setRequests(req);
119
120                 return inps;
121         }
122 }
123