Close
    logoCloudomation Docs

    TaskSCP

    class tasks.task_scp.TaskSCP

    Copy a file from a SCP remote host to cloudomation or vice-versa.

    This task uses SCP to copy a single file from a remote host to cloudomation or to copy a sigle file from cloudomation to a remote host.

    Inputs

    NameTypeDefaultDescription
    connect_timeoutNumber60How long to wait for the SSH connection to be established
    copy_timeoutint60How long to wait for the copy to finish
    dstStringThe path of the destination file. Use the format "cloudomation:[path]" to copy a file to cloudomation
    hostkeyStringThe OpenSSH host key to validate the hosts identity
    hostnameStringThe hostname or IP to use
    keyStringNoneThe SSH private key to use to authenticate. Either "password" or "key" must be specified
    passwordStringNoneThe password to use to authenticate. Either "password" or "key" must be specified
    portNumber22The port number to connect to
    srcStringThe path of the source file to copy. Use the format "cloudomation:[path]" to copy a file from cloudomation
    usernameStringThe user name to use

    Outputs

    NameTypeDefaultDescription
    execution_idintThe ID of the task execution
    messagestrThe ended message for the task. If the task ended with an error, the message will contain information about what went wrong
    statusstrThe ended status for the task. Either "success" or "error".

    Constants

    input_list = ['connect_timeout', 'copy_timeout', 'dst', 'hostkey', 'hostname', 'key', 'password', 'port', 'src', 'username']output_list = []version = 1

    Methods

    get_file (sftp_client, src, dst)
    put_file (sftp_client, src, dst)
    run ()

    Example

    import flow_api
    def handler(system: flow_api.System, this: flow_api.Execution):
    this.task(
    'SCP',
    hostname='my-ssh-server',
    hostkey='ssh-rsa AAAAB3NzaC1yc2E...',
    username='kevin',
    key='-----BEGIN RSA PRIVATE KEY-----\nMII...',
    name='copy apache error log from host',
    src='/var/log/httpd-error.log',
    dst='cloudomation:apache-error.log',
    )
    error_log_content = system.file('apache-error.log').get('content')
    auth_failure_count = error_log_content.count('authentication failure')
    this.log(f'there are {auth_failure_count} authentication failures')
    return this.success('all done')
    Previous
    TaskREST
    Next
    TaskSMB