Make QoS policy object compatible with versions 1.2 and higher

For version 1.2 or higher of QoS policy object it can contain
QoSMinumumBandwidtLimit rules and appending of such rule type
was missing in make_obj_compatible function.
Now such rules are appended to QoS policy.

Change-Id: I40d699db58c34e83272432376d1d59679a680db2
Closes-Bug: #1681440
This commit is contained in:
Sławek Kapłoński 2017-04-10 14:09:51 +00:00
parent 6d171ae5c0
commit 0376d2f6ad
2 changed files with 18 additions and 1 deletions

View File

@ -228,6 +228,8 @@ class QosPolicy(rbac_db.NeutronRbacObject):
names.append(rule_obj_impl.QosBandwidthLimitRule.obj_name())
if _target_version >= (1, 1):
names.append(rule_obj_impl.QosDscpMarkingRule.obj_name())
if _target_version >= (1, 2):
names.append(rule_obj_impl.QosMinimumBandwidthRule.obj_name())
if 'rules' in primitive and names:
primitive['rules'] = filter_rules(names, primitive['rules'])

View File

@ -397,12 +397,14 @@ class QosPolicyDbObjectTestCase(test_base.BaseDbObjectTestCase,
# local version on the class definition
policy_obj, rule_objs = self._create_test_policy_with_rules(
[qos_consts.RULE_TYPE_BANDWIDTH_LIMIT,
qos_consts.RULE_TYPE_DSCP_MARKING], reload_rules=True)
qos_consts.RULE_TYPE_DSCP_MARKING,
qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH], reload_rules=True)
policy_obj_v1_0 = self._policy_through_version(policy_obj, '1.0')
self.assertIn(rule_objs[0], policy_obj_v1_0.rules)
self.assertNotIn(rule_objs[1], policy_obj_v1_0.rules)
self.assertNotIn(rule_objs[2], policy_obj_v1_0.rules)
def test_object_version_degradation_1_2_to_1_1(self):
#NOTE(mangelajo): we should not check .VERSION, since that's the
@ -418,6 +420,19 @@ class QosPolicyDbObjectTestCase(test_base.BaseDbObjectTestCase,
self.assertIn(rule_objs[1], policy_obj_v1_1.rules)
self.assertNotIn(rule_objs[2], policy_obj_v1_1.rules)
def test_object_version_degradation_1_3_to_1_2(self):
#NOTE(mangelajo): we should not check .VERSION, since that's the
# local version on the class definition
policy_obj, rule_objs = self._create_test_policy_with_rules(
[qos_consts.RULE_TYPE_BANDWIDTH_LIMIT,
qos_consts.RULE_TYPE_DSCP_MARKING,
qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH], reload_rules=True)
policy_obj_v1_2 = self._policy_through_version(policy_obj, '1.2')
for rule_obj in rule_objs:
self.assertIn(rule_obj, policy_obj_v1_2.rules)
def test_v1_4_to_v1_3_drops_project_id(self):
policy_new = self._create_test_policy()