Change location metadata key 'backend' to 'store'

As a part of vocabulary correction, changed the location
metadata key name from 'backend' to 'store'. Modified
corresponding tests as well.

bp:multi-store-vocabulary-correction
Change-Id: Iae3503cba6be362b372e1fc3e75c2ddb1e99b763
This commit is contained in:
Abhishek Kekane
2019-05-14 05:29:26 +00:00
parent 4915fb8793
commit 0e55ad71a8
9 changed files with 18 additions and 15 deletions

View File

@@ -1045,7 +1045,7 @@ class ResponseSerializer(wsgi.JSONResponseSerializer):
if locations: if locations:
stores = [] stores = []
for loc in locations: for loc in locations:
backend = loc['metadata'].get('backend') backend = loc['metadata'].get('store')
if backend: if backend:
stores.append(backend) stores.append(backend)
@@ -1238,10 +1238,13 @@ def get_base_properties():
'readOnly': True, 'readOnly': True,
'description': _('An image file url'), 'description': _('An image file url'),
}, },
'backend': { 'stores': {
'type': 'string', 'type': 'string',
'readOnly': True, 'readOnly': True,
'description': _('Backend store to upload image to'), 'description': _('Store in which image data resides. Only '
'present when the operator has enabled multiple '
'stores. May be a comma-separated list of store '
'identifiers.'),
}, },
'schema': { 'schema': {
'type': 'string', 'type': 'string',

View File

@@ -47,7 +47,7 @@ def safe_delete_from_backend(context, image_id, location):
try: try:
if CONF.enabled_backends: if CONF.enabled_backends:
backend = location['metadata'].get('backend') backend = location['metadata'].get('store')
ret = store_api.delete(location['url'], ret = store_api.delete(location['url'],
backend, backend,
context=context) context=context)

View File

@@ -67,7 +67,7 @@ class ImageRepoProxy(glance.domain.proxy.Repo):
for location in image.locations: for location in image.locations:
if CONF.enabled_backends: if CONF.enabled_backends:
self.store_api.set_acls_for_multi_store( self.store_api.set_acls_for_multi_store(
location['url'], location['metadata'].get('backend'), location['url'], location['metadata'].get('store'),
public=public, read_tenants=member_ids, public=public, read_tenants=member_ids,
context=self.context context=self.context
) )
@@ -127,7 +127,7 @@ def _check_location_uri(context, store_api, store_utils, uri,
def _check_image_location(context, store_api, store_utils, location): def _check_image_location(context, store_api, store_utils, location):
backend = None backend = None
if CONF.enabled_backends: if CONF.enabled_backends:
backend = location['metadata'].get('backend') backend = location['metadata'].get('store')
_check_location_uri(context, store_api, store_utils, location['url'], _check_location_uri(context, store_api, store_utils, location['url'],
backend=backend) backend=backend)
@@ -139,7 +139,7 @@ def _set_image_size(context, image, locations):
for location in locations: for location in locations:
if CONF.enabled_backends: if CONF.enabled_backends:
size_from_backend = store.get_size_from_uri_and_backend( size_from_backend = store.get_size_from_uri_and_backend(
location['url'], location['metadata'].get('backend'), location['url'], location['metadata'].get('store'),
context=context) context=context)
else: else:
size_from_backend = store.get_size_from_backend( size_from_backend = store.get_size_from_backend(
@@ -496,7 +496,7 @@ class ImageProxy(glance.domain.proxy.Image):
self.image.image_id) self.image.image_id)
except crypto_exception.InvalidSignature: except crypto_exception.InvalidSignature:
if CONF.enabled_backends: if CONF.enabled_backends:
self.store_api.delete(location, loc_meta.get('backend'), self.store_api.delete(location, loc_meta.get('store'),
context=self.context) context=self.context)
else: else:
self.store_api.delete_from_backend(location, self.store_api.delete_from_backend(location,
@@ -524,7 +524,7 @@ class ImageProxy(glance.domain.proxy.Image):
err = None err = None
for loc in self.image.locations: for loc in self.image.locations:
try: try:
backend = loc['metadata'].get('backend') backend = loc['metadata'].get('store')
if CONF.enabled_backends: if CONF.enabled_backends:
data, size = self.store_api.get( data, size = self.store_api.get(
loc['url'], backend, offset=offset, loc['url'], backend, offset=offset,

View File

@@ -59,7 +59,7 @@ def _calc_required_size(context, image, locations):
try: try:
if CONF.enabled_backends: if CONF.enabled_backends:
size_from_backend = store.get_size_from_uri_and_backend( size_from_backend = store.get_size_from_uri_and_backend(
location['url'], location['metadata'].get('backend'), location['url'], location['metadata'].get('store'),
context=context) context=context)
else: else:
size_from_backend = store.get_size_from_backend( size_from_backend = store.get_size_from_backend(

View File

@@ -255,7 +255,7 @@ class ScrubDBQueue(object):
# if multi-store is enabled then we need to pass backend # if multi-store is enabled then we need to pass backend
# to delete the image. # to delete the image.
backend = loc['metadata'].get('backend') backend = loc['metadata'].get('store')
if CONF.enabled_backends: if CONF.enabled_backends:
ret.append((image['id'], loc['id'], uri, backend)) ret.append((image['id'], loc['id'], uri, backend))
else: else:

View File

@@ -58,7 +58,7 @@ class TestSchemas(functional.FunctionalTest):
'min_disk', 'min_disk',
'protected', 'protected',
'os_hidden', 'os_hidden',
'backend' 'stores'
]) ])
self.assertEqual(expected, set(image_schema['properties'].keys())) self.assertEqual(expected, set(image_schema['properties'].keys()))

View File

@@ -34,7 +34,7 @@ class TestSchemasController(test_utils.BaseTestCase):
'file', 'container_format', 'schema', 'id', 'size', 'file', 'container_format', 'schema', 'id', 'size',
'direct_url', 'min_ram', 'min_disk', 'protected', 'direct_url', 'min_ram', 'min_disk', 'protected',
'locations', 'owner', 'virtual_size', 'os_hidden', 'locations', 'owner', 'virtual_size', 'os_hidden',
'os_hash_algo', 'os_hash_value', 'backend']) 'os_hash_algo', 'os_hash_value', 'stores'])
self.assertEqual(expected, set(output['properties'].keys())) self.assertEqual(expected, set(output['properties'].keys()))
def test_image_has_correct_statuses(self): def test_image_has_correct_statuses(self):

View File

@@ -34,7 +34,7 @@ future==0.16.0
futurist==1.2.0 futurist==1.2.0
gitdb2==2.0.3 gitdb2==2.0.3
GitPython==2.1.8 GitPython==2.1.8
glance-store==0.26.1 glance-store==1.0.0
greenlet==0.4.13 greenlet==0.4.13
hacking==0.12.0 hacking==0.12.0
httplib2==0.9.1 httplib2==0.9.1

View File

@@ -47,7 +47,7 @@ retrying!=1.3.0,>=1.2.3 # Apache-2.0
osprofiler>=1.4.0 # Apache-2.0 osprofiler>=1.4.0 # Apache-2.0
# Glance Store # Glance Store
glance-store!=0.29.0,>=0.26.1 # Apache-2.0 glance-store>=1.0.0 # Apache-2.0
debtcollector>=1.2.0 # Apache-2.0 debtcollector>=1.2.0 # Apache-2.0