]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp check for 7 mode controller version
authorNavneet Singh <singn@netapp.com>
Tue, 30 Jul 2013 12:07:44 +0000 (17:37 +0530)
committerNavneet Singh <singn@netapp.com>
Wed, 31 Jul 2013 09:36:05 +0000 (15:06 +0530)
Queries the filer api version and raises error
if the version is unsupported.

Closes-Bug:#1223474

Change-Id: I430a41d63a2541891fdbdb20dacab9f69fa44291

cinder/tests/test_netapp.py
cinder/tests/test_netapp_nfs.py
cinder/volume/drivers/netapp/api.py
cinder/volume/drivers/netapp/iscsi.py
cinder/volume/drivers/netapp/nfs.py

index 252d749b63fafd9310be294bddd960af7ca4e5b1..3ce185b617df830a62e41d0a2b84c55d81c49c33 100644 (file)
@@ -1066,7 +1066,7 @@ class NetAppDirect7modeISCSIDriverTestCase_NV(
                        FakeDirect7modeHTTPConnection)
         driver.do_setup(context='')
         client = driver.client
-        client.set_api_version(1, 7)
+        client.set_api_version(1, 9)
         self.driver = driver
 
     def _set_config(self, configuration):
@@ -1098,6 +1098,20 @@ class NetAppDirect7modeISCSIDriverTestCase_NV(
         if not success:
             raise AssertionError('Failed creating on selected volumes')
 
+    def test_check_for_setup_error_version(self):
+        drv = self.driver
+        delattr(drv.client, '_api_version')
+
+        # check exception raises when version not found
+        self.assertRaises(exception.VolumeBackendAPIException,
+                          drv.check_for_setup_error)
+
+        drv.client.set_api_version(1, 8)
+
+        # check exception raises when not supported version
+        self.assertRaises(exception.VolumeBackendAPIException,
+                          drv.check_for_setup_error)
+
 
 class NetAppDirect7modeISCSIDriverTestCase_WV(
         NetAppDirect7modeISCSIDriverTestCase_NV):
@@ -1114,7 +1128,7 @@ class NetAppDirect7modeISCSIDriverTestCase_WV(
                        FakeDirect7modeHTTPConnection)
         driver.do_setup(context='')
         client = driver.client
-        client.set_api_version(1, 7)
+        client.set_api_version(1, 9)
         self.driver = driver
 
     def _set_config(self, configuration):
index 4bdf855d2fb6724a88a1f0a9673afd0657f4862f..5301d2b9019b0574c8d17700ea3028c76b1fc67e 100644 (file)
@@ -216,12 +216,10 @@ class NetappDirectCmodeNfsDriverTestCase(test.TestCase):
         drv = self._driver
 
         mox.StubOutWithMock(netapp_nfs.NetAppNFSDriver, 'do_setup')
-        mox.StubOutWithMock(drv, 'check_for_setup_error')
         mox.StubOutWithMock(drv, '_get_client')
         mox.StubOutWithMock(drv, '_do_custom_setup')
 
         netapp_nfs.NetAppNFSDriver.do_setup(IgnoreArg())
-        drv.check_for_setup_error()
         drv._get_client()
         drv._do_custom_setup(IgnoreArg())
 
@@ -797,9 +795,25 @@ class NetappDirect7modeNfsDriverTestCase(NetappDirectCmodeNfsDriverTestCase):
         self._driver = netapp_nfs.NetAppDirect7modeNfsDriver(
             configuration=create_configuration())
 
+    def test_check_for_setup_error_version(self):
+        drv = self._driver
+        drv._client = api.NaServer("127.0.0.1")
+
+        # check exception raises when version not found
+        self.assertRaises(exception.VolumeBackendAPIException,
+                          drv.check_for_setup_error)
+
+        drv._client.set_api_version(1, 8)
+
+        # check exception raises when not supported version
+        self.assertRaises(exception.VolumeBackendAPIException,
+                          drv.check_for_setup_error)
+
     def test_check_for_setup_error(self):
         mox = self.mox
         drv = self._driver
+        drv._client = api.NaServer("127.0.0.1")
+        drv._client.set_api_version(1, 9)
         required_flags = [
             'netapp_transport_type',
             'netapp_login',
@@ -832,11 +846,9 @@ class NetappDirect7modeNfsDriverTestCase(NetappDirectCmodeNfsDriverTestCase):
         mox = self.mox
         drv = self._driver
         mox.StubOutWithMock(netapp_nfs.NetAppNFSDriver, 'do_setup')
-        mox.StubOutWithMock(drv, 'check_for_setup_error')
         mox.StubOutWithMock(drv, '_get_client')
         mox.StubOutWithMock(drv, '_do_custom_setup')
         netapp_nfs.NetAppNFSDriver.do_setup(IgnoreArg())
-        drv.check_for_setup_error()
         drv._get_client()
         drv._do_custom_setup(IgnoreArg())
 
index 4212601d52d57408a1a62c77a5f0ef7718dcf03c..5d0716092a67e6a7d90ea1bfe8198bc697106ca7 100644 (file)
@@ -125,10 +125,10 @@ class NaServer(object):
         self._refresh_conn = True
 
     def get_api_version(self):
-        """Gets the api version."""
+        """Gets the api version tuple."""
         if hasattr(self, '_api_version'):
-            return self._api_version
-        return self._api_version
+            return (self._api_major_version, self._api_minor_version)
+        return None
 
     def set_port(self, port):
         """Set the server communication port."""
index da9859092aecf6dc05b1a3e2d11517a8f6777df1..d21177e9aef9a577f19bdcfbae1a3361ed406d01 100644 (file)
@@ -903,11 +903,25 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver):
         if self.volume_list:
             self.volume_list = self.volume_list.split(',')
             self.volume_list = [el.strip() for el in self.volume_list]
+        (major, minor) = self._get_ontapi_version()
+        self.client.set_api_version(major, minor)
         if self.vfiler:
-            (major, minor) = self._get_ontapi_version()
-            self.client.set_api_version(major, minor)
             self.client.set_vfiler(self.vfiler)
 
+    def check_for_setup_error(self):
+        """Check that the driver is working and can communicate."""
+        api_version = self.client.get_api_version()
+        if api_version:
+            major, minor = api_version
+            if major == 1 and minor < 9:
+                msg = _("Unsupported ONTAP version."
+                        " ONTAP version 7.3.1 and above is supported.")
+                raise exception.VolumeBackendAPIException(data=msg)
+        else:
+            msg = _("Api version could not be determined.")
+            raise exception.VolumeBackendAPIException(data=msg)
+        super(NetAppDirect7modeISCSIDriver, self).check_for_setup_error()
+
     def _create_lun_on_eligible_vol(self, name, size, metadata,
                                     extra_specs=None):
         """Creates an actual lun on filer."""
index e5599a3fea36933c5c39008bad55704f17e60ec7..209abb8e7a544c8d6cd32ea6b6d807405c2ab3f1 100644 (file)
@@ -594,7 +594,6 @@ class NetAppDirectNfsDriver (NetAppNFSDriver):
     def do_setup(self, context):
         super(NetAppDirectNfsDriver, self).do_setup(context)
         self._context = context
-        self.check_for_setup_error()
         self._client = self._get_client()
         self._do_custom_setup(self._client)
 
@@ -996,6 +995,20 @@ class NetAppDirect7modeNfsDriver (NetAppDirectNfsDriver):
         (major, minor) = self._get_ontapi_version()
         client.set_api_version(major, minor)
 
+    def check_for_setup_error(self):
+        """Checks if setup occured properly."""
+        api_version = self._client.get_api_version()
+        if api_version:
+            major, minor = api_version
+            if major == 1 and minor < 9:
+                msg = _("Unsupported ONTAP version."
+                        " ONTAP version 7.3.1 and above is supported.")
+                raise exception.VolumeBackendAPIException(data=msg)
+        else:
+            msg = _("Api version could not be determined.")
+            raise exception.VolumeBackendAPIException(data=msg)
+        super(NetAppDirect7modeNfsDriver, self).check_for_setup_error()
+
     def _invoke_successfully(self, na_element, vfiler=None):
         """Invoke the api for successful result.