From 4706a2fc59383f114a78dc087611630f8541b43d Mon Sep 17 00:00:00 2001 From: Andrew Kerr Date: Thu, 21 Jan 2016 10:22:33 -0500 Subject: [PATCH] NetApp ONTAP - Reapply API tracing The NetApp ONTAP drivers had their API tracing inadvertently removed when the netapp_lib changes were reverted. This patch adds that tracing back in. Closes-Bug: #1536683 Change-Id: I3c9f8fdc33e0e5128db41b497f54bd8ff07a8d85 --- .../netapp/dataontap/client/test_api.py | 22 +++++++++---------- .../drivers/netapp/dataontap/client/api.py | 6 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py index fb8ffc5ff..f577c9cea 100644 --- a/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py +++ b/cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py @@ -106,7 +106,7 @@ class NetAppApiServerTests(test.TestCase): @ddt.unpack def test_invoke_successfully_naapi_error(self, params): """Tests invoke successfully raising NaApiError""" - self.mock_object(self.root, 'invoke_elem', + self.mock_object(self.root, 'send_http_request', mock.Mock(return_value=params['result'])) self.assertRaises(netapp_api.NaApiError, @@ -115,7 +115,7 @@ class NetAppApiServerTests(test.TestCase): def test_invoke_successfully_no_error(self): """Tests invoke successfully with no errors""" - self.mock_object(self.root, 'invoke_elem', mock.Mock( + self.mock_object(self.root, 'send_http_request', mock.Mock( return_value=zapi_fakes.FAKE_RESULT_SUCCESS)) self.assertEqual(zapi_fakes.FAKE_RESULT_SUCCESS.to_string(), @@ -187,12 +187,12 @@ class NetAppApiServerTests(test.TestCase): self.assertTrue(mock_invoke.called) @ddt.data(None, zapi_fakes.FAKE_XML_STR) - def test_invoke_elem_value_error(self, na_element): + def test_send_http_request_value_error(self, na_element): """Tests whether invalid NaElement parameter causes error""" - self.assertRaises(ValueError, self.root.invoke_elem, na_element) + self.assertRaises(ValueError, self.root.send_http_request, na_element) - def test_invoke_elem_http_error(self): + def test_send_http_request_http_error(self): """Tests handling of HTTPError""" na_element = zapi_fakes.FAKE_NA_ELEMENT self.mock_object(self.root, '_create_request', mock.Mock( @@ -205,10 +205,10 @@ class NetAppApiServerTests(test.TestCase): fp=None, code='401', msg='httperror'))) - self.assertRaises(netapp_api.NaApiError, self.root.invoke_elem, + self.assertRaises(netapp_api.NaApiError, self.root.send_http_request, na_element) - def test_invoke_elem_unknown_exception(self): + def test_send_http_request_unknown_exception(self): """Tests handling of Unknown Exception""" na_element = zapi_fakes.FAKE_NA_ELEMENT self.mock_object(self.root, '_create_request', mock.Mock( @@ -219,11 +219,11 @@ class NetAppApiServerTests(test.TestCase): self.mock_object(self.root._opener, 'open', mock.Mock( side_effect=Exception)) - self.assertRaises(netapp_api.NaApiError, self.root.invoke_elem, + self.assertRaises(netapp_api.NaApiError, self.root.send_http_request, na_element) - def test_invoke_elem_valid(self): - """Tests the method invoke_elem with valid parameters""" + def test_send_http_request_valid(self): + """Tests the method send_http_request with valid parameters""" na_element = zapi_fakes.FAKE_NA_ELEMENT self.root._trace = True self.mock_object(self.root, '_create_request', mock.Mock( @@ -237,7 +237,7 @@ class NetAppApiServerTests(test.TestCase): self.root._opener, 'open', mock.Mock()) opener_mock.read.side_effect = ['resp1', 'resp2'] - self.root.invoke_elem(na_element) + self.root.send_http_request(na_element) class NetAppApiElementTransTests(test.TestCase): diff --git a/cinder/volume/drivers/netapp/dataontap/client/api.py b/cinder/volume/drivers/netapp/dataontap/client/api.py index fd756d7c1..b4b77ada3 100644 --- a/cinder/volume/drivers/netapp/dataontap/client/api.py +++ b/cinder/volume/drivers/netapp/dataontap/client/api.py @@ -30,6 +30,7 @@ from six.moves import urllib from cinder import exception from cinder.i18n import _ +from cinder import utils LOG = logging.getLogger(__name__) @@ -196,7 +197,8 @@ class NaServer(object): self._password = password self._refresh_conn = True - def invoke_elem(self, na_element, enable_tunneling=False): + @utils.trace_api + def send_http_request(self, na_element, enable_tunneling=False): """Invoke the API on the server.""" if not na_element or not isinstance(na_element, NaElement): raise ValueError('NaElement must be supplied to invoke API') @@ -230,7 +232,7 @@ class NaServer(object): tunneling. The vserver or vfiler should be set before this call otherwise tunneling remains disabled. """ - result = self.invoke_elem(na_element, enable_tunneling) + result = self.send_http_request(na_element, enable_tunneling) if result.has_attr('status') and result.get_attr('status') == 'passed': return result code = result.get_attr('errno')\ -- 2.45.2