{"body":"commit b388044a3a2f37015c0e2ae4525be9ecc49fa51f\nAuthor: Duncan Thomas <duncan.thomas@hp.com>\nDate:   Mon Sep 21 18:50:20 2015 +0300\n\n    Get keystone endpoint from catalog by default\n    \n    Change-Id: Ic816034ffc682f5a86efc420d80951512651570a\n\ndiff --git a/cinder/api/contrib/quotas.py b/cinder/api/contrib/quotas.py\nindex 27f0401..f5dd579 100644\n--- a/cinder/api/contrib/quotas.py\n+++ b/cinder/api/contrib/quotas.py\n@@ -32,7 +32,23 @@ from oslo_config import cfg\n from oslo_utils import strutils\n \n \n+quota_opts = [\n+    cfg.StrOpt('quota_keystone_api_url',\n+               default=None,\n+               help='Authentication url for quota service.'\n+                    ' Set to \"None\" to use catalog.'),\n+    cfg.StrOpt('quota_auth_catalog_info',\n+               default='identity:keystone:publicURL',\n+               help='Info to match when looking for keystone in the service '\n+                    'catalog. Format is: separated values of the form: '\n+                    '<service_type>:<service_name>:<endpint_type> - '\n+                    'Only used if encryption_auth_url is \"None\"'),\n+]\n+\n+\n CONF = cfg.CONF\n+CONF.register_opts(quota_opts, 'quota')\n+\n QUOTAS = quota.QUOTAS\n NON_QUOTA_KEYS = ['tenant_id', 'id']\n \n@@ -179,8 +195,31 @@ class QuotaSetsController(wsgi.Controller):\n         organized. Therefore, we need to know the project hierarchy, if any, in\n         order to do quota operations properly.\n         \"\"\"\n+        if getattr(self, \"_base_auth_url\", None) is None:\n+            self._base_auth_url = CONF.quota.quota_auth_url\n+            if self._base_auth_url is None:\n+                try:\n+                    info = CONF.quota.quota_auth_catalog_info\n+                    service_type, service_name, endpoint_type = info.split(':')\n+                except ValueError:\n+                    raise exception.QuotamgrConfigException(_(\n+                        \"Failed to parse the configuration option \"\n+                        \"'quota_auth_catalog_info', must be in the form \"\n+                        \"<service_type>:<service_name>:<endpoint_type>.\"))\n+                for entry in context.service_catalog:\n+                    if entry.get('type') == service_type:\n+                        self._base_auth_url = entry.get(\n+                            'endpoints')[0].get(endpoint_type)\n+\n+                if self._base_auth_url is None:\n+                    raise exception.QuotamgrConfigException(_(\n+                        \"Could not determine which endpoint to use. This can \"\n+                        \"either be set in the service catalog or with the \"\n+                        \"cinder.conf config option 'quota_auth_url' in the \"\n+                        \"section [quota].\"))\n+\n         try:\n-            keystone = client.Client(auth_url=CONF.keymgr.encryption_auth_url,\n+            keystone = client.Client(auth_url=self._base_auth_url,\n                                      token=context.auth_token,\n                                      project_id=context.project_id)\n             project = keystone.projects.get(id, subtree_as_ids=subtree_as_ids)\n","name":"patch","extension":"txt","url":"https://www.irccloud.com/pastebin/EMh4NjC5/patch","modified":1442850836,"id":"EMh4NjC5","size":3095,"lines":69,"own_paste":false,"theme":"","date":1442850836}