]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
objects.qos.policy: support per type rule lists as synthetic fields
authorIhar Hrachyshka <ihrachys@redhat.com>
Fri, 10 Jul 2015 16:00:34 +0000 (18:00 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Thu, 16 Jul 2015 13:51:47 +0000 (15:51 +0200)
commit0a33e355bcfb0a44ad3617f659ab452a04abdbdb
tree393dc80fc6b91c553cf6c776b4d3a5b51e201657
parenta28769ff7e4824568cf1817f5ab0d3807b41d131
objects.qos.policy: support per type rule lists as synthetic fields

This is a significant piece of work.

It enables neutron objects to define fields that are lazily loaded on
field access. To achieve that,

- field should be mentioned in cls.synthetic_fields
- obj_load_attr should be extended to lazily fetch and cache the field

Based on this work, we define per type rule fields that are lists of
appropriate neutron objects. (At the moment, we have only single type
supported, but I tried hard to make it easily extendable, with little or
no coding needed when a new rule type object definition is added to
rule.py: for example, we inspect object definitions based on
VALID_RULE_TYPES, and define appropriate fields for the policy object).

To implement lazy loading for those fields, I redefined get_by_id for
rules that now meld fields from both base and subtype db models into the
corresponding neutron object.

Added a simple test that checks bandwidth_rules attribute behaves for
policies.

Some objects unit test framework rework was needed to accomodate
synthetic fields that are not propagated to db layer.

Change-Id: Ia16393453b1ed48651fbd778bbe0ac6427560117
neutron/common/exceptions.py
neutron/common/utils.py
neutron/db/api.py
neutron/objects/base.py
neutron/objects/qos/policy.py
neutron/objects/qos/rule.py
neutron/tests/unit/common/test_utils.py
neutron/tests/unit/objects/qos/test_policy.py
neutron/tests/unit/objects/qos/test_rule.py
neutron/tests/unit/objects/test_base.py