backing file: %s
""" % (volume['name'], new_vol_size, new_vol_size * units.GiB, volpath)
mox.StubOutWithMock(image_utils, 'resize_image')
- image_utils.resize_image(volpath, new_vol_size)
+ image_utils.resize_image(volpath, new_vol_size, run_as_root=True)
mox.StubOutWithMock(image_utils, 'qemu_img_info')
img_info = imageutils.QemuImgInfo(qemu_img_info_output)
volpath = os.path.join(self.volumes_path, volume['name'])
mox.StubOutWithMock(image_utils, 'resize_image')
- image_utils.resize_image(volpath, new_vol_size).AndRaise(
- processutils.ProcessExecutionError('error'))
+ image_utils.resize_image(volpath, new_vol_size, run_as_root=True).\
+ AndRaise(processutils.ProcessExecutionError('error'))
mox.ReplayAll()
self.assertRaises(exception.VolumeBackendAPIException,
data.virtual_size = 1 * units.GiB
return data
- def _fake_qemu_image_resize(self, path, size):
- LOG.info('wtf')
+ def _fake_qemu_image_resize(self, path, size, run_as_root=False):
pass
def _fake_delete_gpfs_file(self, fchild):
return True
return False
+ def _set_rw_permission(self, path, modebits='660'):
+ """Set permission bits for the path."""
+ self._execute('chmod', modebits, path, run_as_root=True)
+
def check_for_setup_error(self):
"""Returns an error if prerequisites aren't met."""
self._check_gpfs_state()
sizestr = self._sizestr(size)
self._execute('truncate', '-s', sizestr, path, run_as_root=True)
- self._execute('chmod', '666', path, run_as_root=True)
def _allocate_file_blocks(self, path, size):
"""Preallocate file blocks by writing zeros."""
# Create a sparse file first; allocate blocks later if requested
self._create_sparse_file(volume_path, volume_size)
-
+ self._set_rw_permission(volume_path)
# Set the attributes prior to allocating any blocks so that
# they are allocated according to the policy
v_metadata = volume.get('volume_metadata')
volume_path = self.local_path(volume)
snapshot_path = self.local_path(snapshot)
self._create_gpfs_copy(src=snapshot_path, dest=volume_path)
+ self._set_rw_permission(volume_path)
self._gpfs_redirect(volume_path)
virt_size = self._resize_volume_file(volume, volume['size'])
return {'size': math.ceil(virt_size / units.GiB)}
src = self.local_path(src_vref)
dest = self.local_path(volume)
self._create_gpfs_clone(src, dest)
+ self._set_rw_permission(dest)
virt_size = self._resize_volume_file(volume, volume['size'])
return {'size': math.ceil(virt_size / units.GiB)}
if(self._gpfs_redirect(src) and self._gpfs_redirect(dest)):
self._execute('rm', '-f', snap, run_as_root=True)
- def _create_gpfs_copy(self, src, dest, modebits='666'):
+ def _create_gpfs_copy(self, src, dest):
self._execute('mmclone', 'copy', src, dest, run_as_root=True)
- self._execute('chmod', modebits, dest, run_as_root=True)
- def _create_gpfs_snap(self, src, dest=None, modebits='644'):
+ def _create_gpfs_snap(self, src, dest=None):
if dest is None:
self._execute('mmclone', 'snap', src, run_as_root=True)
- self._execute('chmod', modebits, src, run_as_root=True)
else:
self._execute('mmclone', 'snap', src, dest, run_as_root=True)
- self._execute('chmod', modebits, dest, run_as_root=True)
def _is_gpfs_parent_file(self, gpfs_file):
out, _ = self._execute('mmclone', 'show', gpfs_file, run_as_root=True)
volume_path = os.path.join(self.configuration.gpfs_mount_point_base,
snapshot['volume_name'])
self._create_gpfs_snap(src=volume_path, dest=snapshot_path)
+ self._set_rw_permission(snapshot_path, modebits='640')
self._gpfs_redirect(volume_path)
def delete_snapshot(self, snapshot):
vol_path = self.local_path(volume)
# if the image is not already a GPFS snap file make it so
if not self._is_gpfs_parent_file(image_path):
- self._create_gpfs_snap(image_path, modebits='666')
+ self._create_gpfs_snap(image_path)
data = image_utils.qemu_img_info(image_path)
LOG.debug('Clone image to vol %s using copyfile' %
volume['id'])
shutil.copyfile(image_path, vol_path)
- self._execute('chmod', '666', vol_path, run_as_root=True)
# if image is not raw convert it to raw into vol_path destination
else:
LOG.debug('Clone image to vol %s using qemu convert' %
volume['id'])
image_utils.convert_image(image_path, vol_path, 'raw')
- self._execute('chmod', '666', vol_path, run_as_root=True)
+ self._set_rw_permission(vol_path)
self._resize_volume_file(volume, volume['size'])
return {'provider_location': None}, True
"""Resize volume file to new size."""
vol_path = self.local_path(volume)
try:
- image_utils.resize_image(vol_path, new_size)
+ image_utils.resize_image(vol_path, new_size, run_as_root=True)
except processutils.ProcessExecutionError as exc:
LOG.error(_("Failed to resize volume "
"%(volume_id)s, error: %(error)s") %