def receive(uuid, source):
    ret = {}
    vmadm = _check_vmadm()
    zfs = _check_zfs()
    if not os.path.isdir(source):
        ret['Error'] = 'Source must be a directory or host'
        return ret
    if not os.path.exists(os.path.join(source, '{0}.vmdata'.format(uuid))):
        ret['Error'] = 'Unknow vm with uuid in {0}'.format(source)
        return ret
    # vmadm receive
    cmd = '{vmadm} receive < {source}'.format(
        vmadm=vmadm,
        source=os.path.join(source, '{0}.vmdata'.format(uuid))
    )
    res = __salt__['cmd.run_all'](cmd, python_shell=True)
    retcode = res['retcode']
    if retcode != 0 and not res['stderr'].endswith('datasets'):
        ret['Error'] = res['stderr'] if 'stderr' in res else _exit_status(retcode)
        return ret
    vmobj = get(uuid)
    if 'datasets' not in vmobj:
        return True
    log.warning('one or more datasets detected, this is not supported!')
    log.warning('trying to restore datasets, mountpoints will need to be set again...')
    for dataset in vmobj['datasets']:
        name = dataset.split('/')
        name = name[-1]
        cmd = '{zfs} receive {dataset} < {source}'.format(
            zfs=zfs,
            dataset=dataset,
            source=os.path.join(source, '{0}-{1}.zfsds'.format(uuid, name))
        )
        res = __salt__['cmd.run_all'](cmd, python_shell=True)
        retcode = res['retcode']
        if retcode != 0:
            ret['Error'] = res['stderr'] if 'stderr' in res else _exit_status(retcode)
            return ret
    cmd = '{vmadm} install {uuid}'.format(
        vmadm=vmadm,
        uuid=uuid
    )
    res = __salt__['cmd.run_all'](cmd, python_shell=True)
    retcode = res['retcode']
    if retcode != 0 and not res['stderr'].endswith('datasets'):
        ret['Error'] = res['stderr'] if 'stderr' in res else _exit_status(retcode)
        return ret
    return True

# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
sends a response to the peer
dataset/ETHPy150Open saltstack/salt/salt/modules/smartos_vmadm.py/receive--crossover with--dataset/ETHPy150Open anandology/pyjamas/examples/jsonrpc/public/services/jsonrpc/__init__.py/SimpleMessageHandler.sendResponse