Add log cli 58/92558/5
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Fri, 2 Aug 2019 09:10:14 +0000 (14:40 +0530)
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Tue, 6 Aug 2019 07:29:59 +0000 (12:59 +0530)
Issue-ID: VNFSDK-424

Change-Id: If3fcd4b7db74389beefe0520d158613073cb30e3
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResource.java

index 1427a57..b0cbcad 100644 (file)
@@ -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<String> 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();
+    }
 }