'Create a volume from a snapshot.'

def create_volume_from_snapshot(self, volume, snapshot):

    name = (self.configuration.disco_volume_name_prefix, volume['id'])
    snap_id = snapshot['provider_location']
    vol_name = ''.join(name)
    LOG.debug('[start]    Create    volume    from    snapshot    :    %(snap_id)s    -    name    :    %(vol_name)s.', {'snap_id': snap_id, 'vol_name': vol_name})
    reply = self.client.restoreFromSnapshot(snap_id, vol_name, (-1), None, (-1))
    status = reply['status']
    result = reply['result']
    LOG.debug('Restore        volume    from    snapshot    [status]    %(stat)s    -    [result]    %(res)s.', {'stat': six.text_type(status), 'res': result})
    if status:
        msg = (_('Error[%(stat)s    -    %(res)s]    while    restoring    snapshot    [%(snap_id)s]    into    volume    [%(vol)s].') % {'stat': six.text_type(status), 'res': result, 'snap_id': snap_id, 'vol': vol_name})
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    params = {'restore_id': int(result)}
    start_time = int(time.time())
    restore_request = DISCOCheck(self.client, params, start_time, 'restore_detail', self.configuration)
    timeout = self.configuration.disco_restore_check_timeout
    restore_request._monitor_request(timeout)
    reply = self.client.volumeDetailByName(vol_name)
    status = reply['status']
    new_vol_id = reply['volumeInfoResult']['volumeId']
    if status:
        msg = (_('Error[status]    %(stat)s    -    [result]    %(res)s]    while    getting    volume    id.') % {'stat': six.text_type(status), 'res': result})
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    LOG.debug('Restore    done    [status]    %(stat)s    -    [volume    id]    %(vol_id)s.', {'stat': status, 'vol_id': six.text_type(new_vol_id)})
    return {'provider_location': new_vol_id}
