在openstack loadbalancer中,tget_members不能使用过滤器

时间:2013-11-30 05:42:36

标签: python sqlalchemy openstack openstack-nova openstack-horizon

试图让属于池的成员并尝试使用

 def get_members(self, context, filters=None, fields=None):

我将此功能称为

   get_members(context,{'pool_d':'some_id_received_by'}

并期望所有具有池ID的成员为some_id_received_by

get_members看起来像这样

def get_members(self, context, filters=None, fields=None):
        return self._get_collection(context, Member,
                                    self._make_member_dict,
                                    filters=filters, fields=fields)

并且最终通话看起来像这样

def _apply_filters_to_query(self, query, model, filters):
    if filters:
        for key, value in filters.iteritems():
            column = getattr(model, key, None)
            if column:
                query = query.filter(column.in_(value))
        for _name, hooks in self._model_query_hooks.get(model,
                                                        {}).iteritems():
            result_filter = hooks.get('result_filters', None)
            if isinstance(result_filter, basestring):
                result_filter = getattr(self, result_filter, None)

            if result_filter:
                query = result_filter(query, filters)
    return query

和模型看起来像这样:

class Member(model_base.BASEV2, models_v2.HasId, models_v2.HasTenant,
             models_v2.HasStatusDescription):
    """Represents a v2 neutron loadbalancer member."""

    pool_id = sa.Column(sa.String(36), sa.ForeignKey("pools.id"),
                        nullable=False)
    address = sa.Column(sa.String(64), nullable=False)
    protocol_port = sa.Column(sa.Integer, nullable=False)
    weight = sa.Column(sa.Integer, nullable=False)
    admin_state_up = sa.Column(sa.Boolean(), nullable=False)

所以我无法看出什么是错的。

                  ========== Updated ===========

它没有返回任何数据,如果我没有通过任何过滤器,它将正确返回所有数据。

0 个答案:

没有答案