summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiaopengju <jiaopengju@cmss.chinamobile.com>2018-11-07 09:18:07 +0800
committerjiaopengju <jiaopengju@cmss.chinamobile.com>2018-11-07 15:12:39 +0800
commit9a13d3c9a20440a7011ca3e332b17db1bcfd6026 (patch)
treeed66a246f7d87f9d3b6f68873c0736eedf281533
parent66b02df4e466bbf01fdd4f9b2c0c9c39e337906a (diff)
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
Notes
Notes (review): Code-Review+2: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Workflow+1: Jiao Pengju <jiaopengju@cmss.chinamobile.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Wed, 07 Nov 2018 09:08:42 +0000 Reviewed-on: https://review.openstack.org/616042 Project: openstack/karbor Branch: refs/heads/master
-rw-r--r--karbor/services/protection/clients/freezer.py9
-rw-r--r--karbor/services/protection/clients/nova.py4
-rw-r--r--karbor/tests/unit/clients/test_freezer_client.py6
3 files changed, 6 insertions, 13 deletions
diff --git a/karbor/services/protection/clients/freezer.py b/karbor/services/protection/clients/freezer.py
index 3715682..ba7d0df 100644
--- a/karbor/services/protection/clients/freezer.py
+++ b/karbor/services/protection/clients/freezer.py
@@ -46,8 +46,6 @@ CONF.register_opts(freezer_client_opts, group=CONFIG_GROUP)
46CONF.set_default('service_name', 'freezer', CONFIG_GROUP) 46CONF.set_default('service_name', 'freezer', CONFIG_GROUP)
47CONF.set_default('service_type', 'backup', CONFIG_GROUP) 47CONF.set_default('service_type', 'backup', CONFIG_GROUP)
48 48
49FREEZERCLIENT_VERSION = '3'
50
51 49
52def create(context, conf, **kwargs): 50def create(context, conf, **kwargs):
53 conf.register_opts(freezer_client_opts, group=CONFIG_GROUP) 51 conf.register_opts(freezer_client_opts, group=CONFIG_GROUP)
@@ -57,10 +55,8 @@ def create(context, conf, **kwargs):
57 append_project_fmt='%(url)s/%(project)s', **kwargs) 55 append_project_fmt='%(url)s/%(project)s', **kwargs)
58 56
59 if kwargs.get('session'): 57 if kwargs.get('session'):
60 return freezer_client.Client(version=FREEZERCLIENT_VERSION, 58 return freezer_client.Client(session=kwargs.get('session'),
61 session=kwargs.get('session'), 59 endpoint=url)
62 endpoint=url
63 )
64 args = { 60 args = {
65 'project_id': context.project_id, 61 'project_id': context.project_id,
66 'project_name': context.project_name, 62 'project_name': context.project_name,
@@ -68,7 +64,6 @@ def create(context, conf, **kwargs):
68 'insecure': client_config.freezer_auth_insecure, 64 'insecure': client_config.freezer_auth_insecure,
69 'endpoint': url, 65 'endpoint': url,
70 'token': context.auth_token, 66 'token': context.auth_token,
71 'version': FREEZERCLIENT_VERSION,
72 'auth_url': client_config.auth_uri 67 'auth_url': client_config.auth_uri
73 } 68 }
74 return freezer_client.Client(**args) 69 return freezer_client.Client(**args)
diff --git a/karbor/services/protection/clients/nova.py b/karbor/services/protection/clients/nova.py
index 6d1b22f..7a0b102 100644
--- a/karbor/services/protection/clients/nova.py
+++ b/karbor/services/protection/clients/nova.py
@@ -10,6 +10,7 @@
10# License for the specific language governing permissions and limitations 10# License for the specific language governing permissions and limitations
11# under the License. 11# under the License.
12 12
13import logging as log
13from novaclient import client as nc 14from novaclient import client as nc
14from oslo_config import cfg 15from oslo_config import cfg
15from oslo_log import log as logging 16from oslo_log import log as logging
@@ -66,4 +67,5 @@ def create(context, conf, **kwargs):
66 err="The parameter session is None.") 67 err="The parameter session is None.")
67 68
68 return nc.Client(NOVACLIENT_VERSION, extensions=extensions, 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'))
diff --git a/karbor/tests/unit/clients/test_freezer_client.py b/karbor/tests/unit/clients/test_freezer_client.py
index 5bd7818..53e2958 100644
--- a/karbor/tests/unit/clients/test_freezer_client.py
+++ b/karbor/tests/unit/clients/test_freezer_client.py
@@ -41,13 +41,11 @@ class FreezerClientTest(base.TestCase):
41 @mock.patch('freezerclient.v1.client.Client') 41 @mock.patch('freezerclient.v1.client.Client')
42 def test_create_client(self, create, get_url): 42 def test_create_client(self, create, get_url):
43 get_url.return_value = self._public_url 43 get_url.return_value = self._public_url
44 client_version = freezer.FREEZERCLIENT_VERSION
45 44
46 session = keystone_session.Session(auth=None) 45 session = keystone_session.Session(auth=None)
47 freezer.create(self._context, cfg.CONF, session=session) 46 freezer.create(self._context, cfg.CONF, session=session)
48 create.assert_called_with(endpoint=self._public_url, 47 create.assert_called_with(endpoint=self._public_url,
49 session=session, 48 session=session)
50 version=client_version)
51 49
52 @mock.patch('karbor.services.protection.clients.utils.get_url') 50 @mock.patch('karbor.services.protection.clients.utils.get_url')
53 @mock.patch('freezerclient.v1.client.Client') 51 @mock.patch('freezerclient.v1.client.Client')
@@ -59,7 +57,6 @@ class FreezerClientTest(base.TestCase):
59 cfg.CONF.set_default('auth_uri', 57 cfg.CONF.set_default('auth_uri',
60 self._auth_url, 58 self._auth_url,
61 freezer.CONFIG_GROUP) 59 freezer.CONFIG_GROUP)
62 client_version = freezer.FREEZERCLIENT_VERSION
63 args = { 60 args = {
64 'project_id': self._context.project_id, 61 'project_id': self._context.project_id,
65 'project_name': self._context.project_name, 62 'project_name': self._context.project_name,
@@ -67,7 +64,6 @@ class FreezerClientTest(base.TestCase):
67 'insecure': client_config.freezer_auth_insecure, 64 'insecure': client_config.freezer_auth_insecure,
68 'endpoint': self._public_url, 65 'endpoint': self._public_url,
69 'token': self._context.auth_token, 66 'token': self._context.auth_token,
70 'version': client_version,
71 'auth_url': self._auth_url, 67 'auth_url': self._auth_url,
72 } 68 }
73 69