RemoteFileUtil

public class RemoteFileUtil
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.RemoteFileUtil


Utility class to handle file from a remote instance

Summary

Public constructors

RemoteFileUtil()

Public methods

static boolean doesRemoteFileExist(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remotePath)

Check if a file (or directory) exists on the remote instance

static boolean doesRemoteFileExist(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remotePath, String sshPortNumber)

Check if a file (or directory) exists on the remote instance

static boolean fetchRemoteDir(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteDirPath, File localDir)

Fetch a remote directory from the remote host.

static File fetchRemoteDir(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteDirPath)

Fetch a remote directory from the remote host.

static File fetchRemoteDir(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteDirPath)

Fetch a remote directory from the remote host.

static boolean fetchRemoteDir(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteDirPath, File localDir)

Fetch a remote directory from the remote host.

static File fetchRemoteFile(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath)

Fetch a remote file in the container instance.

static File fetchRemoteFile(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteFilePath)

Fetch a remote file in the container instance.

static boolean fetchRemoteFile(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)

Fetch a remote file in the device or container instance.

static boolean fetchRemoteFile(String host, String user, File sshPrivateKey, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)

Fetch a remote file in the device or container instance.

static boolean pushFileToRemote(String host, String user, File sshPrivateKey, List<String> scpArgs, IRunUtil runUtil, long timeout, String remoteFilePath, File localFile)

Push a File from the local host to the remote instance

Public constructors

RemoteFileUtil

public RemoteFileUtil ()

Public methods

doesRemoteFileExist

public static boolean doesRemoteFileExist (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remotePath)

Check if a file (or directory) exists on the remote instance

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remotePath String: The remote path where to find the file.

Returns
boolean whether the file exists or not

doesRemoteFileExist

public static boolean doesRemoteFileExist (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remotePath, 
                String sshPortNumber)

Check if a file (or directory) exists on the remote instance

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remotePath String: The remote path where to find the file.

sshPortNumber String: port number for ssh.

Returns
boolean whether the file exists or not

fetchRemoteDir

public static boolean fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath, 
                File localDir)

Fetch a remote directory from the remote host.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteDirPath String: The remote path where to find the directory.

localDir File: The local directory where to put the pulled files.

Returns
boolean True if successful, False otherwise

fetchRemoteDir

public static File fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath)

Fetch a remote directory from the remote host.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteDirPath String: The remote path where to find the directory.

Returns
File The pulled directory File if successful, null otherwise

fetchRemoteDir

public static File fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath)

Fetch a remote directory from the remote host.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

scpArgs List: extra args to be passed to the scp command

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteDirPath String: The remote path where to find the directory.

Returns
File The pulled directory File if successful, null otherwise

fetchRemoteDir

public static boolean fetchRemoteDir (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteDirPath, 
                File localDir)

Fetch a remote directory from the remote host.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

scpArgs List: extra args to be passed to the scp command

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteDirPath String: The remote path where to find the directory.

localDir File: The local directory where to put the pulled files.

Returns
boolean True if successful, False otherwise

fetchRemoteFile

public static File fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath)

Fetch a remote file in the container instance.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

scpArgs List: extra args to be passed to the scp command

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteFilePath String: The remote path where to find the file.

Returns
File The pulled filed if successful, null otherwise

fetchRemoteFile

public static File fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath)

Fetch a remote file in the container instance.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteFilePath String: The remote path where to find the file.

Returns
File The pulled filed if successful, null otherwise

fetchRemoteFile

public static boolean fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath, 
                File localFile)

Fetch a remote file in the device or container instance.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

scpArgs List: extra args to be passed to the scp command

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteFilePath String: The remote path where to find the file.

localFile File: The local File where the remote file will be pulled

Returns
boolean True if successful, False otherwise

fetchRemoteFile

public static boolean fetchRemoteFile (String host, 
                String user, 
                File sshPrivateKey, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath, 
                File localFile)

Fetch a remote file in the device or container instance.

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File: The file containing the ssh key to use.

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteFilePath String: The remote path where to find the file.

localFile File: The local File where the remote file will be pulled

Returns
boolean True if successful, False otherwise

pushFileToRemote

public static boolean pushFileToRemote (String host, 
                String user, 
                File sshPrivateKey, 
                List<String> scpArgs, 
                IRunUtil runUtil, 
                long timeout, 
                String remoteFilePath, 
                File localFile)

Push a File from the local host to the remote instance

Parameters
host String: The remote host.

user String: The user on the remote host

sshPrivateKey File

scpArgs List: extra args to be passed to the scp command

runUtil IRunUtil: a IRunUtil to execute commands.

timeout long: in millisecond for the fetch to complete

remoteFilePath String: The remote path where to find the file.

localFile File: The local File where the remote file will be pulled

Returns
boolean True if successful, False otherwise