'Creates a consistency group from source.
Source can be a cgsnapshot with the relevant list of snapshots,
or another CG with its list of volumes.'

def _create_consistencygroup_from_src(self, context, group, volumes, cgsnapshot, snapshots, source_cg, sorted_source_vols):

    cgname = self._cg_name_from_group(group)
    LOG.info('Creating    consistency    group    %(cg)s    from    src.', {'cg': cgname})
    volumes_model_update = []
    if (cgsnapshot and snapshots):
        LOG.debug('Creating    from    cgsnapshot    %(cg)s', {'cg': self._cg_name_from_group(cgsnapshot)})
        try:
            self._create_consistencygroup(context, cgname)
        except Exception as e:
            LOG.error('Creating    CG    from    cgsnapshot    failed:    %(details)s', {'details': self._get_code_and_status_or_message(e)})
            raise
        created_volumes = []
        try:
            groupname = self._group_name_from_cgsnapshot_id(cgsnapshot['id'])
            for (volume, source) in zip(volumes, snapshots):
                vol_name = source.volume_name
                LOG.debug('Original    volume:    %(vol_name)s', {'vol_name': vol_name})
                snapshot_name = self._volume_name_from_cg_snapshot(groupname, vol_name)
                LOG.debug('create    volume    (vol)s    from    snapshot    %(snap)s', {'vol': vol_name, 'snap': snapshot_name})
                snapshot_size = float(source['volume_size'])
                self._create_volume_from_snapshot(volume, snapshot_name, snapshot_size)
                created_volumes.append(volume)
                volumes_model_update.append({'id': volume['id'], 'status': 'available', 'size': snapshot_size})
        except Exception as e:
            details = self._get_code_and_status_or_message(e)
            msg = (CREATE_VOLUME_BASE_ERROR % {'details': details})
            LOG.error(msg)
            self._silent_cleanup_consistencygroup_from_src(context, group, created_volumes, cgname)
            raise self.meta['exception'].VolumeBackendAPIException(data=msg)
    elif (source_cg and sorted_source_vols):
        LOG.debug('Creating    from    CG    %(cg)s    .', {'cg': self._cg_name_from_group(source_cg)})
        LOG.debug('Creating    from    CG    %(cg)s    .', {'cg': source_cg['id']})
        try:
            self._create_consistencygroup(context, group)
        except Exception as e:
            LOG.error('Creating    CG    from    CG    failed:    %(details)s', {'details': self._get_code_and_status_or_message(e)})
            raise
        created_volumes = []
        try:
            for (volume, source) in zip(volumes, sorted_source_vols):
                self.create_cloned_volume(volume, source)
                created_volumes.append(volume)
                volumes_model_update.append({'id': volume['id'], 'status': 'available', 'size': source['size']})
        except Exception as e:
            details = self._get_code_and_status_or_message(e)
            msg = (CREATE_VOLUME_BASE_ERROR, {'details': details})
            LOG.error(msg)
            self._silent_cleanup_consistencygroup_from_src(context, group, created_volumes, cgname)
            raise self.meta['exception'].VolumeBackendAPIException(data=msg)
    else:
        error = 'create_consistencygroup_from_src    called    without    a    source'
        raise self._get_exception()(error)
    model_update = {'status': fields.GroupStatus.AVAILABLE}
    return (model_update, volumes_model_update)
