summaryrefslogtreecommitdiffstats
path: root/nova/volume
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-09-13 02:12:11 +0000
committerGerrit Code Review <review@openstack.org>2012-09-13 02:12:11 +0000
commit677f6f6873e3d4521d7382db3d78d9963a0ec27c (patch)
treef2077898f889cfac3bea70582e23f7ea88e34acc /nova/volume
parentb99b8b9c0bbdfb7e905d8e0bc2f43d5080293859 (diff)
parent0fa231f718662f2b83c11ffc39f977fdc8941107 (diff)
downloadnova-677f6f6873e3d4521d7382db3d78d9963a0ec27c.tar.gz
nova-677f6f6873e3d4521d7382db3d78d9963a0ec27c.tar.xz
nova-677f6f6873e3d4521d7382db3d78d9963a0ec27c.zip
Merge "Add flag cinder_endpoint_template to volume.cinder"
Diffstat (limited to 'nova/volume')
-rw-r--r--nova/volume/cinder.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index 87b8036a1..616fdea2f 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -36,6 +36,10 @@ cinder_opts = [
help='Info to match when looking for cinder in the service '
'catalog. Format is : separated values of the form: '
'<service_type>:<service_name>:<endpoint_type>'),
+ cfg.StrOpt('cinder_endpoint_template',
+ default=None,
+ help='Override service catalog lookup with template for cinder '
+ 'endpoint e.g. http://localhost:8776/v1/%(project_id)s'),
]
FLAGS = flags.FLAGS
@@ -49,14 +53,17 @@ def cinderclient(context):
# FIXME: the cinderclient ServiceCatalog object is mis-named.
# It actually contains the entire access blob.
compat_catalog = {
- 'access': {'serviceCatalog': context.service_catalog}
+ 'access': {'serviceCatalog': context.service_catalog or {}}
}
sc = service_catalog.ServiceCatalog(compat_catalog)
- info = FLAGS.cinder_catalog_info
- service_type, service_name, endpoint_type = info.split(':')
- url = sc.url_for(service_type=service_type,
- service_name=service_name,
- endpoint_type=endpoint_type)
+ if FLAGS.cinder_endpoint_template:
+ url = FLAGS.cinder_endpoint_template % context.to_dict()
+ else:
+ info = FLAGS.cinder_catalog_info
+ service_type, service_name, endpoint_type = info.split(':')
+ url = sc.url_for(service_type=service_type,
+ service_name=service_name,
+ endpoint_type=endpoint_type)
LOG.debug(_('Cinderclient connection created using URL: %s') % url)
@@ -64,7 +71,9 @@ def cinderclient(context):
context.auth_token,
project_id=context.project_id,
auth_url=url)
- c.client.auth_token = context.auth_token
+ # noauth extracts user_id:project_id from auth_token
+ c.client.auth_token = context.auth_token or '%s:%s' % (context.user_id,
+ context.project_id)
c.client.management_url = url
return c