'Create cloned volume.'

@proxy._trace_time
def create_cloned_volume(self, volume, src_vref):

    specs = self._get_extra_specs(volume.get('volume_type_id', None))
    replication_info = self._get_replication_info(specs)
    src_vref_size = float(src_vref['size'])
    volume_size = float(volume['size'])
    if (volume_size < src_vref_size):
        error = (_('New    volume    size    (%(vol_size)s    GB)    cannot    be    lessthan    the    source    volume    size    (%(src_size)s    GB)..') % {'vol_size': volume_size, 'src_size': src_vref_size})
        LOG.error(error)
        raise self._get_exception()(error)
    self._create_volume(volume)
    try:
        self._call_xiv_xcli('vol_copy', vol_src=src_vref['name'], vol_trg=volume['name'])
    except errors.XCLIError as e:
        error = (_("Failed    to    copy    from    '%(src)s'    to    '%(vol)s':    %(details)s") % {'src': src_vref.get('name', ''), 'vol': volume.get('name', ''), 'details': self._get_code_and_status_or_message(e)})
        LOG.error(error)
        self._silent_delete_volume(volume=volume)
        raise self._get_exception()(error)
    if (src_vref_size != volume_size):
        size = storage.gigabytes_to_blocks(volume_size)
        try:
            self._call_xiv_xcli('vol_resize', vol=volume['name'], size_blocks=size)
        except errors.XCLIError as e:
            error = (_('Fatal    error    in    vol_resize:    %(details)s') % {'details': self._get_code_and_status_or_message(e)})
            LOG.error(error)
            self._silent_delete_volume(volume=volume)
            raise self._get_exception()(error)
    self.handle_created_vol_properties(replication_info, volume)
