From 5ef160ca7511ca92d8735cfca7bd176dee8ed995 Mon Sep 17 00:00:00 2001 From: zengyingzhe Date: Thu, 28 Dec 2017 14:23:36 +0800 Subject: [PATCH] Change a parameter key for CIFS mounting command While Huawei driver mounting CIFS filesystem, the username parameter key passed to the mount command is by the form of "user=***", which's compatible as "username=***" in Ubuntu. However, for some other systems, such as Redhat, it is not valid. This patch changes it to the more compatible form "username=***". Change-Id: Ifa2ca7bcdceef2d47e2841a27ddf51d86f1ef63c Closes-Bug: #1740816 --- manila/share/drivers/huawei/v3/connection.py | 2 +- .../share/drivers/huawei/test_huawei_nas.py | 24 +++++++++++++++++++ ...ver-cifs-mount-issue-2d7bff5a7e6e3ad6.yaml | 5 ++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-huawei-driver-cifs-mount-issue-2d7bff5a7e6e3ad6.yaml diff --git a/manila/share/drivers/huawei/v3/connection.py b/manila/share/drivers/huawei/v3/connection.py index 074fc8831b..42a190b42a 100644 --- a/manila/share/drivers/huawei/v3/connection.py +++ b/manila/share/drivers/huawei/v3/connection.py @@ -601,7 +601,7 @@ class V3StorageConnection(driver.HuaweiBase): share['mount_src']) elif share['share_proto'] == 'CIFS': - user = ('user=' + access['access_to'] + ',' + + user = ('username=' + access['access_to'] + ',' + 'password=' + access['access_password']) utils.execute('mount', '-t', 'cifs', share['mount_path'], share['mount_src'], diff --git a/manila/tests/share/drivers/huawei/test_huawei_nas.py b/manila/tests/share/drivers/huawei/test_huawei_nas.py index cda6c1f831..eee45054ea 100644 --- a/manila/tests/share/drivers/huawei/test_huawei_nas.py +++ b/manila/tests/share/drivers/huawei/test_huawei_nas.py @@ -4600,6 +4600,30 @@ class HuaweiShareDriverTestCase(test.TestCase): self.driver.revert_to_snapshot, None, snapshot, None, None) + @ddt.data({'name': 'fake_name', + 'share_proto': 'NFS', + 'mount_path': 'fake_nfs_mount_path', + 'mount_src': '/mnt/test'}, + {'name': 'fake_name', + 'share_proto': 'CIFS', + 'mount_path': 'fake_cifs_mount_path', + 'mount_src': '/mnt/test'}, + ) + def test_mount_share_to_host(self, share): + access = {'access_to': 'cifs_user', + 'access_password': 'cifs_password'} + mocker = self.mock_object(utils, 'execute') + self.driver.plugin.mount_share_to_host(share, access) + if share['share_proto'] == 'NFS': + mocker.assert_called_once_with( + 'mount', '-t', 'nfs', 'fake_nfs_mount_path', '/mnt/test', + run_as_root=True) + else: + mocker.assert_called_once_with( + 'mount', '-t', 'cifs', 'fake_cifs_mount_path', '/mnt/test', + '-o', 'username=cifs_user,password=cifs_password', + run_as_root=True) + @ddt.ddt class HuaweiDriverHelperTestCase(test.TestCase): diff --git a/releasenotes/notes/fix-huawei-driver-cifs-mount-issue-2d7bff5a7e6e3ad6.yaml b/releasenotes/notes/fix-huawei-driver-cifs-mount-issue-2d7bff5a7e6e3ad6.yaml new file mode 100644 index 0000000000..70a2b072b5 --- /dev/null +++ b/releasenotes/notes/fix-huawei-driver-cifs-mount-issue-2d7bff5a7e6e3ad6.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Change the CIFS mounting parameter of Huawei driver from form "user=" to + "username=", which is compatible in various OS.