Exemple #1
0
def rsync_session(src_arg, dest_arg, delete=False, pipe_output=True):
    """Perform an rsync operation over ssh using api_key's ssh key."""
    _check_rsync_dependencies()
    
    api_key = cloud.connection_info().get('api_key')
    key_file = credentials.get_sshkey_path(api_key)
    if not os.path.exists(key_file):
        raise cloud.CloudException('%s not present. Something must have errored '
                                   'earlier. See cloud.log' % key_file)
    key_file = str(WindowsPath(key_file)) if plat == 'Windows' else key_file

    ssh_shell = ' '.join([_ssh_path(), '-q',
                          '-o UserKnownHostsFile=/dev/null',
                          '-o StrictHostKeyChecking=no',
                          '-o LogLevel=QUIET',
                          '-i %s' % key_file])
    rsync_cmd = [_rsync_path(), '-avz']
    if plat == 'Windows':
        rsync_cmd.append('--chmod=u+rwx')
    if delete:
        rsync_cmd.append('--delete')
    rsync_cmd.extend(['-e "%s"' % ssh_shell, src_arg, dest_arg])
    rsync_cmd_str = ' '.join(rsync_cmd)
    cloudLog.debug('Performing rsync command: %s', rsync_cmd_str)
    print_stdout('Performing rsync...')
    return exec_command(rsync_cmd_str, pipe_output)
def get_key_path():
    """Return the key file path for sshing into setup server."""
    api_key = cloud.connection_info().get('api_key')
    return credentials.get_sshkey_path(api_key)
import cloud

info = cloud.connection_info()
print info