'Creates a clone of the specified volume.'

def _create_cloned_volume(self, volume, src_vref):

    LOG.debug('_create_cloned_volume(Volume    ID    =    %(id)s,    Source    ID    =    %(src_id)s    )    Start.', {'id': volume.id, 'src_id': src_vref.id})
    xml = self._cli.view_all(self._properties['ismview_path'])
    (pools, lds, ldsets, used_ldns, hostports, max_ld_count) = self.configs(xml)
    source_name = self.get_ldname(src_vref.id, self._properties['ld_name_format'])
    if (source_name not in lds):
        msg = (_('Logical    Disk    `%(name)s`    has    unbound    already.    volume_id    =    %(id)s.') % {'name': source_name, 'id': src_vref.id})
        LOG.error(msg)
        raise exception.VolumeBackendAPIException(data=msg)
    source_ld = lds[source_name]
    if (source_ld['RPL    Attribute'] == 'MV'):
        pair_lds = self._cli.get_pair_lds(source_name, lds)
        if (len(pair_lds) == 3):
            msg = (_('Cannot    create    clone    volume.    number    of    pairs    reached    3.    %(msg)s.    ldname=%(ldname)s') % {'msg': msg, 'ldname': source_name})
            LOG.error(msg)
            raise exception.VolumeBackendAPIException(data=msg)
    (volume_name, ldn, selected_pool) = self._bind_ld(volume, src_vref.size, None, self._convert_id2name, self._select_leastused_poolnumber)
    specs = self.get_volume_type_qos_specs(volume)
    self.check_io_parameter(specs)
    self._cli.set_io_limit(volume_name, specs)
    LOG.debug('LD    bound.    Name=%(name)s    Size=%(size)dGB    LDN=%(ldn)04xh    Pool=%(pool)04xh.', {'name': volume_name, 'size': volume.size, 'ldn': ldn, 'pool': selected_pool})
    LOG.debug('source_name=%(src_name)s,    volume_name=%(name)s.', {'src_name': source_name, 'name': volume_name})
    mv_capacity = src_vref.size
    rv_capacity = volume.size
    if (rv_capacity <= mv_capacity):
        rv_capacity = None
    volume_properties = {'mvname': source_name, 'rvname': volume_name, 'capacity': mv_capacity, 'mvid': src_vref.id, 'rvid': volume.id, 'rvldn': ldn, 'rvcapacity': rv_capacity, 'flag': 'clone', 'context': self._context}
    self._cli.backup_restore(volume_properties, cli.UnpairWaitForClone)
    LOG.debug('_create_cloned_volume(Volume    ID    =    %(id)s,    Source    ID    =    %(src_id)s    )    End.', {'id': volume.id, 'src_id': src_vref.id})
