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;
}
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;
}
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;
}
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"));
}
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));
}
}
Aggregations