Add support of defining default store for particular artifact type
Change-Id: I142aaa888a7fab7897b6ef73f075b0863ab8ba59
This commit is contained in:
parent
8e9c5a37f3
commit
a6a1b4bb8e
|
@ -16,6 +16,7 @@
|
|||
import copy
|
||||
|
||||
import jsonpatch
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import excutils
|
||||
|
||||
|
@ -30,6 +31,7 @@ from glare.notification import Notifier
|
|||
from glare.objects.meta import fields as glare_fields
|
||||
from glare.objects.meta import registry as glare_registry
|
||||
|
||||
CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -332,8 +334,16 @@ class Engine(object):
|
|||
|
||||
# try to perform blob uploading to storage backend
|
||||
try:
|
||||
default_store = af.get_default_store(
|
||||
context, af, field_name, blob_key)
|
||||
if default_store not in set(CONF.glance_store.stores):
|
||||
LOG.warn("Incorrect backend configuration - scheme '%s' is not"
|
||||
" supported. Fallback to default store."
|
||||
% default_store)
|
||||
default_store = None
|
||||
location_uri, size, checksums = store_api.save_blob_to_store(
|
||||
blob_id, fd, context, af.get_max_blob_size(field_name))
|
||||
blob_id, fd, context, af.get_max_blob_size(field_name),
|
||||
default_store)
|
||||
except Exception:
|
||||
# if upload failed remove blob from db and storage
|
||||
with excutils.save_and_reraise_exception(logger=LOG):
|
||||
|
|
|
@ -843,6 +843,10 @@ class BaseArtifact(base.VersionedObject):
|
|||
def validate_publish(cls, context, af):
|
||||
pass
|
||||
|
||||
@classmethod
|
||||
def get_default_store(cls, context, af, field_name, blob_key):
|
||||
pass
|
||||
|
||||
def to_notification(self):
|
||||
"""Return notification body that can be send to listeners
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@ class ArtifactRegistry(vo_base.VersionedObjectRegistry):
|
|||
class_attributes = set(vars(type_class).keys())
|
||||
common_attrs = class_attributes & base_attributes
|
||||
allowed_attributes = ('VERSION', 'fields', 'init_db_api',
|
||||
'get_default_store',
|
||||
'get_type_name', 'validate_activate',
|
||||
'validate_publish', 'validate_upload',
|
||||
'__doc__', '__module__')
|
||||
|
|
Loading…
Reference in New Issue