From 70dac125e796d52b874f4e7f3839f9cf042e0f98 Mon Sep 17 00:00:00 2001 From: Kanagaraj Manickam Date: Thu, 29 Aug 2019 15:41:53 +0530 Subject: Minor issues fix Issue-ID: CLI-166 Change-Id: I97bd303b4e636bfc53e24732c7c6e4062037909b Signed-off-by: Kanagaraj Manickam k00365106 --- .../onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'profiles/command/src') diff --git a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java index 40ccf5c4..bc864529 100644 --- a/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java +++ b/profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import org.apache.commons.io.FileUtils; import org.onap.cli.fw.cmd.OnapCommand; import org.onap.cli.fw.cmd.conf.OnapCommandCmdConstants; import org.onap.cli.fw.cmd.error.OnapCommandCmdFailure; @@ -175,11 +176,13 @@ public class OpenCommandShellCmd extends OnapCommand { //add oclip specific environment variables if (this.getExecutionContext() != null) { envs.add("OPEN_CLI_REQUEST_ID=" + this.getExecutionContext().getRequestId()); + if (this.getExecutionContext().getProfile() != null) { + envs.add("OPEN_CLI_PROFILE=" + this.getExecutionContext().getProfile()); + } if (OnapCommandRegistrar.getRegistrar().getHost() != null) { envs.add("OPEN_CLI_RPC_HOST=" + OnapCommandRegistrar.getRegistrar().getHost()); envs.add("OPEN_CLI_RPC_PORT=" + OnapCommandRegistrar.getRegistrar().getPort()); } - //mrkanag set the profile OPEN_CLI_PROFILE } for (String env: this.getEnvs().keySet()) { @@ -315,7 +318,32 @@ public class OpenCommandShellCmd extends OnapCommand { int idxE = line.indexOf("}", idxS); String tmpName = line.substring(idxS + 7, idxE); tmpName = tmpName.trim(); - result.put("tmp:" + tmpName, this.getOutputAttributeFilePath(tmpName, true)); + String tmpTkns[] = tmpName.split(":"); + String tmpFileName; + String paramName; + if (tmpTkns.length == 2) { + tmpFileName = tmpTkns[0]; + paramName = tmpTkns[1]; + } else { + tmpFileName = tmpTkns[0]; + paramName = null; + } + + String tmpFilePath = this.getOutputAttributeFilePath(tmpFileName, true); + if (paramName != null) { + //Write the value of input params into file before passing to command + try { + FileUtils.touch(new File(tmpFilePath)); + FileUtils.writeStringToFile(new File(tmpFilePath), + this.getParametersMap().get(paramName).getValue().toString()); + } catch (IOException e) { + // NO SONAR + } + } + + result.put("tmp:" + tmpFileName, tmpFilePath); //used in output parsing + result.put("tmp:" + tmpName, tmpFilePath); //used in line replacement + currentIdx = idxE + 1; } return result; -- cgit 1.2.3-korg