| author | Lukas Berk | 2012-10-11 09:10:02 (EDT) |
|---|---|---|
| committer | Sami Wagiaalla | 2012-10-16 11:12:19 (EDT) |
| commit | 0a3006a0d84a904a4bb6e37a2b0104d6e06aec1c (patch) (side-by-side diff) | |
| tree | e13014afa9a6da5ad3d54ab5bd7e1cd0aca4594f | |
| parent | fe2a8c2cc440595d2ac46c1e020b77a43a990df4 (diff) | |
| download | org.eclipse.linuxtools-0a3006a0d84a904a4bb6e37a2b0104d6e06aec1c.zip org.eclipse.linuxtools-0a3006a0d84a904a4bb6e37a2b0104d6e06aec1c.tar.gz org.eclipse.linuxtools-0a3006a0d84a904a4bb6e37a2b0104d6e06aec1c.tar.bz2 | |
Add functionality and API to run script locally
Running a systemtap script should not require the sshd service,
especially when simply trying to run the script locally. This patch
adds the functionality to bypass the scp/ssh portions of the code and
simply run the command locally. A get/set style api has been added to
modify and read a protected boolean representing the local/remote
choice. The default remains to use sshd in order to keep the current
implemenation the same. A section in the systemtap preferences should
be set up to modify and set the local/remote settings.
Change-Id: I93b69ff0e398bdc83c5fd7f7d280b0847fccd42a
Reviewed-on: https://git.eclipse.org/r/8164
Tested-by: Hudson CI
Reviewed-by: Sami Wagiaalla <swagiaal@redhat.com>
IP-Clean: Sami Wagiaalla <swagiaal@redhat.com>
Tested-by: Sami Wagiaalla <swagiaal@redhat.com>
| -rw-r--r-- | systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/actions/RunScriptAction.java | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/actions/RunScriptAction.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/actions/RunScriptAction.java index 6401ca2..822c27e 100644 --- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/actions/RunScriptAction.java +++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/actions/RunScriptAction.java @@ -83,26 +83,31 @@ public class RunScriptAction extends Action implements IWorkbenchWindowActionDel public void run() { LogManager.logDebug("Start run:", this); //$NON-NLS-1$ continueRun = true; - if(ConsoleLogPlugin.getDefault().getPreferenceStore().getBoolean(ConsoleLogPreferenceConstants.REMEMBER_SERVER)!=true && + + if(getRunLocal() == false && ConsoleLogPlugin.getDefault().getPreferenceStore().getBoolean(ConsoleLogPreferenceConstants.REMEMBER_SERVER)!=true && new SelectServerDialog(fWindow.getShell()).open() == false) return; if(isValid()) { - try{ + if(getRunLocal() == false) { + try{ ScpClient scpclient = new ScpClient(); serverfileName = fileName.substring(fileName.lastIndexOf('/')+1); tmpfileName="/tmp/"+ serverfileName; scpclient.transfer(fileName,tmpfileName); }catch(Exception e){e.printStackTrace();} - + } String[] script = buildScript(); String[] envVars = getEnvironmentVariables(); if(continueRun) { - - - ScriptConsole console = ScriptConsole.getInstance(serverfileName); + ScriptConsole console; + if(getRunLocal() == false) { + console = ScriptConsole.getInstance(serverfileName); + } else { + console = ScriptConsole.getInstance(fileName); + } console.run(script, envVars, new PasswordPrompt(IDESessionSettings.password), new StapErrorParser()); } } @@ -285,22 +290,35 @@ public class RunScriptAction extends Action implements IWorkbenchWindowActionDel script = new String[cmdList.size() + 4]; script[0] = "stap"; //$NON-NLS-1$ - - script[script.length-1] = tmpfileName; + + if(getRunLocal() == false) + script[script.length-1] = tmpfileName; + else + script[script.length-1] = fileName; for(int i=0; i< cmdList.size(); i++) { script[i+1] = cmdList.get(i).toString(); } script[script.length-3]="-m"; - - String modname = serverfileName.substring(0, serverfileName.indexOf('.')); + + String modname; + if(getRunLocal() == false) { + modname = serverfileName.substring(0, serverfileName.indexOf('.')); + } + /* We need to remove the directory prefix here because in the case of + * running the script remotely, this is already done. Not doing so + * causes a modname error. + */ + else { + modname = fileName.substring(fileName.lastIndexOf('/')+1); + modname = modname.substring(0, modname.indexOf('.')); + } if (modname.indexOf('-') != -1) modname = modname.substring(0, modname.indexOf('-')); script[script.length-2]=modname; - return script; } - + protected String[] getEnvironmentVariables() { return EnvironmentVariablesPreferencePage.getEnvironmentVariables(); } @@ -325,7 +343,16 @@ public class RunScriptAction extends Action implements IWorkbenchWindowActionDel return subscription; } + public void setLocalScript(boolean enabled) { + runLocal = enabled; + } + + public boolean getRunLocal() { + return runLocal; + } + protected boolean continueRun = true; + protected boolean runLocal = false; protected String fileName = null; protected String tmpfileName = null; protected String serverfileName = null; |

