summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-16 02:57:02 +0000
committerGerrit Code Review <review@openstack.org>2017-06-16 02:57:02 +0000
commit71551a058fcc8ce67aefe27fca54258276e34d09 (patch)
treece98dd1623ce4bb0d91dffc8bebe62fa7dffd5c8
parent609d4634737daaf4ae4692f0cbe53b7317b2014d (diff)
parentd051062019f1058a75d6067d81a9f2d658484529 (diff)
Merge "Make QoS policy object compatible with versions 1.2 and higher" into stable/ocata
-rw-r--r--neutron/objects/qos/policy.py2
-rw-r--r--neutron/tests/unit/objects/qos/test_policy.py17
2 files changed, 18 insertions, 1 deletions
diff --git a/neutron/objects/qos/policy.py b/neutron/objects/qos/policy.py
index 804b214..dfb84b8 100644
--- a/neutron/objects/qos/policy.py
+++ b/neutron/objects/qos/policy.py
@@ -228,6 +228,8 @@ class QosPolicy(rbac_db.NeutronRbacObject):
228 names.append(rule_obj_impl.QosBandwidthLimitRule.obj_name()) 228 names.append(rule_obj_impl.QosBandwidthLimitRule.obj_name())
229 if _target_version >= (1, 1): 229 if _target_version >= (1, 1):
230 names.append(rule_obj_impl.QosDscpMarkingRule.obj_name()) 230 names.append(rule_obj_impl.QosDscpMarkingRule.obj_name())
231 if _target_version >= (1, 2):
232 names.append(rule_obj_impl.QosMinimumBandwidthRule.obj_name())
231 if 'rules' in primitive and names: 233 if 'rules' in primitive and names:
232 primitive['rules'] = filter_rules(names, primitive['rules']) 234 primitive['rules'] = filter_rules(names, primitive['rules'])
233 235
diff --git a/neutron/tests/unit/objects/qos/test_policy.py b/neutron/tests/unit/objects/qos/test_policy.py
index b463524..1b8871f 100644
--- a/neutron/tests/unit/objects/qos/test_policy.py
+++ b/neutron/tests/unit/objects/qos/test_policy.py
@@ -397,12 +397,14 @@ class QosPolicyDbObjectTestCase(test_base.BaseDbObjectTestCase,
397 # local version on the class definition 397 # local version on the class definition
398 policy_obj, rule_objs = self._create_test_policy_with_rules( 398 policy_obj, rule_objs = self._create_test_policy_with_rules(
399 [qos_consts.RULE_TYPE_BANDWIDTH_LIMIT, 399 [qos_consts.RULE_TYPE_BANDWIDTH_LIMIT,
400 qos_consts.RULE_TYPE_DSCP_MARKING], reload_rules=True) 400 qos_consts.RULE_TYPE_DSCP_MARKING,
401 qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH], reload_rules=True)
401 402
402 policy_obj_v1_0 = self._policy_through_version(policy_obj, '1.0') 403 policy_obj_v1_0 = self._policy_through_version(policy_obj, '1.0')
403 404
404 self.assertIn(rule_objs[0], policy_obj_v1_0.rules) 405 self.assertIn(rule_objs[0], policy_obj_v1_0.rules)
405 self.assertNotIn(rule_objs[1], policy_obj_v1_0.rules) 406 self.assertNotIn(rule_objs[1], policy_obj_v1_0.rules)
407 self.assertNotIn(rule_objs[2], policy_obj_v1_0.rules)
406 408
407 def test_object_version_degradation_1_2_to_1_1(self): 409 def test_object_version_degradation_1_2_to_1_1(self):
408 #NOTE(mangelajo): we should not check .VERSION, since that's the 410 #NOTE(mangelajo): we should not check .VERSION, since that's the
@@ -418,6 +420,19 @@ class QosPolicyDbObjectTestCase(test_base.BaseDbObjectTestCase,
418 self.assertIn(rule_objs[1], policy_obj_v1_1.rules) 420 self.assertIn(rule_objs[1], policy_obj_v1_1.rules)
419 self.assertNotIn(rule_objs[2], policy_obj_v1_1.rules) 421 self.assertNotIn(rule_objs[2], policy_obj_v1_1.rules)
420 422
423 def test_object_version_degradation_1_3_to_1_2(self):
424 #NOTE(mangelajo): we should not check .VERSION, since that's the
425 # local version on the class definition
426 policy_obj, rule_objs = self._create_test_policy_with_rules(
427 [qos_consts.RULE_TYPE_BANDWIDTH_LIMIT,
428 qos_consts.RULE_TYPE_DSCP_MARKING,
429 qos_consts.RULE_TYPE_MINIMUM_BANDWIDTH], reload_rules=True)
430
431 policy_obj_v1_2 = self._policy_through_version(policy_obj, '1.2')
432
433 for rule_obj in rule_objs:
434 self.assertIn(rule_obj, policy_obj_v1_2.rules)
435
421 def test_v1_4_to_v1_3_drops_project_id(self): 436 def test_v1_4_to_v1_3_drops_project_id(self):
422 policy_new = self._create_test_policy() 437 policy_new = self._create_test_policy()
423 438