'Deletes a consistency group.'

def _delete_consistencygroup(self, context, group, volumes):

    cgname = self._cg_name_from_group(group)
    LOG.info('Deleting    consistency    group    %(name)s.', {'name': cgname})
    model_update = {}
    model_update['status'] = group.get('status', fields.GroupStatus.DELETING)
    volumes_model_update = []
    for volume in volumes:
        try:
            self._call_xiv_xcli('cg_remove_vol', vol=volume['name'])
        except errors.XCLIError as e:
            LOG.error('Failed    removing    volume    %(vol)s    from    consistency    group    %(cg)s:    %(err)s', {'vol': volume['name'], 'cg': cgname, 'err': self._get_code_and_status_or_message(e)})
        try:
            self._delete_volume(volume['name'])
            volumes_model_update.append({'id': volume['id'], 'status': 'deleted'})
        except errors.XCLIError as e:
            LOG.error(DELETE_VOLUME_BASE_ERROR, {'volume': volume['name'], 'error': self._get_code_and_status_or_message(e)})
            model_update['status'] = fields.GroupStatus.ERROR_DELETING
            volumes_model_update.append({'id': volume['id'], 'status': 'error_deleting'})
    if (model_update['status'] != fields.GroupStatus.ERROR_DELETING):
        try:
            self._call_xiv_xcli('cg_delete', cg=cgname).as_list
            model_update['status'] = fields.GroupStatus.DELETED
        except (errors.CgDoesNotExistError, errors.CgBadNameError):
            LOG.warning('consistency    group    %(cgname)s    does    not    exist    on    backend', {'cgname': cgname})
            model_update['status'] = fields.GroupStatus.DELETED
        except errors.CgHasMirrorError:
            error = (_('consistency    group    %s    is    being    mirrored') % cgname)
            LOG.error(error)
            raise self._get_exception()(error)
        except errors.CgNotEmptyError:
            error = (_('consistency    group    %s    is    not    empty') % cgname)
            LOG.error(error)
            raise self._get_exception()(error)
        except errors.XCLIError as e:
            error = (_('Fatal:    %(code)s.    CG:    %(cgname)s') % {'code': self._get_code_and_status_or_message(e), 'cgname': cgname})
            LOG.error(error)
            raise self._get_exception()(error)
    return (model_update, volumes_model_update)
