summaryrefslogtreecommitdiff
path: root/glance
diff options
context:
space:
mode:
Diffstat (limited to 'glance')
-rw-r--r--glance/location.py4
-rw-r--r--glance/tests/unit/v2/test_images_resource.py25
2 files changed, 21 insertions, 8 deletions
diff --git a/glance/location.py b/glance/location.py
index 24f112a89..3c6df1296 100644
--- a/glance/location.py
+++ b/glance/location.py
@@ -53,7 +53,7 @@ class ImageRepoProxy(glance.domain.proxy.Repo):
self.db_api = glance.db.get_api()
def _set_acls(self, image):
- public = image.visibility == 'public'
+ public = image.visibility in ['public', 'community']
member_ids = []
if image.locations and not public:
member_repo = _get_member_repo_for_store(image,
@@ -633,7 +633,7 @@ class ImageMemberRepoProxy(glance.domain.proxy.Repo):
super(ImageMemberRepoProxy, self).__init__(repo)
def _set_acls(self):
- public = self.image.visibility == 'public'
+ public = self.image.visibility in ['public', 'community']
if self.image.locations and not public:
member_ids = [m.member_id for m in self.repo.list()]
for location in self.image.locations:
diff --git a/glance/tests/unit/v2/test_images_resource.py b/glance/tests/unit/v2/test_images_resource.py
index 43b82543f..77ce0135a 100644
--- a/glance/tests/unit/v2/test_images_resource.py
+++ b/glance/tests/unit/v2/test_images_resource.py
@@ -2368,12 +2368,13 @@ class TestImagesController(base.IsolatedUnitTest):
@mock.patch.object(glance.location.ImageRepoProxy, '_set_acls')
@mock.patch.object(store, 'get_size_from_uri_and_backend')
@mock.patch.object(store, 'get_size_from_backend')
- def test_add_location_on_queued(self,
- mock_get_size,
- mock_get_size_uri,
- mock_set_acls,
- mock_check_loc,
- mock_calc):
+ def _test_add_location_on_queued(self,
+ visibility,
+ mock_get_size,
+ mock_get_size_uri,
+ mock_set_acls,
+ mock_check_loc,
+ mock_calc):
mock_calc.return_value = 1
mock_get_size.return_value = 1
mock_get_size_uri.return_value = 1
@@ -2384,6 +2385,7 @@ class TestImagesController(base.IsolatedUnitTest):
name='1',
disk_format='raw',
container_format='bare',
+ visibility=visibility,
status='queued'),
]
self.db.image_create(None, self.images[0])
@@ -2397,6 +2399,17 @@ class TestImagesController(base.IsolatedUnitTest):
self.assertEqual(1, len(output.locations))
self.assertEqual(new_location, output.locations[0])
self.assertEqual('active', output.status)
+ self.assertEqual(visibility, output.visibility)
+ mock_set_acls.assert_called_once()
+
+ def test_add_location_on_queued_shared(self):
+ self._test_add_location_on_queued('shared')
+
+ def test_add_location_on_queued_community(self):
+ self._test_add_location_on_queued('community')
+
+ def test_add_location_on_queued_public(self):
+ self._test_add_location_on_queued('public')
@mock.patch.object(glance.quota, '_calc_required_size')
@mock.patch.object(glance.location, '_check_image_location')