use of com.microsoft.azure.toolkit.lib.appservice.TunnelProxy in project azure-tools-for-java by Microsoft.
the class SSHIntoWebAppAction method actionPerformed.
@Override
protected void actionPerformed(NodeActionEvent nodeActionEvent) throws AzureCmdException {
logger.info(message("webapp.ssh.hint.startSSH", webAppName));
// ssh to connect to remote web app container.
final AzureString title = title("webapp|ssh.connect", webAppName);
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, title, false, () -> {
final TunnelProxy proxy = new TunnelProxy(webApp);
int localPort;
try {
localPort = proxy.start();
} catch (IOException e) {
try {
proxy.close();
} catch (Throwable ex) {
// ignore
}
throw new AzureToolkitRuntimeException(message("webapp.ssh.error.message"));
}
final int finalLocalPort = localPort;
// ssh to local proxy and open terminal.
AzureTaskManager.getInstance().runAndWait(() -> {
// create a new terminal tab.
TerminalView terminalView = TerminalView.getInstance(project);
ShellTerminalWidget shellTerminalWidget = terminalView.createLocalShellWidget(null, String.format(WEBAPP_TERMINAL_TABLE_NAME, webAppName));
final AzureString messageTitle = title("webapp|ssh.open", webAppName);
AzureTaskManager.getInstance().runInBackground(new AzureTask(project, messageTitle, false, () -> {
// create connection to the local proxy.
final SSHTerminalManager.CreateRemoteConnectionInfo info = new SSHTerminalManager.CreateRemoteConnectionInfo();
info.setUsername(TunnelProxy.DEFAULT_SSH_USERNAME);
info.setPassword(TunnelProxy.DEFAULT_SSH_PASSWORD);
info.setPort(finalLocalPort);
SSHTerminalManager.INSTANCE.openConnectionInTerminal(shellTerminalWidget, info);
}));
}, AzureTask.Modality.ANY);
}));
logger.info(message("webapp.ssh.hint.SSHDone", webAppName));
}
Aggregations