def test_create_cloned_volume(self):
(mox, drv) = self._mox, self._driver
- mox.StubOutWithMock(drv, 'create_snapshot')
- mox.StubOutWithMock(drv, 'delete_snapshot')
+ mox.StubOutWithMock(drv, '_create_snapshot')
+ mox.StubOutWithMock(drv, '_delete_snapshot')
mox.StubOutWithMock(drv, '_read_info_file')
mox.StubOutWithMock(image_utils, 'convert_image')
mox.StubOutWithMock(drv, '_copy_volume_from_snapshot')
'id': 'tmp-snap-%s' % src_vref['id'],
'volume': src_vref}
- drv.create_snapshot(snap_ref)
+ drv._create_snapshot(snap_ref)
snap_info = {'active': volume_file,
snap_ref['id']: volume_path + '-clone'}
drv._copy_volume_from_snapshot(snap_ref, volume_ref, volume['size'])
- drv.delete_snapshot(mox_lib.IgnoreArg())
+ drv._delete_snapshot(mox_lib.IgnoreArg())
mox.ReplayAll()
volume = self._simple_volume('c1073000-0000-0000-0000-0000000c1073')
src_volume = self._simple_volume()
- mox.StubOutWithMock(drv, 'create_snapshot')
+ mox.StubOutWithMock(drv, '_create_snapshot')
mox.StubOutWithMock(drv, '_copy_volume_from_snapshot')
- mox.StubOutWithMock(drv, 'delete_snapshot')
+ mox.StubOutWithMock(drv, '_delete_snapshot')
snap_ref = {'volume_name': src_volume['name'],
'name': 'clone-snap-%s' % src_volume['id'],
'provider_location': volume['provider_location'],
'name': 'volume-' + volume['id']}
- drv.create_snapshot(snap_ref)
+ drv._create_snapshot(snap_ref)
drv._copy_volume_from_snapshot(snap_ref,
volume_ref,
src_volume['size'])
- drv.delete_snapshot(snap_ref)
+ drv._delete_snapshot(snap_ref)
mox.ReplayAll()
'volume_id': src_vref['id'],
'id': 'tmp-snap-%s' % src_vref['id'],
'volume': src_vref}
- self.create_snapshot(temp_snapshot)
+ self._create_snapshot(temp_snapshot)
try:
self._copy_volume_from_snapshot(temp_snapshot,
volume_info,
src_vref['size'])
finally:
- self.delete_snapshot(temp_snapshot)
+ self._delete_snapshot(temp_snapshot)
return {'provider_location': src_vref['provider_location']}
return {'provider_location': volume['provider_location']}
+ @utils.synchronized('glusterfs', external=False)
def create_volume_from_snapshot(self, volume, snapshot):
"""Creates a volume from a snapshot.
@utils.synchronized('glusterfs', external=False)
def create_snapshot(self, snapshot):
+ """Apply locking to the create snapshot operation."""
+
+ return self._create_snapshot(snapshot)
+
+ def _create_snapshot(self, snapshot):
"""Create a snapshot.
If volume is attached, call to Nova to create snapshot,
LOG.debug(_('volume id: %s') % snapshot['volume_id'])
path_to_disk = self._local_path_volume(snapshot['volume'])
- self._create_snapshot(snapshot, path_to_disk)
+ self._create_snapshot_offline(snapshot, path_to_disk)
def _create_qcow2_snap_file(self, snapshot, backing_filename,
new_snap_path):
new_snap_path]
self._execute(*command, run_as_root=True)
- def _create_snapshot(self, snapshot, path_to_disk):
+ def _create_snapshot_offline(self, snapshot, path_to_disk):
"""Create snapshot (offline case)."""
# Requires volume status = 'available'
@utils.synchronized('glusterfs', external=False)
def delete_snapshot(self, snapshot):
+ """Apply locking to the delete snapshot operation."""
+ self._delete_snapshot(snapshot)
+
+ def _delete_snapshot(self, snapshot):
"""Delete a snapshot.
If volume status is 'available', delete snapshot here in Cinder