Refactor where store drivers are initialized

The call to create_stores was happening in the v1 and v2 API
controllers. This moves that call and the verification that
the default_store exists into the necessary binaries.

Fixes bug 1039727.

Change-Id: I36542fd9b1d536d6266898766317abe110bb71a2
This commit is contained in:
Brian Waldon
2012-11-16 14:27:00 -08:00
parent 6d57df0eda
commit 3bc265281f
12 changed files with 46 additions and 61 deletions

View File

@@ -21,6 +21,7 @@ import time
from glance.common import exception
from glance.common import utils
import glance.context
from glance.openstack.common import cfg
from glance.openstack.common import importutils
import glance.openstack.common.log as logging
@@ -37,6 +38,10 @@ store_opts = [
'glance.store.s3.Store',
'glance.store.swift.Store',
]),
cfg.StrOpt('default_store', default='file',
help=_("Default scheme to use to store image data. The "
"scheme must be registered by one of the stores "
"defined by the 'known_stores' config option.")),
cfg.StrOpt('scrubber_datadir',
default='/var/lib/glance/scrubber'),
cfg.BoolOpt('delayed_delete', default=False),
@@ -168,6 +173,16 @@ def create_stores():
return store_count
def verify_default_store():
scheme = cfg.CONF.default_store
context = glance.context.RequestContext()
try:
get_store_from_scheme(context, scheme)
except exception.UnknownScheme:
msg = _("Store for scheme %s not found") % scheme
raise RuntimeError(msg)
def get_store_from_scheme(context, scheme):
"""
Given a scheme, return the appropriate store object

View File

@@ -92,8 +92,6 @@ class Scrubber(object):
utils.safe_mkdirs(self.datadir)
store.create_stores()
def run(self, pool, event=None):
now = time.time()