summaryrefslogtreecommitdiff
path: root/glance_store/location.py
diff options
context:
space:
mode:
authorZhi Yan Liu <zhiyanl@cn.ibm.com>2014-09-17 20:56:35 +0800
committerZhi Yan Liu <lzy.dev@gmail.com>2014-09-24 11:56:11 +0800
commit22dbccb4913c894c20a5df7cfc56713e4e4cf591 (patch)
tree3af997796fb17cb63e706f51ca52724415f09a4c /glance_store/location.py
parent56af7fd60cd912e81f45e4173e7998a26c9ac14c (diff)
downloadglance_store-22dbccb4913c894c20a5df7cfc56713e4e4cf591.tar.gz
Enhance configuration handling
1. Changed drivers to prevent using global CONF but access it from client by interface. 2. Corrected swift driver to involve options from swift driver utils, allow glance_store exports and registers them for client. 3. Added missing test cases for the functions of swift driver util. Change-Id: I8fac6800efde202e29179791ea05c4814ec58435 Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
Diffstat (limited to 'glance_store/location.py')
-rw-r--r--glance_store/location.py20
1 files changed, 13 insertions, 7 deletions
diff --git a/glance_store/location.py b/glance_store/location.py
index 61ab9b2..a98773d 100644
--- a/glance_store/location.py
+++ b/glance_store/location.py
@@ -40,20 +40,24 @@ credentials and is **not** user-facing.
import logging
import urlparse
+from oslo.config import cfg
+
from glance_store import exceptions
+CONF = cfg.CONF
LOG = logging.getLogger(__name__)
SCHEME_TO_CLS_MAP = {}
-def get_location_from_uri(uri):
+def get_location_from_uri(uri, conf=CONF):
"""
Given a URI, return a Location object that has had an appropriate
store parse the URI.
:param uri: A URI that could come from the end-user in the Location
- attribute/header
+ attribute/header.
+ :param conf: The global configuration.
Example URIs:
https://user:pass@example.com:80/images/some-id
@@ -70,8 +74,8 @@ def get_location_from_uri(uri):
if pieces.scheme not in SCHEME_TO_CLS_MAP.keys():
raise exceptions.UnknownScheme(scheme=pieces.scheme)
scheme_info = SCHEME_TO_CLS_MAP[pieces.scheme]
- return Location(pieces.scheme, uri=uri,
- store_location_class=scheme_info['location_class'])
+ return Location(pieces.scheme, scheme_info['location_class'],
+ conf, uri=uri)
def register_scheme_map(scheme_map):
@@ -93,7 +97,7 @@ class Location(object):
Class describing the location of an image that Glance knows about
"""
- def __init__(self, store_name, store_location_class,
+ def __init__(self, store_name, store_location_class, conf,
uri=None, image_id=None, store_specs=None):
"""
Create a new Location object.
@@ -111,7 +115,8 @@ class Location(object):
self.store_name = store_name
self.image_id = image_id
self.store_specs = store_specs or {}
- self.store_location = store_location_class(self.store_specs)
+ self.conf = conf
+ self.store_location = store_location_class(self.store_specs, conf)
if uri:
self.store_location.parse_uri(uri)
@@ -132,7 +137,8 @@ class StoreLocation(object):
Base class that must be implemented by each store
"""
- def __init__(self, store_specs):
+ def __init__(self, store_specs, conf):
+ self.conf = conf
self.specs = store_specs
if self.specs:
self.process_specs()