From 4ee72619a7b93e187771aa23284387a8196dde7d Mon Sep 17 00:00:00 2001 From: Vikas Sharma Date: Tue, 28 Mar 2017 15:00:42 +0530 Subject: Added UPLOAD and EXECUTE interfaces. issue_id:VNFSDK-21 Change-Id: I2da6c1870c0f0b7ded232b6fd6186c3ef8c8da8c Signed-off-by: Vikas Sharma --- .../vnfsdk/functest/resource/CommonManager.java | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'vnf-sdk-function-test/src/main') diff --git a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java index 6c61e1a..6ab0bba 100644 --- a/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java +++ b/vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java @@ -207,29 +207,28 @@ public class CommonManager { LOGGER.info("execute function test"); try { + + // Upload the script and execute the script and run command + final UUID uniqueKey = UUID.randomUUID(); // Convert the stream to script folder String nl = File.separator; - String filePath = storeChunkFileInLocal("temp", "TempFile.rar", csarInputStream); + String filePath = storeChunkFileInLocal("package" + nl + uniqueKey.toString(), "TempFile.rar", csarInputStream); // Unzip the folder - String tempDir = System.getProperty("user.dir") + nl + "temp"; + String tempDir = System.getProperty("user.dir") + nl + "package" + nl + uniqueKey + nl +"temp"; FileUtil.unzip(filePath, tempDir); LOGGER.info("File path=" + filePath); - String[] directories = FileUtil.getDirectory(tempDir); - if(null != directories) { - filePath = tempDir + File.separator + directories[0]; + filePath = tempDir + File.separator + "RobotScript"; + if(!FileUtil.checkFileExist(filePath)) { + return RestResponseUtil.getErrorResponse(null); } - - // Upload the script and execute the script and run command - final UUID uniqueKey = UUID.randomUUID(); - + final String finalPath = filePath; ExecutorService es = Executors.newFixedThreadPool(3); es.submit(new Callable() { - public Integer call() throws Exception { new TaskExecution().executeScript(finalPath, uniqueKey); @@ -238,7 +237,7 @@ public class CommonManager { }); // Send REST response - return RestResponseUtil.getSuccessResponse(uniqueKey); + return RestResponseUtil.getSuccessResponse(uniqueKey.toString()); } catch(IOException e) { LOGGER.error("Upload the script and execute the script and run command", e); -- cgit 1.2.3-korg