lvm.py (manila-8.1.3) | : | lvm.py (manila-8.1.4) | ||
---|---|---|---|---|
skipping to change at line 110 | skipping to change at line 110 | |||
# NOTE(vish): Next power of two for region size. See: | # NOTE(vish): Next power of two for region size. See: | |||
# http://red.ht/U2BPOD | # http://red.ht/U2BPOD | |||
cmd += ['-R', six.text_type(rsize)] | cmd += ['-R', six.text_type(rsize)] | |||
self._try_execute(*cmd, run_as_root=True) | self._try_execute(*cmd, run_as_root=True) | |||
device_name = self._get_local_path(share) | device_name = self._get_local_path(share) | |||
self._execute('mkfs.%s' % self.configuration.share_volume_fstype, | self._execute('mkfs.%s' % self.configuration.share_volume_fstype, | |||
device_name, run_as_root=True) | device_name, run_as_root=True) | |||
def _extend_container(self, share, device_name, size): | def _extend_container(self, share, device_name, size): | |||
cmd = ['lvextend', '-L', '%sG' % size, '-n', device_name] | cmd = ['lvextend', '-L', '%sG' % size, '-r', device_name] | |||
self._try_execute(*cmd, run_as_root=True) | self._try_execute(*cmd, run_as_root=True) | |||
def _deallocate_container(self, share_name): | def _deallocate_container(self, share_name): | |||
"""Deletes a logical volume for share.""" | """Deletes a logical volume for share.""" | |||
try: | try: | |||
self._try_execute('lvremove', '-f', "%s/%s" % | self._try_execute('lvremove', '-f', "%s/%s" % | |||
(self.configuration.lvm_share_volume_group, | (self.configuration.lvm_share_volume_group, | |||
share_name), run_as_root=True) | share_name), run_as_root=True) | |||
except exception.ProcessExecutionError as exc: | except exception.ProcessExecutionError as exc: | |||
if "not found" not in exc.stderr: | err_pattern = re.compile(".*failed to find.*|.*not found.*", | |||
re.IGNORECASE) | ||||
if not err_pattern.match(exc.stderr): | ||||
LOG.exception("Error deleting volume") | LOG.exception("Error deleting volume") | |||
raise | raise | |||
LOG.warning("Volume not found: %s", exc.stderr) | LOG.warning("Volume not found: %s", exc.stderr) | |||
def _create_snapshot(self, context, snapshot): | def _create_snapshot(self, context, snapshot): | |||
"""Creates a snapshot.""" | """Creates a snapshot.""" | |||
orig_lv_name = "%s/%s" % (self.configuration.lvm_share_volume_group, | orig_lv_name = "%s/%s" % (self.configuration.lvm_share_volume_group, | |||
snapshot['share_name']) | snapshot['share_name']) | |||
self._try_execute( | self._try_execute( | |||
'lvcreate', '-L', '%sG' % snapshot['share']['size'], | 'lvcreate', '-L', '%sG' % snapshot['share']['size'], | |||
skipping to change at line 270 | skipping to change at line 272 | |||
share_device_name = self._get_local_path(share) | share_device_name = self._get_local_path(share) | |||
self._set_random_uuid_to_device(share) | self._set_random_uuid_to_device(share) | |||
self._copy_volume( | self._copy_volume( | |||
snapshot_device_name, share_device_name, share['size']) | snapshot_device_name, share_device_name, share['size']) | |||
location = self._get_helper(share).create_exports( | location = self._get_helper(share).create_exports( | |||
self.share_server, share['name']) | self.share_server, share['name']) | |||
self._mount_device(share, share_device_name) | self._mount_device(share, share_device_name) | |||
return location | return location | |||
def delete_share(self, context, share, share_server=None): | def delete_share(self, context, share, share_server=None): | |||
self._unmount_device(share) | self._unmount_device(share, raise_if_missing=False) | |||
self._delete_share(context, share) | self._delete_share(context, share) | |||
self._deallocate_container(share['name']) | self._deallocate_container(share['name']) | |||
def _unmount_device(self, share_or_snapshot): | def _unmount_device(self, share_or_snapshot, raise_if_missing=True): | |||
"""Unmount the filesystem of a share or snapshot LV.""" | """Unmount the filesystem of a share or snapshot LV.""" | |||
mount_path = self._get_mount_path(share_or_snapshot) | mount_path = self._get_mount_path(share_or_snapshot) | |||
if os.path.exists(mount_path): | if os.path.exists(mount_path): | |||
# umount, may be busy | # umount, may be busy | |||
try: | try: | |||
self._execute('umount', '-f', mount_path, run_as_root=True) | self._execute('umount', '-f', mount_path, run_as_root=True) | |||
except exception.ProcessExecutionError as exc: | except exception.ProcessExecutionError as exc: | |||
if 'device is busy' in six.text_type(exc): | if 'device is busy' in exc.stderr.lower(): | |||
raise exception.ShareBusyException( | raise exception.ShareBusyException( | |||
reason=share_or_snapshot['name']) | reason=share_or_snapshot['name']) | |||
elif 'not mounted' in exc.stderr.lower(): | ||||
if raise_if_missing: | ||||
LOG.error('Unable to find device: %s', exc) | ||||
raise | ||||
else: | else: | |||
LOG.error('Unable to umount: %s', exc) | LOG.error('Unable to umount: %s', exc) | |||
raise | raise | |||
# remove dir | # remove dir | |||
self._execute('rmdir', mount_path, run_as_root=True) | self._execute('rmdir', mount_path, run_as_root=True) | |||
def ensure_shares(self, context, shares): | def ensure_shares(self, context, shares): | |||
updates = {} | updates = {} | |||
for share in shares: | for share in shares: | |||
updates[share['id']] = { | updates[share['id']] = { | |||
skipping to change at line 393 | skipping to change at line 399 | |||
extra_flags = [] | extra_flags = [] | |||
# Perform the copy | # Perform the copy | |||
self._execute('dd', 'if=%s' % srcstr, 'of=%s' % deststr, | self._execute('dd', 'if=%s' % srcstr, 'of=%s' % deststr, | |||
'count=%d' % (size_in_g * 1024), 'bs=1M', | 'count=%d' % (size_in_g * 1024), 'bs=1M', | |||
*extra_flags, run_as_root=True) | *extra_flags, run_as_root=True) | |||
def extend_share(self, share, new_size, share_server=None): | def extend_share(self, share, new_size, share_server=None): | |||
device_name = self._get_local_path(share) | device_name = self._get_local_path(share) | |||
self._extend_container(share, device_name, new_size) | self._extend_container(share, device_name, new_size) | |||
self._execute('resize2fs', device_name, run_as_root=True) | ||||
def revert_to_snapshot(self, context, snapshot, share_access_rules, | def revert_to_snapshot(self, context, snapshot, share_access_rules, | |||
snapshot_access_rules, share_server=None): | snapshot_access_rules, share_server=None): | |||
share = snapshot['share'] | share = snapshot['share'] | |||
# Temporarily remove all access rules | # Temporarily remove all access rules | |||
self._get_helper(share).update_access(self.share_server, | self._get_helper(share).update_access(self.share_server, | |||
snapshot['name'], [], [], []) | snapshot['name'], [], [], []) | |||
self._get_helper(share).update_access(self.share_server, | self._get_helper(share).update_access(self.share_server, | |||
share['name'], [], [], []) | share['name'], [], [], []) | |||
# Unmount the snapshot filesystem | # Unmount the snapshot filesystem | |||
skipping to change at line 444 | skipping to change at line 449 | |||
device_name = self._get_local_path(snapshot) | device_name = self._get_local_path(snapshot) | |||
self._mount_device(snapshot, device_name) | self._mount_device(snapshot, device_name) | |||
helper = self._get_helper(snapshot['share']) | helper = self._get_helper(snapshot['share']) | |||
exports = helper.create_exports(self.share_server, snapshot['name']) | exports = helper.create_exports(self.share_server, snapshot['name']) | |||
return {'export_locations': exports} | return {'export_locations': exports} | |||
def delete_snapshot(self, context, snapshot, share_server=None): | def delete_snapshot(self, context, snapshot, share_server=None): | |||
self._unmount_device(snapshot) | self._unmount_device(snapshot, raise_if_missing=False) | |||
super(LVMShareDriver, self).delete_snapshot(context, snapshot, | super(LVMShareDriver, self).delete_snapshot(context, snapshot, | |||
share_server) | share_server) | |||
def get_configured_ip_versions(self): | def get_configured_ip_versions(self): | |||
if self.configured_ip_version is None: | if self.configured_ip_version is None: | |||
try: | try: | |||
self.configured_ip_version = [] | self.configured_ip_version = [] | |||
if self.configuration.lvm_share_export_ip: | if self.configuration.lvm_share_export_ip: | |||
self.configured_ip_version.append(ipaddress.ip_address( | self.configured_ip_version.append(ipaddress.ip_address( | |||
End of changes. 8 change blocks. | ||||
7 lines changed or deleted | 12 lines changed or added |