3 * * ============LICENSE_START=======================================================
5 * * ================================================================================
6 * * Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
7 * * Copyright (c) 2021 Nokia. All rights reserved.
8 * * ================================================================================
9 * * Licensed under the Apache License, Version 2.0 (the "License");
10 * * you may not use this file except in compliance with the License.
11 * * You may obtain a copy of the License at
13 * * http://www.apache.org/licenses/LICENSE-2.0
15 * * Unless required by applicable law or agreed to in writing, software
16 * * distributed under the License is distributed on an "AS IS" BASIS,
17 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * * See the License for the specific language governing permissions and
19 * * limitations under the License.
20 * * ============LICENSE_END=========================================================
25 package org.onap.blueprintgenerator.service.common;
27 import org.onap.blueprintgenerator.model.common.GetInput;
28 import org.onap.blueprintgenerator.model.common.StartInputs;
29 import org.onap.blueprintgenerator.model.componentspec.OnapAuxilary;
30 import org.onap.blueprintgenerator.model.componentspec.OnapComponentSpec;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Service;
34 import java.util.LinkedHashMap;
36 import java.util.ArrayList;
37 import java.util.HashMap;
38 import java.util.List;
41 * @author : Ravi Mantena
42 * @date 10/16/2020 Application: ONAP - Blueprint Generator Common ONAP Service to add Start Inputs
46 public class StartInputsService {
49 private PgaasNodeService pgaasNodeService;
52 * Creates Start Inputs for Start in Interfaces
54 * @param inputs Inputs
55 * @param onapComponentSpec OnapComponentSpec
58 public Map<String, Object> createStartInputs(
59 Map<String, Map<String, Object>> inputs, OnapComponentSpec onapComponentSpec) {
61 Map<String, Object> response = new HashMap<>();
62 StartInputs startInputs = new StartInputs();
65 List<String> portList = new ArrayList();
66 OnapAuxilary aux = onapComponentSpec.getAuxilary();
68 if (aux.getPorts() != null) {
69 for (Object p : aux.getPorts()) {
70 String[] ports = p.toString().split(":");
72 String.format("concat: [\"%s:\", {get_input: external_port_%d}]", ports[0],
75 Map<String, Object> portType = new LinkedHashMap();
76 portType.put("type", "string");
77 portType.put("default", ports[1]);
78 inputs.put("external_port_" + count, portType);
83 startInputs.setPorts(portList);
85 Map<String, Object> envMap = new LinkedHashMap();
86 if (onapComponentSpec.getAuxilary().getDatabases() != null) {
87 Map<String, Object> envVars =
88 pgaasNodeService.getEnvVariables(onapComponentSpec.getAuxilary().getDatabases());
89 startInputs.setEnvs(envVars);
90 envMap.put("default", "&envs {}");
92 GetInput env = new GetInput();
93 env.setBpInputName("envs");
94 startInputs.setEnvs(env);
95 envMap.put("default", "{}");
97 inputs.put("envs", envMap);
99 response.put("startInputs", startInputs);
100 response.put("inputs", inputs);