Skip to content

Commit

Permalink
Merge pull request #3 from stackhpc/glance_rbd_slow
Browse files Browse the repository at this point in the history
Add interface to get store weight from memory
  • Loading branch information
priteau authored Feb 11, 2025
2 parents 594e40c + 8a25e10 commit f7e8886
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions glance_store/multi_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,34 @@ def verify_store():
raise RuntimeError(msg)


def get_store_weight(store_identifier):
"""Determine backing store weightage from identifier.
Given a store identifier, return the appropriate weight of store
from memory.
"""
enabled_backends = CONF.enabled_backends
enabled_backends.update(_RESERVED_STORES)

try:
scheme = enabled_backends[store_identifier]
except KeyError:
msg = _("Store for identifier %s not found") % store_identifier
raise exceptions.UnknownScheme(msg)

try:
backend_map = location.SCHEME_TO_CLS_BACKEND_MAP[scheme]
scheme_info = backend_map[store_identifier]
except KeyError:
raise exceptions.UnknownScheme(scheme=scheme)

store = scheme_info['store']
if store:
return store.weight

return 0


def get_store_from_store_identifier(store_identifier):
"""Determine backing store from identifier.
Expand Down

0 comments on commit f7e8886

Please sign in to comment.