25669973 ZFSSANFSDriver fails with wrong mount.nfs expectation
authorsaurabh.vyas@oracle.com
Mon, 06 Mar 2017 19:45:46 -0800
changeset 7714 39538c7a06b7
parent 7713 61b9fca2eeb4
child 7718 9960a50bc6cf
25669973 ZFSSANFSDriver fails with wrong mount.nfs expectation
components/openstack/cinder/patches/17-launchpad-1598191.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/openstack/cinder/patches/17-launchpad-1598191.patch	Mon Mar 06 19:45:46 2017 -0800
@@ -0,0 +1,86 @@
+Based on patch from https://review.openstack.org/#/c/336598/
+
+From bc2f011fc0fd7e8ad331b3ae1918a5f660691253 Mon Sep 17 00:00:00 2001
+From: Kedar Vidvans <[email protected]>
+Date: Fri, 1 Jul 2016 10:29:09 -0400
+Subject: Fixes ZFSSANFS driver on Solaris platform
+
+The Solaris operating system doesn't have the mount.nfs
+tool installed. This fix skips the check for mount.nfs
+if the operating system is Solaris in the setup method.
+
+Change-Id: I8f6ee8e576a0f79ffe688aa2740913e9097e06c0
+Closes-Bug: #1598191
+
+--- cinder-8.0.0/cinder/tests/unit/test_zfssa.py.orig
++++ cinder-8.0.0/cinder/tests/unit/test_zfssa.py
+@@ -14,6 +14,7 @@
+ """Unit tests for Oracle's ZFSSA Cinder volume driver."""
+ 
+ from datetime import date
++import errno
+ import json
+ import math
+ 
+@@ -976,6 +977,7 @@
+         self.drv = zfssanfs.ZFSSANFSDriver(configuration=self.configuration)
+         self.drv._execute = fake_utils.fake_execute
+         self.drv.do_setup({})
++        self.context = context.get_admin_context()
+
+     def _create_fake_config(self):
+         self.configuration = mock.Mock(spec=conf.Configuration)
+@@ -998,6 +1000,22 @@
+         self.configuration.nfs_sparsed_volumes = 'true'
+         self.configuration.zfssa_manage_policy = 'strict'
+ 
++    def test_setup_nfs_client(self):
++        mock_execute = self.mock_object(self.drv, '_execute',
++                                        side_effect= OSError(errno.ENOENT,
++                                                             'No such file or '
++                                                             'directory.'))
++
++        self.assertRaises(exception.NfsException, self.drv.do_setup,
++                          self.context)
++        mock_execute.assert_has_calls(
++            [mock.call('mount.nfs',
++                       check_exit_code=False,
++                       run_as_root=True),
++             mock.call('/usr/sbin/mount',
++                       check_exit_code=False,
++                       run_as_root=True)])
++
+     def test_migrate_volume(self):
+         self.drv.zfssa.get_asn.return_value = (
+             '9a2b5a0f-e3af-6d14-9578-8825f229dc89')
+--- cinder-8.0.0/cinder/volume/drivers/zfssa/zfssanfs.py.orig
++++ cinder-8.0.0/cinder/volume/drivers/zfssa/zfssanfs.py
+@@ -113,15 +113,18 @@ class ZFSSANFSDriver(nfs.NfsDriver):
+             LOG.error(msg)
+             raise exception.NfsException(msg)
+ 
+-        package = 'mount.nfs'
+-        try:
+-            self._execute(package, check_exit_code=False, run_as_root=True)
+-        except OSError as exc:
+-            if exc.errno == errno.ENOENT:
+-                msg = _('%s is not installed') % package
+-                raise exception.NfsException(msg)
+-            else:
+-                raise
++        packages = ('mount.nfs', '/usr/sbin/mount')
++        for package in packages:
++            try:
++                self._execute(package, check_exit_code=False, run_as_root=True)
++                break
++            except OSError as exc:
++                if exc.errno != errno.ENOENT:
++                    raise
++                LOG.error(_LE('%s is not installed.'), package)
++        else:
++            msg = utils.build_or_str(packages, '%s needs to be installed.')
++            raise exception.NfsException(msg)
+ 
+         lcfg = self.configuration
+         LOG.info(_LI('Connecting to host: %s.'), lcfg.san_ip)
+