Search in sources :

Example 1 with HeatTemplateParam

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);
    }
}
Also used : HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) ArrayList(java.util.ArrayList) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam)

Example 2 with HeatTemplateParam

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);
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam)

Example 3 with HeatTemplateParam

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"));
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YamlEditor(org.onap.so.asdc.util.YamlEditor) File(java.io.File) FileInputStream(java.io.FileInputStream) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with HeatTemplateParam

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);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YamlEditor(org.onap.so.asdc.util.YamlEditor) File(java.io.File) FileInputStream(java.io.FileInputStream) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with HeatTemplateParam

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()));
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YamlEditor(org.onap.so.asdc.util.YamlEditor) File(java.io.File) FileInputStream(java.io.FileInputStream) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) Test(org.junit.Test)

Aggregations

HeatTemplateParam (org.onap.so.db.catalog.beans.HeatTemplateParam)20 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)9 HeatTemplate (org.onap.so.db.catalog.beans.HeatTemplate)9 HashSet (java.util.HashSet)8 Test (org.junit.Test)8 File (java.io.File)5 Map (java.util.Map)5 VfModuleCustomization (org.onap.so.db.catalog.beans.VfModuleCustomization)5 JsonParseException (com.fasterxml.jackson.core.JsonParseException)4 HeatEnvironment (org.onap.so.db.catalog.beans.HeatEnvironment)4 VfModule (org.onap.so.db.catalog.beans.VfModule)4 MsoException (org.onap.so.openstack.exceptions.MsoException)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 LinkedHashMap (java.util.LinkedHashMap)3 VnfException (org.onap.so.adapters.vnf.exceptions.VnfException)3 YamlEditor (org.onap.so.asdc.util.YamlEditor)3 CloudSite (org.onap.so.db.catalog.beans.CloudSite)3