'Creates cloned volume.
1. Take an internal snapshot of source volume, and attach it.
2. Thin clone from the snapshot to a new volume.
Note: there are several cases the thin clone will downgrade to `dd`,
2.1 Source volume is attached (in-use).
2.2 Array OE version doesn\'t support thin clone.
2.3 The current LUN family reaches the thin clone limits.
3. Delete the internal snapshot created in step 1.'

def create_cloned_volume(self, volume, src_vref):

    src_lun_id = self.get_lun_id(src_vref)
    if (src_lun_id is None):
        raise exception.VolumeBackendAPIException(data=(_('LUN    ID    of    source    volume:    %s    not    found.') % src_vref.name))
    src_lun = self.client.get_lun(lun_id=src_lun_id)
    src_snap_name = ('snap_clone_%s' % volume.id)
    create_snap_func = functools.partial(self.client.create_snap, src_lun_id, src_snap_name)
    vol_params = VolumeParams(self, volume)
    with utils.assure_cleanup(create_snap_func, self.client.delete_snap, True) as src_snap:
        LOG.debug('Internal    snapshot    for    clone    is    created,    name:    %(name)s,    id:    %(id)s.', {'name': src_snap_name, 'id': src_snap.get_id()})
        if src_vref.volume_attachment:
            lun = self._dd_copy(vol_params, src_snap, src_lun=src_lun)
            LOG.debug('Volume    copied    using    dd    because    source    volume:    %(name)s    is    attached:    %(attach)s.', {'name': src_vref.name, 'attach': src_vref.volume_attachment})
            return self.makeup_model(lun)
        else:
            lun = self._thin_clone(vol_params, src_snap, src_lun=src_lun)
            return self.makeup_model(lun, is_snap_lun=True)
