io.cloudslang.content.ssh.services.SSHService Maven / Gradle / Ivy
/*******************************************************************************
* (c) Copyright 2017 Hewlett-Packard Development Company, L.P.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License v2.0 which accompany this distribution.
*
* The Apache License is available at
* http://www.apache.org/licenses/LICENSE-2.0
*
*******************************************************************************/
package io.cloudslang.content.ssh.services;
import com.hp.oo.sdk.content.plugin.GlobalSessionObject;
import com.jcraft.jsch.Channel;
import com.jcraft.jsch.Session;
import io.cloudslang.content.ssh.entities.CommandResult;
import io.cloudslang.content.ssh.entities.SSHConnection;
import java.util.Map;
/**
* @author ioanvranauhp
* Date: 10/29/14
*/
public interface SSHService extends AutoCloseable {
/**
* Run a Shell command(s) using SSH protocol, using a direct shell.
*
* @param command The Shell command(s).
* @param characterSet The character set for the command and for the output of the command.
* @param usePseudoTerminal If true the result will be formatted like in a terminal.
* @param connectTimeout The channel connection timeout.
* @param commandTimeout The command timeout.
* @param agentForwarding Weathers the agent forwarding is enabled or not.
* @return the command result.
*/
CommandResult runShell(String command, String characterSet, boolean usePseudoTerminal, int connectTimeout, int commandTimeout, boolean agentForwarding);
/**
* Run a Shell command(s) using SSH protocol.
*
* @param command The Shell command(s).
* @param characterSet The character set for the command and for the output of the command.
* @param usePseudoTerminal If true the result will be formatted like in a terminal.
* @param connectTimeout The channel connection timeout.
* @param commandTimeout The command timeout.
* @param agentForwarding Weathers the agent forwarding is enabled or not.
* @return the command result.
*/
CommandResult runShellCommand(String command, String characterSet, boolean usePseudoTerminal, int connectTimeout, int commandTimeout, boolean agentForwarding);
/**
* Checks the SSH session.
*
* @return true if the SSH session is opened, otherwise false.
*/
boolean isConnected();
/**
* Close the SSH session.
*/
void close();
/**
* Save the SSH session in the cache (Operation Orchestration session).
*
* @param sessionParam The cache (Operation Orchestration session).
* @param sessionId The key of the Operation Orchestration session.
*/
boolean saveToCache(GlobalSessionObject