Fix list zones if shared with multiple projects
This patch fixes a bug when listing zones or updating recordsets in
zones that are shared with more than one project.
Closes-Bug: #2025295
(cherry picked from commit 011ebe2e7c
)
Change-Id: I98c341b8f7138681e35d84707062f8d0e807c533
This commit is contained in:
parent
e742851dc9
commit
efeff8e8be
|
@ -223,7 +223,8 @@ class SQLAlchemyStorage(sqlalchemy_base.SQLAlchemy, storage_base.Storage):
|
||||||
literal_column('False')),
|
literal_column('False')),
|
||||||
else_=literal_column('True')).label('shared')
|
else_=literal_column('True')).label('shared')
|
||||||
query = select(
|
query = select(
|
||||||
[tables.zones, shared_case]).outerjoin(tables.shared_zones)
|
[tables.zones,
|
||||||
|
shared_case]).outerjoin(tables.shared_zones).distinct()
|
||||||
|
|
||||||
zones = self._find(
|
zones = self._find(
|
||||||
context, tables.zones, objects.Zone, objects.ZoneList,
|
context, tables.zones, objects.Zone, objects.ZoneList,
|
||||||
|
|
|
@ -706,6 +706,23 @@ class StorageTestCase(object):
|
||||||
results = self.storage.find_zones(two_context)
|
results = self.storage.find_zones(two_context)
|
||||||
self.assertEqual(1, len(results))
|
self.assertEqual(1, len(results))
|
||||||
|
|
||||||
|
def test_find_zones_shared(self):
|
||||||
|
# Create an admin context
|
||||||
|
admin_context = self.get_admin_context()
|
||||||
|
|
||||||
|
# Create a zone in the admin context
|
||||||
|
zone = self.create_zone(context=admin_context)
|
||||||
|
|
||||||
|
# Share the zone with two other projects
|
||||||
|
self.share_zone(
|
||||||
|
zone_id=zone['id'], target_project_id=1, context=admin_context)
|
||||||
|
self.share_zone(
|
||||||
|
zone_id=zone['id'], target_project_id=2, context=admin_context)
|
||||||
|
|
||||||
|
# Ensure that one zone record is returned from find_zones (LP 2025295)
|
||||||
|
results = self.storage.find_zones(admin_context)
|
||||||
|
self.assertEqual(1, len(results))
|
||||||
|
|
||||||
def test_get_zone(self):
|
def test_get_zone(self):
|
||||||
# Create a zone
|
# Create a zone
|
||||||
expected = self.create_zone()
|
expected = self.create_zone()
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixed issues with list zones and recordsets when a zone is shared with more
|
||||||
|
than one project.
|
Loading…
Reference in New Issue