use of org.onap.so.adapters.vdu.PluginAction in project so by onap.
the class MsoHeatUtils method stackStatusToVduStatus.
private VduStatus stackStatusToVduStatus(StackInfo stackInfo) {
VduStatus vduStatus = new VduStatus();
// Map the status fields to more generic VduStatus.
// There are lots of HeatStatus values, so this is a bit long...
HeatStatus heatStatus = stackInfo.getStatus();
String statusMessage = stackInfo.getStatusMessage();
if (heatStatus == HeatStatus.INIT || heatStatus == HeatStatus.BUILDING) {
vduStatus.setState(VduStateType.INSTANTIATING);
vduStatus.setLastAction((new PluginAction("create", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.NOTFOUND) {
vduStatus.setState(VduStateType.NOTFOUND);
} else if (heatStatus == HeatStatus.CREATED) {
vduStatus.setState(VduStateType.INSTANTIATED);
vduStatus.setLastAction((new PluginAction("create", "complete", statusMessage)));
} else if (heatStatus == HeatStatus.UPDATED) {
vduStatus.setState(VduStateType.INSTANTIATED);
vduStatus.setLastAction((new PluginAction("update", "complete", statusMessage)));
} else if (heatStatus == HeatStatus.UPDATING) {
vduStatus.setState(VduStateType.UPDATING);
vduStatus.setLastAction((new PluginAction("update", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.DELETING) {
vduStatus.setState(VduStateType.DELETING);
vduStatus.setLastAction((new PluginAction("delete", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.FAILED) {
vduStatus.setState(VduStateType.FAILED);
vduStatus.setErrorMessage(stackInfo.getStatusMessage());
} else {
vduStatus.setState(VduStateType.UNKNOWN);
}
return vduStatus;
}
use of org.onap.so.adapters.vdu.PluginAction in project so by onap.
the class MsoMulticloudUtils method stackStatusToVduStatus.
private VduStatus stackStatusToVduStatus(StackInfo stackInfo) {
VduStatus vduStatus = new VduStatus();
// Map the status fields to more generic VduStatus.
// There are lots of HeatStatus values, so this is a bit long...
HeatStatus heatStatus = stackInfo.getStatus();
String statusMessage = stackInfo.getStatusMessage();
logger.debug("HeatStatus = {} msg = {}", heatStatus, statusMessage);
if (logger.isDebugEnabled()) {
logger.debug(String.format("Stack Status: %s", heatStatus.toString()));
logger.debug(String.format("Stack Status Message: %s", statusMessage));
}
if (heatStatus == HeatStatus.INIT || heatStatus == HeatStatus.BUILDING) {
vduStatus.setState(VduStateType.INSTANTIATING);
vduStatus.setLastAction((new PluginAction("create", "in_progress", statusMessage)));
} else if (heatStatus == HeatStatus.NOTFOUND) {
vduStatus.setState(VduStateType.NOTFOUND);
} else if (heatStatus == HeatStatus.CREATED) {
vduStatus.setState(VduStateType.INSTANTIATED);
vduStatus.setLastAction((new PluginAction("create", "complete", statusMessage)));
} else if (heatStatus == HeatStatus.UPDATED) {
vduStatus.setState(VduStateType.INSTANTIATED);
vduStatus.setLastAction((new PluginAction("update", "complete", statusMessage)));
} else if (heatStatus == HeatStatus.UPDATING) {
vduStatus.setState(VduStateType.UPDATING);
vduStatus.setLastAction((new PluginAction("update", "in_progress", statusMessage)));
} else if (heatStatus == HeatStatus.DELETING) {
vduStatus.setState(VduStateType.DELETING);
vduStatus.setLastAction((new PluginAction("delete", "in_progress", statusMessage)));
} else if (heatStatus == HeatStatus.FAILED) {
vduStatus.setState(VduStateType.FAILED);
vduStatus.setErrorMessage(stackInfo.getStatusMessage());
} else {
vduStatus.setState(VduStateType.UNKNOWN);
}
return vduStatus;
}
use of org.onap.so.adapters.vdu.PluginAction in project so by onap.
the class MsoHeatUtilsITTest method queryVduTest.
@Test
public void queryVduTest() throws Exception {
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");
String instanceId = "instanceId";
StubOpenStack.mockOpenStackResponseAccess(wireMockServer, wireMockPort);
StubOpenStack.mockOpenStackPostStack_200(wireMockServer, "OpenstackResponse_Stack_Created.json");
wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/instanceId")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("OpenstackResponse_StackId.json").withStatus(HttpStatus.SC_OK)));
VduInstance actual = heatUtils.queryVdu(cloudInfo, instanceId);
assertThat(actual, sameBeanAs(expected));
}
use of org.onap.so.adapters.vdu.PluginAction 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