summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-29 12:07:20 +0000
committerGerrit Code Review <review@openstack.org>2013-01-29 12:07:20 +0000
commitcc1fee34599549abc497fda662ca5cd858432698 (patch)
treef1c143a1827c3519f5097a5a1634bc9294a76c9b
parentce09c50c9253131396f713edbf11ca427341be0e (diff)
parent9983d07d056f064da96fe46790573be7ff90677f (diff)
downloadnova-cc1fee34599549abc497fda662ca5cd858432698.tar.gz
nova-cc1fee34599549abc497fda662ca5cd858432698.tar.xz
nova-cc1fee34599549abc497fda662ca5cd858432698.zip
Merge "Stop including full service catalog in each RPC msg"
-rw-r--r--nova/context.py6
-rw-r--r--nova/tests/test_context.py19
-rw-r--r--nova/volume/cinder.py4
3 files changed, 26 insertions, 3 deletions
diff --git a/nova/context.py b/nova/context.py
index 1a566cb5a..8731e012d 100644
--- a/nova/context.py
+++ b/nova/context.py
@@ -46,7 +46,7 @@ class RequestContext(object):
roles=None, remote_address=None, timestamp=None,
request_id=None, auth_token=None, overwrite=True,
quota_class=None, user_name=None, project_name=None,
- service_catalog=None, instance_lock_checked=False, **kwargs):
+ service_catalog=[], instance_lock_checked=False, **kwargs):
"""
:param read_deleted: 'no' indicates deleted records are hidden, 'yes'
indicates deleted records are visible, 'only' indicates that
@@ -79,7 +79,9 @@ class RequestContext(object):
request_id = generate_request_id()
self.request_id = request_id
self.auth_token = auth_token
- self.service_catalog = service_catalog
+ # Only include required parts of service_catalog
+ self.service_catalog = [s for s in service_catalog
+ if s.get('type') in ('volume')]
self.instance_lock_checked = instance_lock_checked
# NOTE(markmc): this attribute is currently only used by the
diff --git a/nova/tests/test_context.py b/nova/tests/test_context.py
index 0915bf157..527534fd5 100644
--- a/nova/tests/test_context.py
+++ b/nova/tests/test_context.py
@@ -74,3 +74,22 @@ class ContextTestCase(test.TestCase):
self.assertTrue(c)
self.assertIn("'extra_arg1': 'meow'", info['log_msg'])
self.assertIn("'extra_arg2': 'wuff'", info['log_msg'])
+
+ def test_service_catalog_default(self):
+ ctxt = context.RequestContext('111', '222')
+ self.assertEquals(ctxt.service_catalog, [])
+
+ def test_service_catalog_cinder_only(self):
+ service_catalog = [
+ {u'type': u'compute', u'name': u'nova'},
+ {u'type': u's3', u'name': u's3'},
+ {u'type': u'image', u'name': u'glance'},
+ {u'type': u'volume', u'name': u'cinder'},
+ {u'type': u'ec2', u'name': u'ec2'},
+ {u'type': u'object-store', u'name': u'swift'},
+ {u'type': u'identity', u'name': u'keystone'}]
+
+ volume_catalog = [{u'type': u'volume', u'name': u'cinder'}]
+ ctxt = context.RequestContext('111', '222',
+ service_catalog=service_catalog)
+ self.assertEquals(ctxt.service_catalog, volume_catalog)
diff --git a/nova/volume/cinder.py b/nova/volume/cinder.py
index daca69854..05918f83d 100644
--- a/nova/volume/cinder.py
+++ b/nova/volume/cinder.py
@@ -63,8 +63,10 @@ def cinderclient(context):
# FIXME: the cinderclient ServiceCatalog object is mis-named.
# It actually contains the entire access blob.
+ # Only needed parts of the service catalog are passed in, see
+ # nova/context.py.
compat_catalog = {
- 'access': {'serviceCatalog': context.service_catalog or {}}
+ 'access': {'serviceCatalog': context.service_catalog or []}
}
sc = service_catalog.ServiceCatalog(compat_catalog)
if CONF.cinder_endpoint_template: