use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class MsoMulticloudUtils method instantiateVdu.
/**
* VduPlugin interface for instantiate function.
*
* Translate the VduPlugin parameters to the corresponding 'createStack' parameters, and then invoke the existing
* function.
*/
@Override
public VduInstance instantiateVdu(CloudInfo cloudInfo, String instanceName, Map<String, Object> inputs, VduModelInfo vduModel, boolean rollbackOnFailure) throws VduException {
String cloudSiteId = cloudInfo.getCloudSiteId();
String cloudOwner = cloudInfo.getCloudOwner();
String tenantId = cloudInfo.getTenantId();
// Translate the VDU ModelInformation structure to that which is needed for
// creating the Heat stack. Loop through the artifacts, looking specifically
// for MAIN_TEMPLATE and ENVIRONMENT. Any other artifact will
// be attached as a FILE.
String heatTemplate = null;
Map<String, Object> nestedTemplates = new HashMap<>();
Map<String, Object> files = new HashMap<>();
String heatEnvironment = null;
for (VduArtifact vduArtifact : vduModel.getArtifacts()) {
if (vduArtifact.getType() == ArtifactType.MAIN_TEMPLATE) {
heatTemplate = new String(vduArtifact.getContent());
} else if (vduArtifact.getType() == ArtifactType.NESTED_TEMPLATE) {
nestedTemplates.put(vduArtifact.getName(), new String(vduArtifact.getContent()));
} else if (vduArtifact.getType() == ArtifactType.ENVIRONMENT) {
heatEnvironment = new String(vduArtifact.getContent());
}
}
try {
StackInfo stackInfo = createStack(cloudSiteId, cloudOwner, tenantId, instanceName, vduModel, heatTemplate, // poll
inputs, // poll
true, // completion
vduModel.getTimeoutMinutes(), heatEnvironment, nestedTemplates, files, rollbackOnFailure, false);
// Populate a vduInstance from the StackInfo
return stackInfoToVduInstance(stackInfo);
} catch (Exception e) {
throw new VduException("MsoMulticloudUtils (instantiateVDU): createStack Exception", e);
}
}
use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class VfModuleCustomizationToVduMapper method mapHeatTemplateToVduArtifact.
private VduArtifact mapHeatTemplateToVduArtifact(HeatTemplate heatTemplate, ArtifactType artifactType) {
VduArtifact vduArtifact = new VduArtifact();
vduArtifact.setName(heatTemplate.getTemplateName());
vduArtifact.setContent(heatTemplate.getHeatTemplate().getBytes());
vduArtifact.setType(artifactType);
return vduArtifact;
}
use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class VfModuleCustomizationToVduMapper method mapEnvironmentFileToVduArtifact.
private VduArtifact mapEnvironmentFileToVduArtifact(HeatEnvironment heatEnv) {
VduArtifact vduArtifact = new VduArtifact();
vduArtifact.setName(heatEnv.getName());
vduArtifact.setContent(heatEnv.getEnvironment().getBytes());
vduArtifact.setType(ArtifactType.ENVIRONMENT);
return vduArtifact;
}
use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class VfModuleCustomizationToVduMapper method mapCloudTemplates.
private void mapCloudTemplates(HeatTemplate heatTemplate, VduModelInfo vduModel) {
// TODO: These catalog objects will be refactored to be non-Heat-specific
List<VduArtifact> vduArtifacts = vduModel.getArtifacts();
// Main template. Also set the VDU timeout based on the main template.
vduArtifacts.add(mapHeatTemplateToVduArtifact(heatTemplate, ArtifactType.MAIN_TEMPLATE));
vduModel.setTimeoutMinutes(heatTemplate.getTimeoutMinutes());
// Nested templates
List<HeatTemplate> childTemplates = heatTemplate.getChildTemplates();
if (childTemplates != null) {
for (HeatTemplate childTemplate : childTemplates) {
vduArtifacts.add(mapHeatTemplateToVduArtifact(childTemplate, ArtifactType.NESTED_TEMPLATE));
}
}
}
use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class VfModuleCustomizationToVduMapper method mapCloudFileToVduArtifact.
private VduArtifact mapCloudFileToVduArtifact(HeatFiles heatFile, ArtifactType artifactType) {
VduArtifact vduArtifact = new VduArtifact();
vduArtifact.setName(heatFile.getFileName());
vduArtifact.setContent(heatFile.getFileBody().getBytes());
vduArtifact.setType(artifactType);
return vduArtifact;
}
Aggregations