Fix for None base_url for Monasca client
Heat engine tries to create client object using token, but the token in Monsca client will be reauthenticated. It can't be reauthenticated, because it doesn't have base_url in kwargs (Monasca client), so it raises an error "AttributeError: 'NoneType' object has no attribute 'find'". Using session instead of token fixes the issue. Change-Id: I154c0360946043f6dbb12ef756aa01d674f6de8f Closes-Bug: #1713050
This commit is contained in:
parent
9e4cda46e6
commit
36e53d3c2b
|
@ -32,15 +32,10 @@ class MonascaClientPlugin(client_plugin.ClientPlugin):
|
|||
interface = self._get_client_option(CLIENT_NAME, 'endpoint_type')
|
||||
endpoint = self.url_for(service_type=self.MONITORING,
|
||||
endpoint_type=interface)
|
||||
# Change this to use session once it's supported by monascaclient
|
||||
return client.Client(
|
||||
self.VERSION,
|
||||
token=self.context.keystone_session.get_token(),
|
||||
endpoint=endpoint,
|
||||
cacert=self._get_client_option(CLIENT_NAME, 'ca_file'),
|
||||
cert_file=self._get_client_option(CLIENT_NAME, 'cert_file'),
|
||||
key_file=self._get_client_option(CLIENT_NAME, 'key_file'),
|
||||
insecure=self._get_client_option(CLIENT_NAME, 'insecure'))
|
||||
session=self.context.keystone_session,
|
||||
endpoint=endpoint)
|
||||
|
||||
def is_not_found(self, ex):
|
||||
return isinstance(ex, monasca_exc.NotFound)
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
import mock
|
||||
import six
|
||||
|
||||
import monascaclient
|
||||
|
||||
from heat.common import exception as heat_exception
|
||||
from heat.engine.clients.os import monasca as client_plugin
|
||||
from heat.tests import common
|
||||
|
@ -47,6 +49,12 @@ class MonascaClientPluginTest(common.HeatTestCase):
|
|||
client = plugin.client()
|
||||
self.assertIsNotNone(client.metrics)
|
||||
|
||||
@mock.patch.object(monascaclient.client, '_session')
|
||||
def test_client_uses_session(self, mock_session):
|
||||
monasca_client = client_plugin.MonascaClientPlugin(
|
||||
context=mock.MagicMock())
|
||||
self.assertIsNotNone(monasca_client._create())
|
||||
|
||||
|
||||
class MonascaClientPluginNotificationTest(common.HeatTestCase):
|
||||
|
||||
|
|
Loading…
Reference in New Issue