From e71059ac4d6546c153b7229d4d7763564c6cdf1f Mon Sep 17 00:00:00 2001 From: Vladimir Khlyunev Date: Mon, 9 Jan 2017 16:31:37 +0400 Subject: [PATCH] Update Nova client initialization according to 7.0.0 version python-novaclient was updated and now newest version contains bug in username-password auth. Switching to session-based auth will allow to fix it (and also its openstack way to use shared session) Change-Id: If48f8f96843023f4f36e737cd818761db9184884 Closes-bug:1653693 --- fuel_health/nmanager.py | 39 +++++++++++++++++---------------------- requirements.txt | 4 ++-- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/fuel_health/nmanager.py b/fuel_health/nmanager.py index aea77459..5ef5dbd2 100644 --- a/fuel_health/nmanager.py +++ b/fuel_health/nmanager.py @@ -18,6 +18,9 @@ import logging import os import time +from keystoneauth1.identity import V2Password +from keystoneauth1.session import Session as KeystoneSession + import fuel_health.common.utils.data_utils as data_utils LOG = logging.getLogger(__name__) @@ -94,6 +97,8 @@ class OfficialClientManager(fuel_health.manager.Manager): self.clients_initialized = False self.traceback = '' self.keystone_error_message = None + + self._keystone_session = None self.compute_client = self._get_compute_client() try: self.identity_client = self._get_identity_client() @@ -141,32 +146,22 @@ class OfficialClientManager(fuel_health.manager.Manager): 'murano_art_client' ] - def _get_compute_client(self, username=None, password=None, - tenant_name=None): - if not username: - username = self.config.identity.admin_username - if not password: - password = self.config.identity.admin_password - if not tenant_name: - tenant_name = self.config.identity.admin_tenant_name + @property + def keystone_session(self): + if not self._keystone_session: + auth = V2Password( + auth_url=self.config.identity.uri, + username=self.config.identity.admin_username, + password=self.config.identity.admin_password, + tenant_name=self.config.identity.admin_tenant_name) - if None in (username, password, tenant_name): - msg = ("Missing required credentials for identity client. " - "username: {username}, password: {password}, " - "tenant_name: {tenant_name}").format( - username=username, - password=password, - tenant_name=tenant_name, ) - raise exceptions.InvalidConfiguration(msg) + self._keystone_session = KeystoneSession(auth=auth, verify=False) + return self._keystone_session - auth_url = self.config.identity.uri - - client_args = (username, password, tenant_name, auth_url) - - # Create our default Nova client to use in testing + def _get_compute_client(self): service_type = self.config.compute.catalog_type return novaclient.client.Client(self.NOVACLIENT_VERSION, - *client_args, + session=self.keystone_session, service_type=service_type, no_cache=True, insecure=True, diff --git a/requirements.txt b/requirements.txt index fe83879e..49ed04b1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ python-cinderclient>=1.6.0,!=1.7.0,!=1.7.1 # Apache-2.0 python-ceilometerclient>=2.5.0 # Apache-2.0 python-keystoneclient>=2.0.0,!=2.1.0 # Apache-2.0 python-muranoclient>=0.8.2 # Apache-2.0 -python-novaclient>=2.29.0,!=2.33.0 # Apache-2.0 +python-novaclient>=7.0 # Apache-2.0 python-neutronclient>=5.1.0 # Apache-2.0 python-heatclient>=1.4.0 # Apache-2.0 python-glanceclient>=2.3.0,!=2.4.0 # Apache-2.0 @@ -25,7 +25,7 @@ amqp>=1.4.0,<2.0 # LGPL anyjson>=0.3.3 # BSD gevent keystonemiddleware>=4.0.0,!=4.1.0,!=4.5.0 # Apache-2.0 -kombu>=3.0.25,!=4.0.0 # BSD +kombu>=3.0.25,<4.0.0 # BSD oslo.serialization>=1.10.0 # Apache-2.0 oslo.utils>=3.16.0 # Apache-2.0 pecan>=1.0.0,!=1.0.2,!=1.0.3,!=1.0.4 # BSD