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