Add per-store weight config element
Related to blueprint store-weight Change-Id: Ia7d5ca93500aa84a00cd571a67d9838152ecfadd
This commit is contained in:
parent
9bd9cf4fcd
commit
b0b3edf703
@ -39,7 +39,15 @@ This option will be used to provide a constructive information about
|
||||
the store backend to end users. Using /v2/stores-info call user can
|
||||
seek more information on all available backends.
|
||||
|
||||
"""))
|
||||
""")),
|
||||
cfg.IntOpt('weight',
|
||||
help=_("""
|
||||
This option is used to define a relative weight for this store over
|
||||
any others that are configured. The actual value of the weight is meaningless
|
||||
and only serves to provide a "sort order" compared to others. Any stores
|
||||
with the same weight will be treated as equivalent.
|
||||
"""),
|
||||
default=0),
|
||||
]
|
||||
|
||||
|
||||
@ -79,6 +87,15 @@ class Store(capabilities.StoreCapability):
|
||||
def url_prefix(self):
|
||||
return self._url_prefix
|
||||
|
||||
@property
|
||||
def weight(self):
|
||||
if self.backend_group is None:
|
||||
# NOTE(danms): A backend with no config group can not have a
|
||||
# weight set, so just return the default
|
||||
return 0
|
||||
else:
|
||||
return getattr(self.conf, self.backend_group).weight
|
||||
|
||||
def configure(self, re_raise_bsc=False):
|
||||
"""
|
||||
Configure the store to use the stored configuration options
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
A `weight` option has been added to the store configuration definition.
|
||||
This allows configuring stores with *relative* weights to each other for
|
||||
sorting when an image exists in multiple stores.
|
Loading…
Reference in New Issue
Block a user