use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class VfModuleCustomizationToVduMapper method mapCloudFiles.
private void mapCloudFiles(VfModuleCustomization vfModuleCustom, VduModelInfo vduModel) {
// TODO: These catalog objects will be refactored to be non-Heat-specific
List<VduArtifact> vduArtifacts = vduModel.getArtifacts();
// Attached Files
List<HeatFiles> heatFiles = vfModuleCustom.getVfModule().getHeatFiles();
if (heatFiles != null) {
for (HeatFiles file : heatFiles) {
vduArtifacts.add(mapCloudFileToVduArtifact(file, ArtifactType.TEXT_FILE));
}
}
}
use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class MsoHeatUtils method instantiateVdu.
/**
*****************************************************************************
*
* Methods (and associated utilities) to implement the VduPlugin interface
*
******************************************************************************
*/
/**
* 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("MsoHeatUtils (instantiateVDU): createStack Exception", e);
}
}
use of org.onap.so.adapters.vdu.VduArtifact in project so by onap.
the class MsoHeatUtilsITTest method instantiateVduTest.
@Test
public void instantiateVduTest() throws MsoException, IOException {
VduInstance expected = new VduInstance();
expected.setVduInstanceId("name/da886914-efb2-4917-b335-c8381528d90b");
expected.setVduInstanceName("name");
VduStatus status = new VduStatus();
status.setState(VduStateType.INSTANTIATED);
status.setLastAction((new PluginAction("create", "complete", null)));
expected.setStatus(status);
CloudInfo cloudInfo = new CloudInfo();
cloudInfo.setCloudSiteId("MTN13");
cloudInfo.setTenantId("tenantId");
VduModelInfo vduModel = new VduModelInfo();
vduModel.setModelCustomizationUUID("blueprintId");
vduModel.setTimeoutMinutes(1);
VduArtifact artifact = new VduArtifact();
artifact.setName("name");
artifact.setType(ArtifactType.MAIN_TEMPLATE);
byte[] content = new byte[1];
artifact.setContent(content);
List<VduArtifact> artifacts = new ArrayList<>();
artifacts.add(artifact);
vduModel.setArtifacts(artifacts);
Map<String, byte[]> blueprintFiles = new HashMap<>();
blueprintFiles.put(artifact.getName(), artifact.getContent());
String instanceName = "stackname";
Map<String, Object> inputs = new HashMap<>();
boolean rollbackOnFailure = true;
StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/stackname/stackId")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
VduInstance actual = heatUtils.instantiateVdu(cloudInfo, instanceName, inputs, vduModel, rollbackOnFailure);
assertThat(actual, sameBeanAs(expected));
}
Aggregations