Browse Source

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
Vladimir Khlyunev 2 years ago
parent
commit
e71059ac4d
2 changed files with 19 additions and 24 deletions
  1. 17
    22
      fuel_health/nmanager.py
  2. 2
    2
      requirements.txt

+ 17
- 22
fuel_health/nmanager.py View File

@@ -18,6 +18,9 @@ import logging
18 18
 import os
19 19
 import time
20 20
 
21
+from keystoneauth1.identity import V2Password
22
+from keystoneauth1.session import Session as KeystoneSession
23
+
21 24
 import fuel_health.common.utils.data_utils as data_utils
22 25
 
23 26
 LOG = logging.getLogger(__name__)
@@ -94,6 +97,8 @@ class OfficialClientManager(fuel_health.manager.Manager):
94 97
         self.clients_initialized = False
95 98
         self.traceback = ''
96 99
         self.keystone_error_message = None
100
+
101
+        self._keystone_session = None
97 102
         self.compute_client = self._get_compute_client()
98 103
         try:
99 104
             self.identity_client = self._get_identity_client()
@@ -141,32 +146,22 @@ class OfficialClientManager(fuel_health.manager.Manager):
141 146
                 'murano_art_client'
142 147
             ]
143 148
 
144
-    def _get_compute_client(self, username=None, password=None,
145
-                            tenant_name=None):
146
-        if not username:
147
-            username = self.config.identity.admin_username
148
-        if not password:
149
-            password = self.config.identity.admin_password
150
-        if not tenant_name:
151
-            tenant_name = self.config.identity.admin_tenant_name
152
-
153
-        if None in (username, password, tenant_name):
154
-            msg = ("Missing required credentials for identity client. "
155
-                   "username: {username}, password: {password}, "
156
-                   "tenant_name: {tenant_name}").format(
157
-                       username=username,
158
-                       password=password,
159
-                       tenant_name=tenant_name, )
160
-            raise exceptions.InvalidConfiguration(msg)
161
-
162
-        auth_url = self.config.identity.uri
149
+    @property
150
+    def keystone_session(self):
151
+        if not self._keystone_session:
152
+            auth = V2Password(
153
+                auth_url=self.config.identity.uri,
154
+                username=self.config.identity.admin_username,
155
+                password=self.config.identity.admin_password,
156
+                tenant_name=self.config.identity.admin_tenant_name)
163 157
 
164
-        client_args = (username, password, tenant_name, auth_url)
158
+            self._keystone_session = KeystoneSession(auth=auth, verify=False)
159
+        return self._keystone_session
165 160
 
166
-        # Create our default Nova client to use in testing
161
+    def _get_compute_client(self):
167 162
         service_type = self.config.compute.catalog_type
168 163
         return novaclient.client.Client(self.NOVACLIENT_VERSION,
169
-                                        *client_args,
164
+                                        session=self.keystone_session,
170 165
                                         service_type=service_type,
171 166
                                         no_cache=True,
172 167
                                         insecure=True,

+ 2
- 2
requirements.txt View File

@@ -5,7 +5,7 @@ python-cinderclient>=1.6.0,!=1.7.0,!=1.7.1  # Apache-2.0
5 5
 python-ceilometerclient>=2.5.0  # Apache-2.0
6 6
 python-keystoneclient>=2.0.0,!=2.1.0  # Apache-2.0
7 7
 python-muranoclient>=0.8.2  # Apache-2.0
8
-python-novaclient>=2.29.0,!=2.33.0  # Apache-2.0
8
+python-novaclient>=7.0  # Apache-2.0
9 9
 python-neutronclient>=5.1.0  # Apache-2.0
10 10
 python-heatclient>=1.4.0  # Apache-2.0
11 11
 python-glanceclient>=2.3.0,!=2.4.0  # Apache-2.0
@@ -25,7 +25,7 @@ amqp>=1.4.0,<2.0 # LGPL
25 25
 anyjson>=0.3.3  # BSD
26 26
 gevent
27 27
 keystonemiddleware>=4.0.0,!=4.1.0,!=4.5.0  # Apache-2.0
28
-kombu>=3.0.25,!=4.0.0 # BSD
28
+kombu>=3.0.25,<4.0.0 # BSD
29 29
 oslo.serialization>=1.10.0              # Apache-2.0
30 30
 oslo.utils>=3.16.0                       # Apache-2.0
31 31
 pecan>=1.0.0,!=1.0.2,!=1.0.3,!=1.0.4  # BSD

Loading…
Cancel
Save