diff options
author | Kanagaraj Manickam <mkr1481@gmail.com> | 2019-08-29 15:41:53 +0530 |
---|---|---|
committer | Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com> | 2019-08-29 15:41:53 +0530 |
commit | 70dac125e796d52b874f4e7f3839f9cf042e0f98 (patch) | |
tree | 9382129179acf1a0b0e82c5051a0f287f000c0e1 /profiles/command | |
parent | 02b61c5a78448d2c01ce15adecb6df99f1b6b8c8 (diff) |
Minor issues fix
Issue-ID: CLI-166
Change-Id: I97bd303b4e636bfc53e24732c7c6e4062037909b
Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'profiles/command')
-rw-r--r-- | profiles/command/src/main/java/org/onap/cli/fw/cmd/cmd/OpenCommandShellCmd.java | 32 |
1 files changed, 30 insertions, 2 deletions
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; |