Workaround in NetworkSegmentRange OVO until "project_id" migration
The "network_segment_range" service plugin API does not have
"tenant_id" as parameter. However, because the migration from
"tenant_id" to "project_id" did not finish, every OVO with
"project_id" will also have "tenant_id" as an extra field. This
extra field will be populated with the same value as the
"project_id" field.
If the Neutron API WSGI is used and "tenant_id" is not present in
the API (defined in neutron-lib), both "tenant_id" and "project_id"
parameters will be removed from the response.
This patch introduces a workaround for this OVO until the migration
is over.
More information about this patch can be found in the bug c#4.
Change-Id: I85a02d8b59e8a758826c110e00df84672fa93676
Closes-Bug: #1828205
(cherry picked from commit 3053caaa02
)
This commit is contained in:
parent
7b81f801d0
commit
c945e5ccba
|
@ -83,7 +83,11 @@ class NetworkSegmentRange(base.NeutronDbObject):
|
|||
# AttrtibuteError can be raised when accessing self.db_obj
|
||||
# or self.db_obj.standard_attr
|
||||
pass
|
||||
return db_utils.resource_fields(_dict, fields)
|
||||
# NOTE(ralonsoh): this workaround should be removed once the migration
|
||||
# from "tenant_id" to "project_id" is finished.
|
||||
_dict = db_utils.resource_fields(_dict, fields)
|
||||
_dict.pop('tenant_id', None)
|
||||
return _dict
|
||||
|
||||
def _check_shared_project_id(self, action):
|
||||
if self.shared is False and not self.project_id:
|
||||
|
|
|
@ -726,6 +726,7 @@ class BaseObjectIfaceTestCase(_BaseObjectTestCase, test_base.BaseTestCase):
|
|||
self.model_map = collections.defaultdict(list)
|
||||
self.model_map[self._test_class.db_model] = self.db_objs
|
||||
self.pager_map = collections.defaultdict(lambda: None)
|
||||
self.extra_fields_not_in_dict = []
|
||||
|
||||
self.get_objects_mock = mock.patch.object(
|
||||
obj_db_api, 'get_objects',
|
||||
|
@ -1156,8 +1157,11 @@ class BaseObjectIfaceTestCase(_BaseObjectTestCase, test_base.BaseTestCase):
|
|||
for field in self._test_class.obj_extra_fields:
|
||||
# field is accessible and cannot be set by any value
|
||||
getattr(obj, field)
|
||||
self.assertIn(field, obj.to_dict().keys())
|
||||
self.assertRaises(AttributeError, setattr, obj, field, "1")
|
||||
if field in self.extra_fields_not_in_dict:
|
||||
self.assertNotIn(field, obj.to_dict().keys())
|
||||
else:
|
||||
self.assertIn(field, obj.to_dict().keys())
|
||||
self.assertRaises(AttributeError, setattr, obj, field, "1")
|
||||
|
||||
def test_to_dict_makes_primitive_field_value(self):
|
||||
obj = self._test_class(self.context, **self.obj_fields[0])
|
||||
|
|
|
@ -57,13 +57,14 @@ class NetworkSegmentRangeIfaceObjectTestCase(
|
|||
# `shared` and `network_type` respectively.
|
||||
# Hack to always populate test project_id and physical_network
|
||||
# fields in network segment range Iface object testing so that related
|
||||
# tests like `test_extra_fields`, `test_create_updates_from_db_object`,
|
||||
# tests like `test_create_updates_from_db_object` and
|
||||
# `test_update_updates_from_db_object` can have those fields.
|
||||
# Alternatives can be skipping those tests when executing
|
||||
# NetworkSegmentRangeIfaceObjectTestCase, or making base test case
|
||||
# adjustments.
|
||||
self.update_obj_fields({'project_id': TEST_TENANT_ID,
|
||||
'physical_network': TEST_PHYSICAL_NETWORK})
|
||||
self.extra_fields_not_in_dict = ['tenant_id']
|
||||
|
||||
|
||||
class NetworkSegmentRangeDbObjectTestCase(obj_test_base.BaseDbObjectTestCase,
|
||||
|
|
Loading…
Reference in New Issue