use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class TransformationController method getInputs.
/**
* Returns a list of inputs that might have to be set (if they are required) in order to start
* the transformation <p>
* Accessed with http call <code>GET /csars/{csar}/transformations/{platform}/inputs</code>
* <table summary="">
* <tr>
* <td>HTTP-Code</td>
* <td>Mime-Type</td>
* <td>Description (Returned if)</td>
* </tr>
* <tr>
* <td>200</td>
* <td>application/hal+json</td>
* <td>Returned with content body (See samples.md) if the operation was successful</td>
* </tr>
* <tr>
* <td>404</td>
* <td>application/json</td>
* <td>Returns a error message if the csar is not found or if the csar does not have a transformation for the given
* name (see returned error message for details)</td>
* </tr>
* </table>
*/
@RequestMapping(path = "/{platform}/inputs", method = RequestMethod.GET, produces = "application/hal+json")
@ApiOperation(value = "Retrieve the inputs of this transformation", tags = { "transformations" }, notes = "This Operation returns a list of inputs, specific to the csar and the platform. " + "If the input is invalid it has to be set in order to proceed with " + "starting the transformation. Setting the inputs is done with a POST or PUT to the same URL " + "(See Set Inputs Operation). If Transformation does not have any inputs, an empty array " + "is returned")
@ApiResponses({ @ApiResponse(code = 200, message = "The operation was executed successfully", response = GetInputsResponse.class), @ApiResponse(code = 404, message = "There is no CSAR for the given identifier or the CSAR does not have " + "a Transformation for the specified platform.", response = RestErrorResponse.class) })
public ResponseEntity<GetInputsResponse> getInputs(@ApiParam(value = "The identifier for the CSAR", required = true, example = "test") @PathVariable(name = "csarId") String csarId, @ApiParam(value = "The identifier for the platform", required = true, example = "kubernetes") @PathVariable(name = "platform") String platformId) {
Csar csar = findByCsarId(csarId);
Transformation transformation = findTransformationByPlatform(csar, platformId);
List<InputWrap> inputWrapList = toPropertyWrapList(transformation.getInputs(), null);
GetInputsResponse response = new GetInputsResponse(csarId, platformId, inputWrapList);
return ResponseEntity.ok(response);
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class TransformationController method getCSARTransformation.
/**
* Returns information about a single transformation
* <p>
* Accessed with http call <code>GET /csars/{csar}/transformations/{platform}/</code>
* <table summary="">
* <tr>
* <td>HTTP-Code</td>
* <td>Mime-Type</td>
* <td>Description (Returned if)</td>
* </tr>
* <tr>
* <td>200</td>
* <td>application/hal+json</td>
* <td>Returns a empty body if the transformation has been started</td>
* </tr>
* <tr>
* <td>404</td>
* <td>application/json</td>
* <td>Returns a error message if the csar is not found or if the csar does not have a transformation for the given
* name (see returned error message for details)</td>
* </tr>
* </table>
*/
@RequestMapping(path = "/{platform}", method = RequestMethod.GET, produces = "application/hal+json")
@ApiOperation(value = "Get details for a specific transformation", tags = { "transformations" }, notes = "Returns a HAL-Resource Containing the details for the transformation with the given parameters")
@ApiResponses({ @ApiResponse(code = 200, message = "The operation was executed successfully"), @ApiResponse(code = 404, message = "There is no CSAR for the given identifier or the CSAR does not have " + "a Transformation for the specified platform.", response = RestErrorResponse.class) })
public ResponseEntity<TransformationResponse> getCSARTransformation(@ApiParam(value = "The unique identifier for the CSAR", required = true, example = "test") @PathVariable(name = "csarId") String name, @ApiParam(value = "The identifier for the platform", required = true, example = "kubernetes") @PathVariable(name = "platform") String platform) {
Csar csar = findByCsarId(name);
Transformation transformation = findTransformationByPlatform(csar, platform);
return ResponseEntity.ok().body(new TransformationResponse(transformation.getLifecyclePhases(), transformation.getState(), platform, name));
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class CsarFilesystemDao method readFromDisk.
/**
* Reads csars from disks post: csarMap reflects contents of DATA_DIR on disk
*/
private void readFromDisk() {
csarMap.clear();
dataDir.mkdir();
logger.info("Reading CSARs from repository");
File[] files = dataDir.listFiles();
for (File file : files) {
if (isCsarDir(file)) {
String id = file.getName();
new File(getRootDir(id), id + ".log").delete();
CsarImpl csar = new CsarImpl(getRootDir(id), id, getLog(id));
LifecyclePhase unzip = csar.getLifecyclePhase(Csar.Phase.UNZIP);
if (csar.getContentDir().listFiles().length != 0) {
unzip.setState(LifecyclePhase.State.DONE);
csar.validate();
} else {
unzip.setState(LifecyclePhase.State.FAILED);
}
csarMap.put(csar.getIdentifier(), csar);
List<Transformation> transformations = transformationDao.find(csar);
csar.setTransformations(transformations);
csar.getLog().close();
}
}
logger.info("Found {} CSARs in repository", csarMap.size());
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class CsarControllerTest method testDeleteCsarBusy.
@Test
public void testDeleteCsarBusy() throws Exception {
// Add mock transformation to csar
Csar csar = service.getCsar(VALID_CSAR_NAME).get();
Transformation transformation = new TransformationImpl(csar, PLATFORM1, logMock(), modelMock());
transformation.setState(TransformationState.TRANSFORMING);
csar.getTransformations().put(PLATFORM1.id, transformation);
// Perform request
mvc.perform(delete(DELETE_VALID_CSAR_URL)).andDo(print()).andExpect(status().is(400));
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class TransformationControllerTest method testGetOutputs.
// </editor-fold>
// <editor-fold desc="Output Tests">
@Test
public void testGetOutputs() throws Exception {
List<Transformation> transformations = preInitNonCreationTests();
Transformation t = transformations.get(0);
when(t.getState()).thenReturn(TransformationState.DONE);
String outputKey = "test_output";
List<OutputProperty> outputs = Lists.newArrayList(new PlatformInput(outputKey, PropertyType.TEXT, "", true, "some value"));
when(t.getOutputs()).thenReturn(outputs);
mvc.perform(get(GET_OUTPUT_URL)).andDo(print()).andExpect(status().is(200)).andExpect(jsonPath("$.outputs").isArray()).andExpect(jsonPath("$.links[0].href").value("http://localhost" + GET_OUTPUT_URL)).andExpect(jsonPath("$.outputs[0].key").value(outputKey)).andReturn();
}
Aggregations