From aa7237cb5d5d0af57741be06009419bcd85bff42 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam k00365106 Date: Fri, 2 Aug 2019 14:40:14 +0530 Subject: Add log cli Issue-ID: VNFSDK-424 Change-Id: If3fcd4b7db74389beefe0520d158613073cb30e3 Signed-off-by: Kanagaraj Manickam k00365106 --- .../onap/vtp/execution/VTPExecutionResource.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'vnfmarket-be/vnf-sdk-marketplace/src') diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java index 1427a578..b0cbcad8 100644 --- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java +++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java @@ -370,4 +370,36 @@ public class VTPExecutionResource extends VTPResource{ return Response.ok(this.getTestExecutionHandler(executionId).toString(), MediaType.APPLICATION_JSON).build(); } + + public String getTestExecutionLogsHandler( + String executionId, String action) throws VTPException, IOException{ + List args = new ArrayList<>(); + args.addAll(Arrays.asList(new String[] { + "--product", "open-cli", "execution-show-" + action, "--execution-id", executionId, "--format", "text" + })); + + + Result result = this.makeRpc(args); + + return result.getOutput(); + } + + @Path("/executions/{executionId}/logs") + @GET + @ApiOperation(tags = "VTP Execution", value = "Retrieve test execution logs details", response = String.class) + @Produces(MediaType.TEXT_PLAIN) + @ApiResponses(value = { + @ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, + message = "Failed to perform the operation", + response = VTPError.class) }) + public Response getTestExecutionLogs( + @ApiParam("Test execution Id") @PathParam("executionId") String executionId, + @ApiParam("Test console reports, Options: out, err, debug") @DefaultValue("out") @QueryParam("option") String option + ) throws VTPException, IOException { + if (!(option.equalsIgnoreCase("out") || option.equalsIgnoreCase("err") || option.equalsIgnoreCase("debug"))) { + option = "out"; + } + + return Response.ok(this.getTestExecutionLogsHandler(executionId, option), MediaType.TEXT_PLAIN).build(); + } } -- cgit 1.2.3-korg