]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes the provisioning on selected volumes for NetApp 7 mode.
authorNavneet Singh <singn@netapp.com>
Thu, 14 Feb 2013 13:20:03 +0000 (05:20 -0800)
committerNavneet Singh <singn@netapp.com>
Thu, 14 Feb 2013 13:20:03 +0000 (05:20 -0800)
The current direct driver for 7 mode provisions openstack
volume on all NetApp 7 mode volumes mixing openstack volumes
with all non openstack volumes. This fix allows volume selection
by the user to keep openstack volumes separate from non opnestack
block storage entities.

bug 1132834

Change-Id: I77b78ce304e72482724b6ff7c52795c60992243e

cinder/tests/test_netapp.py
cinder/volume/drivers/netapp/iscsi.py

index c3ff075d391a0ae8bd9dc75155be15265503f284..0bc8f48de3b20ccd2e9168c11a6e459dd0b75929 100644 (file)
@@ -2280,11 +2280,31 @@ class NetAppDirect7modeISCSIDriverTestCase_NV(
                               hostname='127.0.0.1',
                               port='80')
         driver.vfiler = None
+        driver.volume_list = None
         self.driver = driver
 
+    def test_create_on_select_vol(self):
+        self.driver.volume_list = ['vol0', 'vol1']
+        self.driver.create_volume(self.volume)
+        self.driver.delete_volume(self.volume)
+        self.driver.volume_list = []
+
+    def test_create_fail_on_select_vol(self):
+        self.driver.volume_list = ['vol2', 'vol3']
+        success = False
+        try:
+            self.driver.create_volume(self.volume)
+        except VolumeBackendAPIException:
+            success = True
+            pass
+        finally:
+            self.driver.volume_list = []
+        if not success:
+            raise AssertionError('Failed creating on selected volumes')
+
 
 class NetAppDirect7modeISCSIDriverTestCase_WV(
-        NetAppDirectCmodeISCSIDriverTestCase):
+        NetAppDirect7modeISCSIDriverTestCase_NV):
     """Test case for NetAppISCSIDriver
        With vfiler
     """
@@ -2301,4 +2321,5 @@ class NetAppDirect7modeISCSIDriverTestCase_WV(
                               port='80')
         driver.vfiler = 'vfiler'
         driver.client.set_api_version(1, 7)
+        driver.volume_list = None
         self.driver = driver
index d97c9e5c24154535b3a9e5823ad9b39d1cdbe5e2..642bb781252e3e2a723f6c4786022c9b41782c37 100644 (file)
@@ -77,7 +77,11 @@ netapp_opts = [
                help='Cluster vserver to use for provisioning'),
     cfg.FloatOpt('netapp_size_multiplier',
                  default=1.2,
-                 help='Volume size multiplier to ensure while creation'), ]
+                 help='Volume size multiplier to ensure while creation'),
+    cfg.StrOpt('netapp_volume_list',
+               default='',
+               help='Comma separated eligible volumes for provisioning on'
+                    ' 7 mode'), ]
 
 FLAGS = flags.FLAGS
 FLAGS.register_opts(netapp_opts)
@@ -2244,6 +2248,10 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver):
     def _do_custom_setup(self):
         """Does custom setup depending on the type of filer."""
         self.vfiler = FLAGS.netapp_vfiler
+        self.volume_list = FLAGS.netapp_volume_list
+        if self.volume_list:
+            self.volume_list = self.volume_list.split(',')
+            self.volume_list = [el.strip() for el in self.volume_list]
         if self.vfiler:
             (major, minor) = self._get_ontapi_version()
             self.client.set_api_version(major, minor)
@@ -2263,8 +2271,12 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver):
                 avl_vol['block-type'] = vol.get_child_content('block-type')
                 avl_vol['type'] = vol.get_child_content('type')
                 avl_vol['size-available'] = avl_size
-                if self._check_vol_not_root(avl_vol):
-                    return avl_vol
+                if self.volume_list:
+                    if avl_vol['name'] in self.volume_list:
+                        return avl_vol
+                else:
+                    if self._check_vol_not_root(avl_vol):
+                        return avl_vol
         return None
 
     def _check_vol_not_root(self, vol):
@@ -2342,10 +2354,29 @@ class NetAppDirect7modeISCSIDriver(NetAppDirectISCSIDriver):
 
     def _get_lun_list(self):
         """Gets the list of luns on filer."""
+        lun_list = []
+        if self.volume_list:
+            for vol in self.volume_list:
+                try:
+                    luns = self._get_vol_luns(vol)
+                    if luns:
+                        lun_list.extend(luns)
+                except NaApiError:
+                    LOG.warn(_("Error finding luns for volume %(vol)s."
+                               " Verify volume exists.") % locals())
+        else:
+            luns = self._get_vol_luns(None)
+            lun_list.extend(luns)
+        self._extract_and_populate_luns(lun_list)
+
+    def _get_vol_luns(self, vol_name):
+        """Gets the luns for a volume."""
         api = NaElement('lun-list-info')
+        if vol_name:
+            api.add_new_child('volume-name', vol_name)
         result = self._invoke_successfully(api, True)
         luns = result.get_child_by_name('luns')
-        self._extract_and_populate_luns(luns.get_children())
+        return luns.get_children()
 
     def _find_mapped_lun_igroup(self, path, initiator, os=None):
         """Find the igroup for mapped lun with initiator."""