Browse Source

Fix unit test error of nova freezer client updates

This patch mainly contains two aspects:

1. Freezer team has updated freezerclient, they remove
the version parameter in Client. This make karbor
not work well when using freezer protection plugin.

2. Nova client remove self.logger as default from nova
client, it requires karbor transport logger to the
client.

Closes-Bug: #1802022

Change-Id: Iea594ff2917767108b868242d919db97a65479ea
jiaopengju 5 months ago
parent
commit
9a13d3c9a2

+ 2
- 7
karbor/services/protection/clients/freezer.py View File

@@ -46,8 +46,6 @@ CONF.register_opts(freezer_client_opts, group=CONFIG_GROUP)
46 46
 CONF.set_default('service_name', 'freezer', CONFIG_GROUP)
47 47
 CONF.set_default('service_type', 'backup', CONFIG_GROUP)
48 48
 
49
-FREEZERCLIENT_VERSION = '3'
50
-
51 49
 
52 50
 def create(context, conf, **kwargs):
53 51
     conf.register_opts(freezer_client_opts, group=CONFIG_GROUP)
@@ -57,10 +55,8 @@ def create(context, conf, **kwargs):
57 55
                         append_project_fmt='%(url)s/%(project)s', **kwargs)
58 56
 
59 57
     if kwargs.get('session'):
60
-        return freezer_client.Client(version=FREEZERCLIENT_VERSION,
61
-                                     session=kwargs.get('session'),
62
-                                     endpoint=url
63
-                                     )
58
+        return freezer_client.Client(session=kwargs.get('session'),
59
+                                     endpoint=url)
64 60
     args = {
65 61
         'project_id': context.project_id,
66 62
         'project_name': context.project_name,
@@ -68,7 +64,6 @@ def create(context, conf, **kwargs):
68 64
         'insecure': client_config.freezer_auth_insecure,
69 65
         'endpoint': url,
70 66
         'token': context.auth_token,
71
-        'version': FREEZERCLIENT_VERSION,
72 67
         'auth_url': client_config.auth_uri
73 68
     }
74 69
     return freezer_client.Client(**args)

+ 3
- 1
karbor/services/protection/clients/nova.py View File

@@ -10,6 +10,7 @@
10 10
 #    License for the specific language governing permissions and limitations
11 11
 #    under the License.
12 12
 
13
+import logging as log
13 14
 from novaclient import client as nc
14 15
 from oslo_config import cfg
15 16
 from oslo_log import log as logging
@@ -66,4 +67,5 @@ def create(context, conf, **kwargs):
66 67
             err="The parameter session is None.")
67 68
 
68 69
     return nc.Client(NOVACLIENT_VERSION, extensions=extensions,
69
-                     session=kwargs.get('session'), endpoint_override=url)
70
+                     session=kwargs.get('session'), endpoint_override=url,
71
+                     logger=log.getLogger('novaclient'))

+ 1
- 5
karbor/tests/unit/clients/test_freezer_client.py View File

@@ -41,13 +41,11 @@ class FreezerClientTest(base.TestCase):
41 41
     @mock.patch('freezerclient.v1.client.Client')
42 42
     def test_create_client(self, create, get_url):
43 43
         get_url.return_value = self._public_url
44
-        client_version = freezer.FREEZERCLIENT_VERSION
45 44
 
46 45
         session = keystone_session.Session(auth=None)
47 46
         freezer.create(self._context, cfg.CONF, session=session)
48 47
         create.assert_called_with(endpoint=self._public_url,
49
-                                  session=session,
50
-                                  version=client_version)
48
+                                  session=session)
51 49
 
52 50
     @mock.patch('karbor.services.protection.clients.utils.get_url')
53 51
     @mock.patch('freezerclient.v1.client.Client')
@@ -59,7 +57,6 @@ class FreezerClientTest(base.TestCase):
59 57
         cfg.CONF.set_default('auth_uri',
60 58
                              self._auth_url,
61 59
                              freezer.CONFIG_GROUP)
62
-        client_version = freezer.FREEZERCLIENT_VERSION
63 60
         args = {
64 61
             'project_id': self._context.project_id,
65 62
             'project_name': self._context.project_name,
@@ -67,7 +64,6 @@ class FreezerClientTest(base.TestCase):
67 64
             'insecure': client_config.freezer_auth_insecure,
68 65
             'endpoint': self._public_url,
69 66
             'token': self._context.auth_token,
70
-            'version': client_version,
71 67
             'auth_url': self._auth_url,
72 68
         }
73 69
 

Loading…
Cancel
Save