'Count the number of instances in a group belonging to a user.'

@base.remotable
def count_members_by_user(self, user_id):

    filter_uuids = self.members
    filters = {'uuid': filter_uuids, 'user_id': user_id, 'deleted': False}
    instances = objects.InstanceList.get_by_filters(self._context, filters=filters)
    return len(instances)
