]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp ONTAP - Reapply API tracing
authorAndrew Kerr <andrew.kerr@netapp.com>
Thu, 21 Jan 2016 15:22:33 +0000 (10:22 -0500)
committerAndrew Kerr <andrew.kerr@netapp.com>
Thu, 21 Jan 2016 18:30:00 +0000 (18:30 +0000)
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

cinder/tests/unit/volume/drivers/netapp/dataontap/client/test_api.py
cinder/volume/drivers/netapp/dataontap/client/api.py

index fb8ffc5ff0c8d1ef2959b49f98906a211162345a..f577c9cea10bfdb7472f78fbc854f18826ed24ab 100644 (file)
@@ -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):
index fd756d7c13985dd7cd0ab3ef977eec17e321f490..b4b77ada3a32bbfb912a61900f6378b123cdc8d3 100644 (file)
@@ -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')\