summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrabi <ramishra@redhat.com>2017-02-03 17:45:23 +0530
committerrabi <ramishra@redhat.com>2017-02-07 10:29:19 +0530
commit674b36f2356103805fe2120e03d92e925918b747 (patch)
treeb1281859f2637e402ada5d8514361242391675b1
parent32fefb75ffc175053aef0d65bc41ae9f978639b2 (diff)
downloadheat-674b36f2356103805fe2120e03d92e925918b747.tar.gz
Use region_name when creating keystone client
When creating trust and stack domain user/project, we create a keystone client without the region_name. This may not work in a multi-region environment. Change-Id: I90979e9fe889deb1ef322ab0af31b9e079b77747 Closes-Bug: #1661594 (cherry picked from commit a21a29c8479e18e13df4be350743b169c311eb67)
-rw-r--r--heat/common/heat_keystoneclient.py10
-rw-r--r--heat/tests/clients/test_heat_client.py9
2 files changed, 14 insertions, 5 deletions
diff --git a/heat/common/heat_keystoneclient.py b/heat/common/heat_keystoneclient.py
index 97ecf470d..b5ea0bf80 100644
--- a/heat/common/heat_keystoneclient.py
+++ b/heat/common/heat_keystoneclient.py
@@ -112,6 +112,10 @@ class KeystoneClientV3(object):
return self._client
@property
+ def region_name(self):
+ return self.context.region_name or cfg.CONF.region_name_for_services
+
+ @property
def domain_admin_auth(self):
if not self._domain_admin_auth:
# Note we must specify the domain when getting the token
@@ -140,13 +144,15 @@ class KeystoneClientV3(object):
if not self._domain_admin_client:
self._domain_admin_client = kc_v3.Client(
session=self.session,
- auth=self.domain_admin_auth)
+ auth=self.domain_admin_auth,
+ region_name=self.region_name)
return self._domain_admin_client
def _v3_client_init(self):
client = kc_v3.Client(session=self.session,
- auth=self.context.auth_plugin)
+ auth=self.context.auth_plugin,
+ region_name=self.region_name)
if hasattr(self.context.auth_plugin, 'get_access'):
# NOTE(jamielennox): get_access returns the current token without
diff --git a/heat/tests/clients/test_heat_client.py b/heat/tests/clients/test_heat_client.py
index 4e39f6aac..92d974165 100644
--- a/heat/tests/clients/test_heat_client.py
+++ b/heat/tests/clients/test_heat_client.py
@@ -91,7 +91,8 @@ class KeystoneClientTest(common.HeatTestCase):
m.AndReturn(mock_ks_auth)
n = kc_v3.Client(session=mox.IsA(ks_session.Session),
- auth=mock_ks_auth)
+ auth=mock_ks_auth,
+ region_name=None)
n.AndReturn(self.mock_admin_client)
self.mock_admin_client.domains = self.mock_ks_v3_client_domain_mngr
@@ -131,7 +132,8 @@ class KeystoneClientTest(common.HeatTestCase):
if client:
c = kc_v3.Client(session=mox.IsA(ks_session.Session),
- auth=mock_ks_auth)
+ auth=mock_ks_auth,
+ region_name=None)
c.AndReturn(self.mock_ks_v3_client)
if stub_trust_context:
@@ -1482,7 +1484,8 @@ class KeystoneClientTestDomainName(KeystoneClientTest):
m.AndReturn(mock_ks_auth)
n = kc_v3.Client(session=mox.IsA(ks_session.Session),
- auth=mock_ks_auth)
+ auth=mock_ks_auth,
+ region_name=None)
n.AndReturn(self.mock_admin_client)
self.mock_admin_client.domains = self.mock_ks_v3_client_domain_mngr