From 41ac47d732eed8392d60d0f6773e5a279d49b999 Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 12 Dec 2013 13:36:50 +0100 Subject: initial commit of Enea Linux 3.1 Migrated from the internal git server on the dora-enea branch Signed-off-by: Adrian Dudau --- .../sdk/remotetools/actions/SystemtapModel.java | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java (limited to 'plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java') diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java new file mode 100644 index 0000000..bb2fa2d --- /dev/null +++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/SystemtapModel.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2010 Intel Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel - initial API and implementation + *******************************************************************************/ +package org.yocto.sdk.remotetools.actions; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.console.ConsolePlugin; +import org.eclipse.ui.console.IConsole; +import org.eclipse.ui.console.IConsoleManager; +import org.eclipse.ui.console.MessageConsole; +import org.yocto.remote.utils.ShellSession; + +public class SystemtapModel extends BaseModel { + protected static final String DEFAULT_INIT_SCRIPT = "oe-init-build-env"; + protected static final String SYSTEMTAP_CONSOLE = "Systemtap Console"; + + private static final String TASK_NAME = "systemtap command"; + + protected MessageConsole sessionConsole; + private String metadata_location; + private String builddir_location; + private String remote_host; + private String user_id; + private String systemtap_script; + private String systemtap_args; + + Display display; + + public SystemtapModel(String metadata_location, String builddir_location, String remote_host, String user_id, String systemtap_script, String systemtap_args, Display display) { + super(null, TASK_NAME, "", ""); + this.metadata_location = metadata_location; + this.builddir_location = builddir_location; + this.remote_host = remote_host; + this.user_id = user_id; + this.systemtap_script = systemtap_script; + this.systemtap_args = systemtap_args; + this.display = display; + if (sessionConsole == null) { + IConsoleManager conMan = ConsolePlugin.getDefault().getConsoleManager(); + IConsole[] existing = conMan.getConsoles(); + for (int i = 0; i < existing.length; i++) + if (SYSTEMTAP_CONSOLE.equals(existing[i].getName())) { + sessionConsole = (MessageConsole) existing[i]; + break; + } + if (sessionConsole == null) { + sessionConsole = new MessageConsole(SYSTEMTAP_CONSOLE, null); + conMan.addConsoles(new IConsole[] { sessionConsole }); + } + } + + ConsolePlugin.getDefault().getConsoleManager().showConsoleView(sessionConsole); + } + + @Override + public void preProcess(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException {} + + @Override + public void process(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + try { + ShellSession shell = new ShellSession(ShellSession.SHELL_TYPE_BASH, + new File(this.metadata_location), new File(this.builddir_location), + DEFAULT_INIT_SCRIPT, sessionConsole.newOutputStream()); + boolean acceptedKey = shell.ensureKnownHostKey(user_id, remote_host); + if (acceptedKey) { + String crosstapCmd = "crosstap " + user_id + "@" + remote_host + " " + systemtap_script; + if (systemtap_args != null) + crosstapCmd = crosstapCmd + " " + systemtap_args; + shell.execute(crosstapCmd); + } + } catch (Exception e) { + throw new InvocationTargetException(e,e.getMessage()); + } + } +} -- cgit v1.2.3-54-g00ecf