diff options
author | Vikas Sharma <svikas@huawei.com> | 2017-03-28 15:00:42 +0530 |
---|---|---|
committer | Vikas Sharma <svikas@huawei.com> | 2017-03-28 15:00:42 +0530 |
commit | 4ee72619a7b93e187771aa23284387a8196dde7d (patch) | |
tree | bd0200ba92f8f84980660e30bc53793e6e6d3aaf /vnf-sdk-function-test/src/main | |
parent | 8dcfd784d1739b29e63d5729908b71d41f986995 (diff) |
Added UPLOAD and EXECUTE interfaces.
issue_id:VNFSDK-21
Change-Id: I2da6c1870c0f0b7ded232b6fd6186c3ef8c8da8c
Signed-off-by: Vikas Sharma <svikas@huawei.com>
Diffstat (limited to 'vnf-sdk-function-test/src/main')
-rw-r--r-- | vnf-sdk-function-test/src/main/java/org/openo/vnfsdk/functest/resource/CommonManager.java | 21 |
1 files changed, 10 insertions, 11 deletions
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<Integer>() { - 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); |