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
This commit is contained in:
Ramana Raja 2016-03-30 13:53:36 +05:30
parent a36ff17041
commit cbb316babf
2 changed files with 12 additions and 7 deletions

View File

@ -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'])

View File

@ -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"},