use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.
the class ToscaResourceInstaller method createHeatTemplateFromArtifact.
protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure, ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
HeatTemplate existingHeatTemplate = heatRepo.findByArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
if (existingHeatTemplate == null) {
HeatTemplate heatTemplate = new HeatTemplate();
List<String> typeList = new ArrayList<>();
typeList.add(ASDCConfiguration.HEAT_NESTED);
typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
heatTemplate.setTemplateBody(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
} else {
heatTemplate.setTimeoutMinutes(240);
}
heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
heatTemplate.setVersion(BigDecimalVersion.castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
} else {
heatTemplate.setArtifactChecksum(MANUAL_RECORD);
}
Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
heatTemplate.setParameters(heatParam);
vfModuleArtifact.setHeatTemplate(heatTemplate);
} else {
if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
existingHeatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
}
vfModuleArtifact.setHeatTemplate(existingHeatTemplate);
}
}
use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.
the class YamlEditor method addParameterList.
public synchronized void addParameterList(Set<HeatTemplateParam> heatSet) {
@SuppressWarnings("unchecked") Map<String, Object> resourceMap = (Map<String, Object>) yml.get("parameters");
if (resourceMap == null) {
resourceMap = new LinkedHashMap<>();
this.yml.put("parameters", resourceMap);
}
for (HeatTemplateParam heatParam : heatSet) {
Map<String, Object> paramInfo = new HashMap<>();
paramInfo.put("type", heatParam.getParamType());
resourceMap.put(heatParam.getParamName(), paramInfo);
}
// this.yml.put("parameters", resourceMap);
}
use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.
the class YamlTest method addParameterListWhenEmptyTest.
@Test
public void addParameterListWhenEmptyTest() throws Exception {
InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTestWithoutParam.yaml"));
YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
Set<HeatTemplateParam> newParamSet = new HashSet<>();
HeatTemplateParam heatParam1 = new HeatTemplateParam();
heatParam1.setHeatTemplateArtifactUuid("1");
heatParam1.setParamName("testos1");
heatParam1.setParamType("string");
HeatTemplateParam heatParam2 = new HeatTemplateParam();
heatParam2.setHeatTemplateArtifactUuid("2");
heatParam2.setParamName("testos2");
heatParam2.setParamType("number");
newParamSet.add(heatParam1);
newParamSet.add(heatParam2);
decoder.addParameterList(newParamSet);
Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
assertTrue(paramSet.size() == 2);
assertTrue(decoder.encode().contains("testos1"));
assertTrue(decoder.encode().contains("string"));
assertTrue(decoder.encode().contains("testos2"));
assertTrue(decoder.encode().contains("number"));
}
use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.
the class YamlTest method addParameterListTest.
@Test
public void addParameterListTest() throws Exception {
InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
Set<HeatTemplateParam> newParamSet = new HashSet<>();
HeatTemplateParam heatParam1 = new HeatTemplateParam();
heatParam1.setHeatTemplateArtifactUuid("1");
heatParam1.setParamName("testos1");
heatParam1.setParamType("string");
HeatTemplateParam heatParam2 = new HeatTemplateParam();
heatParam2.setHeatTemplateArtifactUuid("2");
heatParam2.setParamName("testos2");
heatParam2.setParamType("number");
newParamSet.add(heatParam1);
newParamSet.add(heatParam2);
decoder.addParameterList(newParamSet);
Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
assertTrue(paramSet.size() == 7);
Boolean check1 = Boolean.FALSE;
Boolean check2 = Boolean.FALSE;
for (HeatTemplateParam param : paramSet) {
if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
assertFalse(param.isRequired());
} else {
assertTrue(param.isRequired());
}
if ("testos1".equals(param.getParamName()) && "string".equals(param.getParamType())) {
check1 = Boolean.TRUE;
}
if ("testos2".equals(param.getParamName()) && "number".equals(param.getParamType())) {
check2 = Boolean.TRUE;
}
}
assertTrue(check1);
assertTrue(check2);
}
use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.
the class YamlTest method getParameterListTest.
@Test
public void getParameterListTest() throws Exception {
InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
assertTrue(paramSet.size() == 5);
for (HeatTemplateParam param : paramSet) {
if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
assertTrue(param.isRequired() == false);
} else {
assertTrue(param.isRequired() == true);
}
assertTrue("string".equals(param.getParamType()));
}
}
Aggregations