Fix OS::Zaqar::MistralSubscription with mistralclient 3.0

Starting with python-mistralclient 3.0.0, the Client object no longer
has http_client as an attribute. Instead get it from the
ExecutionManager.

To ensure backward compatibility with earlier client versions, look for
either the HTTPClient or the Client as an attribute of the
ExecutionManager.

Change-Id: I507284727039476acfdb1c9c8a26a360edc42417
Closes-Bug: #1704883
This commit is contained in:
Zane Bitter 2017-07-17 18:19:10 -04:00
parent f74c00b8cb
commit 02176a5811
2 changed files with 7 additions and 3 deletions

View File

@ -193,7 +193,9 @@ class MistralTrigger(ZaqarSubscription):
def _subscriber_url(self):
mistral_client = self.client('mistral')
return 'trust+%s/executions' % mistral_client.http_client.base_url
manager = getattr(mistral_client.executions, 'client',
mistral_client.executions)
return 'trust+%s/executions' % manager.http_client.base_url
def _subscription_options(self):
params = dict(self.properties[self.PARAMS])

View File

@ -348,8 +348,10 @@ class ZaqarMistralTriggerTest(common.HeatTestCase):
def client(name='zaqar'):
if name == 'mistral':
client = mock.Mock()
client.http_client = mock.Mock()
client.http_client.base_url = 'http://mistral.example.net:8989'
http_client = mock.Mock()
client.executions = mock.Mock(spec=['http_client'])
client.executions.http_client = http_client
http_client.base_url = 'http://mistral.example.net:8989'
return client
elif name == 'zaqar':
return self.fc