'Create a volume from a snapshot.
We use LUNcopy to copy a new volume from snapshot.
The time needed increases as volume size does.'

def create_volume_from_snapshot(self, volume, snapshot):

    volume_type = self._get_volume_type(volume)
    opts = self._get_volume_params(volume_type)
    if ((opts.get('hypermetro') == 'true') and (opts.get('replication_enabled') == 'true')):
        msg = _('Hypermetro    and    Replication    can    not    be    used    in    the    same    volume_type.')
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    snapshot_id = huawei_utils.get_snapshot_id(self.client, snapshot)
    if (snapshot_id is None):
        msg = (_('create_volume_from_snapshot:    Snapshot    %(name)s    does    not    exist.') % {'name': snapshot.id})
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    (lun_params, lun_info, model_update) = self._create_base_type_volume(opts, volume, volume_type)
    tgt_lun_id = lun_info['ID']
    luncopy_name = huawei_utils.encode_name(volume.id)
    LOG.info('create_volume_from_snapshot:    src_lun_id:    %(src_lun_id)s,    tgt_lun_id:    %(tgt_lun_id)s,    copy_name:    %(copy_name)s.', {'src_lun_id': snapshot_id, 'tgt_lun_id': tgt_lun_id, 'copy_name': luncopy_name})
    wait_interval = self.configuration.lun_ready_wait_interval
    def _volume_ready():
        result = self.client.get_lun_info(tgt_lun_id)
        if ((result['HEALTHSTATUS'] == constants.STATUS_HEALTH) and (result['RUNNINGSTATUS'] == constants.STATUS_VOLUME_READY)):
            return True
        return False
    huawei_utils.wait_for_condition(_volume_ready, wait_interval, (wait_interval * 10))
    self._copy_volume(volume, luncopy_name, snapshot_id, tgt_lun_id)
    model_update = self._add_extend_type_to_volume(opts, lun_params, lun_info, model_update)
    model_update['provider_location'] = huawei_utils.to_string(**model_update.pop('metadata'))
    return model_update
