From cbb316babf1648f46c7e31e6415470df29dd5377 Mon Sep 17 00:00:00 2001 From: Ramana Raja Date: Wed, 30 Mar 2016 13:53:36 +0530 Subject: [PATCH] cephfs_native: Change backend snapshot dir's name A snapshot of a share created by cephfs_native driver can be read from its corresponding snapshot directory created within the share. The snapshot directory was named using the snapshot instance ID, which would be visible only to manila admins. In effect, a non-admin manila user could not identify the snapshot directory (in the mounted share) from where he could read the snapshot's contents. Fix by creating ceph snapshot directories with names that also contain snapshot IDs that are visible to all users. Change-Id: Ifda0300c60fca87a3f993c1f2eaeb05d1dd909d4 Closes-Bug: #1563198 --- manila/share/drivers/cephfs/cephfs_native.py | 9 ++++++--- .../tests/share/drivers/cephfs/test_cephfs_native.py | 10 ++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/manila/share/drivers/cephfs/cephfs_native.py b/manila/share/drivers/cephfs/cephfs_native.py index 5eb6f70155..32c9b4319d 100644 --- a/manila/share/drivers/cephfs/cephfs_native.py +++ b/manila/share/drivers/cephfs/cephfs_native.py @@ -227,7 +227,8 @@ class CephFSNativeDriver(driver.ShareDriver,): self.volume_client.deauthorize(self._share_path(share), access['access_to']) - self.volume_client.evict(access['access_to']) + self.volume_client.evict(self._share_path(share), + access['access_to']) def update_access(self, context, share, access_rules, add_rules, delete_rules, share_server=None): @@ -287,11 +288,13 @@ class CephFSNativeDriver(driver.ShareDriver,): def create_snapshot(self, context, snapshot, share_server=None): self.volume_client.create_snapshot_volume( - self._share_path(snapshot['share']), snapshot['name']) + self._share_path(snapshot['share']), + '_'.join([snapshot['snapshot_id'], snapshot['id']])) def delete_snapshot(self, context, snapshot, share_server=None): self.volume_client.destroy_snapshot_volume( - self._share_path(snapshot['share']), snapshot['name']) + self._share_path(snapshot['share']), + '_'.join([snapshot['snapshot_id'], snapshot['id']])) def create_consistency_group(self, context, cg_dict, share_server=None): self.volume_client.create_group(cg_dict['id']) diff --git a/manila/tests/share/drivers/cephfs/test_cephfs_native.py b/manila/tests/share/drivers/cephfs/test_cephfs_native.py index 8630f7660d..d95dab3d27 100644 --- a/manila/tests/share/drivers/cephfs/test_cephfs_native.py +++ b/manila/tests/share/drivers/cephfs/test_cephfs_native.py @@ -277,28 +277,30 @@ class CephFSNativeDriverTestCase(test.TestCase): def test_create_snapshot(self): self._driver.create_snapshot(self._context, { + "id": "instance1", "share": self._share, - "name": "snappy1" + "snapshot_id": "snappy1" }, None) (self._driver._volume_client.create_snapshot_volume .assert_called_once_with( self._driver._share_path(self._share), - "snappy1")) + "snappy1_instance1")) def test_delete_snapshot(self): self._driver.delete_snapshot(self._context, { + "id": "instance1", "share": self._share, - "name": "snappy1" + "snapshot_id": "snappy1" }, None) (self._driver._volume_client.destroy_snapshot_volume .assert_called_once_with( self._driver._share_path(self._share), - "snappy1")) + "snappy1_instance1")) def test_create_consistency_group(self): self._driver.create_consistency_group(self._context, {"id": "grp1"},