3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * ================================================================================
8 * * Licensed under the Apache License, Version 2.0 (the "License");
9 * * you may not use this file except in compliance with the License.
10 * * You may obtain a copy of the License at
12 * * http://www.apache.org/licenses/LICENSE-2.0
14 * * Unless required by applicable law or agreed to in writing, software
15 * * distributed under the License is distributed on an "AS IS" BASIS,
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * * See the License for the specific language governing permissions and
18 * * limitations under the License.
19 * * ============LICENSE_END=========================================================
24 package org.onap.blueprintgenerator.service.common;
26 import org.onap.blueprintgenerator.constants.Constants;
27 import org.onap.blueprintgenerator.model.common.GetInput;
28 import org.onap.blueprintgenerator.model.common.ResourceConfig;
29 import org.onap.blueprintgenerator.service.base.BlueprintHelperService;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Service;
33 import java.util.HashMap;
34 import java.util.LinkedHashMap;
36 import java.util.TreeMap;
39 * @author : Ravi Mantena
40 * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add
43 @Service("onapResourceConfigService")
44 public class ResourceConfigService {
47 private BlueprintHelperService blueprintHelperService;
50 * Creates Resouce Config for properties
52 * @param inputs Inputs
56 public Map<String, Object> createResourceConfig(
57 Map<String, LinkedHashMap<String, Object>> inputs, String name) {
58 Map<String, Object> response = new HashMap<>();
59 ResourceConfig resourceConfig = new ResourceConfig();
61 LinkedHashMap<String, Object> memoryLimit =
62 blueprintHelperService.createStringInput(Constants.MEMORY_LIMIT_128Mi);
64 LinkedHashMap<String, Object> cpuLimit =
65 blueprintHelperService.createStringInput(Constants.CPU_LIMIT_250m);
67 name = blueprintHelperService.getNamePrefix(name);
69 Map<String, GetInput> lim = new TreeMap<>();
71 GetInput cpu = new GetInput();
72 cpu.setBpInputName(name + Constants.CPU_LIMIT);
75 GetInput memL = new GetInput();
76 memL.setBpInputName(name + Constants.MEMORY_LIMIT);
77 lim.put("memory", memL);
79 inputs.put(name + Constants.CPU_LIMIT, cpuLimit);
80 inputs.put(name + Constants.MEMORY_LIMIT, memoryLimit);
82 resourceConfig.setLimits(lim);
84 Map<String, GetInput> req = new TreeMap<>();
86 GetInput cpuR = new GetInput();
87 cpuR.setBpInputName(name + Constants.CPU_REQUEST);
90 GetInput memR = new GetInput();
91 memR.setBpInputName(name + Constants.MEMORY_REQUEST);
92 req.put("memory", memR);
94 inputs.put(name + Constants.CPU_REQUEST, cpuLimit);
95 inputs.put(name + Constants.MEMORY_REQUEST, memoryLimit);
97 resourceConfig.setRequests(req);
99 response.put("resourceConfig", resourceConfig);
100 response.put("inputs", inputs);