'Updates a consistency group.'

def _update_consistencygroup(self, context, group, add_volumes=None, remove_volumes=None):

    cgname = self._cg_name_from_group(group)
    LOG.info('Updating    consistency    group    %(name)s.', {'name': cgname})
    model_update = {'status': fields.GroupStatus.AVAILABLE}
    add_volumes_update = []
    if add_volumes:
        for volume in add_volumes:
            try:
                self._call_xiv_xcli('cg_add_vol', vol=volume['name'], cg=cgname)
            except errors.XCLIError as e:
                error = (_('Failed    adding    volume    %(vol)s    to    consistency    group    %(cg)s:    %(err)s') % {'vol': volume['name'], 'cg': cgname, 'err': self._get_code_and_status_or_message(e)})
                LOG.error(error)
                self._cleanup_consistencygroup_update(context, group, add_volumes_update, None)
                raise self._get_exception()(error)
            add_volumes_update.append({'name': volume['name']})
    remove_volumes_update = []
    if remove_volumes:
        for volume in remove_volumes:
            try:
                self._call_xiv_xcli('cg_remove_vol', vol=volume['name'])
            except (errors.VolumeNotInConsGroup, errors.VolumeBadNameError) as e:
                details = self._get_code_and_status_or_message(e)
                LOG.debug(details)
            except errors.XCLIError as e:
                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)})
                LOG.error(error)
                self._cleanup_consistencygroup_update(context, group, add_volumes_update, remove_volumes_update)
                raise self._get_exception()(error)
            remove_volumes_update.append({'name': volume['name']})
    return (model_update, None, None)
