Search in sources :

Example 16 with HeatTemplateParam

use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.

the class MsoVnfAdapterImplTest method getVfModuleCustomization.

private VfModuleCustomization getVfModuleCustomization() {
    VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
    VfModule vfModule = new VfModule();
    vfModule.setIsBase(false);
    HeatTemplate heatTemplate = new HeatTemplate();
    heatTemplate.setTemplateBody("");
    heatTemplate.setTimeoutMinutes(200);
    HeatTemplateParam heatTemplateParam = new HeatTemplateParam();
    heatTemplateParam.setParamAlias("ParamAlias");
    heatTemplateParam.setRequired(true);
    heatTemplateParam.setParamName("test");
    Set set = new HashSet();
    set.add(heatTemplateParam);
    heatTemplate.setParameters(set);
    vfModule.setModuleHeatTemplate(heatTemplate);
    vfModuleCustomization.setVfModule(vfModule);
    HeatEnvironment heatEnvironment = new HeatEnvironment();
    heatEnvironment.setEnvironment("parameters:ist");
    vfModuleCustomization.setHeatEnvironment(heatEnvironment);
    return vfModuleCustomization;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) HeatEnvironment(org.onap.so.db.catalog.beans.HeatEnvironment) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) VfModule(org.onap.so.db.catalog.beans.VfModule) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) HashSet(java.util.HashSet)

Example 17 with HeatTemplateParam

use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.

the class ServiceMapperTest method getTestVfModuleCust.

private List<VfModuleCustomization> getTestVfModuleCust() {
    List<VfModuleCustomization> test = new ArrayList<>();
    VfModuleCustomization testVfMod = new VfModuleCustomization();
    testVfMod.setAvailabilityZoneCount(10);
    testVfMod.setInitialCount(1);
    testVfMod.setLabel("label");
    testVfMod.setMaxInstances(3);
    testVfMod.setMinInstances(1);
    testVfMod.setModelCustomizationUUID("modelCustomizationUUID");
    org.onap.so.db.catalog.beans.VfModule vfModule = new org.onap.so.db.catalog.beans.VfModule();
    vfModule.setDescription("description");
    vfModule.setIsBase(false);
    vfModule.setModelInvariantUUID("modelInvariantUUID");
    vfModule.setModelName("modelName");
    vfModule.setModelUUID("modelUUID");
    vfModule.setModelVersion("modelVersion");
    HeatTemplate moduleHeatTemplate = new HeatTemplate();
    moduleHeatTemplate.setArtifactChecksum("artifactChecksum");
    moduleHeatTemplate.setArtifactUuid("artifactUuid");
    List<HeatTemplate> childTemplates;
    // moduleHeatTemplate.setChildTemplates(childTemplates);
    moduleHeatTemplate.setDescription("description");
    Set<HeatTemplateParam> parameters = new HashSet<>();
    HeatTemplateParam heatParam = new HeatTemplateParam();
    heatParam.setHeatTemplateArtifactUuid("heatTemplateArtifactUuid");
    heatParam.setParamAlias("paramAlias");
    heatParam.setParamName("paramName");
    heatParam.setParamType("paramType");
    heatParam.setRequired(false);
    parameters.add(heatParam);
    moduleHeatTemplate.setParameters(parameters);
    moduleHeatTemplate.setTemplateBody("templateBody");
    moduleHeatTemplate.setTemplateName("templateName");
    moduleHeatTemplate.setTimeoutMinutes(1000);
    moduleHeatTemplate.setVersion("version");
    vfModule.setModuleHeatTemplate(moduleHeatTemplate);
    testVfMod.setVfModule(vfModule);
    test.add(testVfMod);
    return test;
}
Also used : ArrayList(java.util.ArrayList) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) VfModuleCustomization(org.onap.so.db.catalog.beans.VfModuleCustomization) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) HashSet(java.util.HashSet)

Example 18 with HeatTemplateParam

use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.

the class YamlEditor method getParameterList.

// Generate the parameter list based on the Heat Template
// Based on the email from Ella Kvetny:
// Within Heat Template, under parameters catalog, it might indicate the default value of the parameter
// If default value exist, the parameter is not mandatory, otherwise its value should be set
public synchronized Set<HeatTemplateParam> getParameterList(String artifactUUID) {
    Set<HeatTemplateParam> paramSet = new HashSet<>();
    @SuppressWarnings("unchecked") Map<String, Object> resourceMap = (Map<String, Object>) yml.get("parameters");
    for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) {
        HeatTemplateParam param = new HeatTemplateParam();
        Entry<String, Object> pair = stringObjectEntry;
        @SuppressWarnings("unchecked") Map<String, String> resourceEntry = (Map<String, String>) pair.getValue();
        param.setParamName(pair.getKey());
        // System.out.println(pair.getKey()+":"+type);
        if (resourceEntry.containsKey("default")) {
            param.setRequired(false);
        } else {
            param.setRequired(true);
        }
        // Now set the type
        String value = resourceEntry.get("type");
        param.setParamType(value);
        param.setHeatTemplateArtifactUuid(artifactUUID);
        paramSet.add(param);
    }
    return paramSet;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) HashSet(java.util.HashSet)

Example 19 with HeatTemplateParam

use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.

the class MsoHeatUtilsUnitTest method convertInputMapValuesTest.

@Test
public final void convertInputMapValuesTest() {
    MsoHeatUtils utils = new MsoHeatUtils();
    Map<String, Object> inputs = new HashMap<>();
    Set<HeatTemplateParam> params = new HashSet<>();
    HeatTemplate ht = new HeatTemplate();
    HeatTemplateParam htp = new HeatTemplateParam();
    htp.setParamName("vnf_name");
    htp.setParamType("string");
    params.add(htp);
    inputs.put("vnf_name", "a_vnf_name");
    htp = new HeatTemplateParam();
    htp.setParamName("image_size");
    htp.setParamType("number");
    params.add(htp);
    inputs.put("image_size", "1024");
    htp = new HeatTemplateParam();
    htp.setParamName("external");
    htp.setParamType("boolean");
    params.add(htp);
    inputs.put("external", "false");
    htp = new HeatTemplateParam();
    htp.setParamName("oam_ips");
    htp.setParamType("comma_delimited_list");
    params.add(htp);
    inputs.put("oam_ips", "a,b");
    htp = new HeatTemplateParam();
    htp.setParamName("oam_prefixes");
    htp.setParamType("json");
    params.add(htp);
    String jsonEscInput = "[{\"prefix\": \"aValue\"}, {\"prefix\": \"aValue2\"}]";
    inputs.put("oam_prefixes", jsonEscInput);
    ht.setParameters(params);
    Map<String, Object> output = utils.convertInputMap(inputs, ht);
    assertEquals("a_vnf_name", output.get("vnf_name"));
    assertEquals(1024, output.get("image_size"));
    assertEquals(false, output.get("external"));
    List<String> cdl = new ArrayList<>();
    cdl.add(0, "a");
    cdl.add(1, "b");
    assertEquals(cdl, output.get("oam_ips"));
    ObjectMapper JSON_MAPPER = new ObjectMapper();
    JsonNode jn = null;
    try {
        jn = JSON_MAPPER.readTree(jsonEscInput);
    } catch (Exception e) {
    }
    assertEquals(jn, output.get("oam_prefixes"));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) HeatTemplate(org.onap.so.db.catalog.beans.HeatTemplate) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 20 with HeatTemplateParam

use of org.onap.so.db.catalog.beans.HeatTemplateParam in project so by onap.

the class MsoYamlEditorWithEnvtTest method getParameterListFromEnvtTest.

@Test
public void getParameterListFromEnvtTest() throws JsonParseException, JsonMappingException, IOException {
    yaml = new MsoYamlEditorWithEnvt(RAW_ENTRY_WITH_NO_RESOURCE_REGISTRY.getBytes());
    HeatTemplateParam expectedHeatParam = mapper.readValue(new File(RESOURCE_PATH + "HeatTemplateParamExpected.json"), HeatTemplateParam.class);
    Set<HeatTemplateParam> heatParamSet = yaml.getParameterList();
    for (HeatTemplateParam heatParam : heatParamSet) {
        assertThat(heatParam, sameBeanAs(expectedHeatParam));
    }
}
Also used : File(java.io.File) 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