From ec6eaa21fd08cb7e6fa950e303a626a99580ec89 Mon Sep 17 00:00:00 2001 From: Charles Short Date: Wed, 30 Jan 2019 13:14:09 -0500 Subject: [PATCH] Replace 'lvconvert' from rootwrap Use oslo.privsep to run the lvconvert command. Change-Id: I6c2dce7beb1c3f8bb777066f62ced134f763e640 Signed-off-by: Charles Short --- cinder/brick/local_dev/lvm.py | 4 +--- cinder/privsep/lvm.py | 6 ++++++ etc/cinder/rootwrap.d/volume.filters | 3 --- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cinder/brick/local_dev/lvm.py b/cinder/brick/local_dev/lvm.py index 4231bf7f5bb..4f929fd88bb 100644 --- a/cinder/brick/local_dev/lvm.py +++ b/cinder/brick/local_dev/lvm.py @@ -747,10 +747,8 @@ class LVM(executor.Executor): :param snapshot_name: Name of snapshot to revert """ - cmd = ['lvconvert', '--merge', '%s/%s' % (self.vg_name, snapshot_name)] try: - self._execute(*cmd, root_helper=self._root_helper, - run_as_root=True) + cinder.privsep.lvm.lvconvert(self.vg_name, snapshot_name) except putils.ProcessExecutionError as err: LOG.exception('Error Revert Volume') LOG.error('Cmd :%s', err.cmd) diff --git a/cinder/privsep/lvm.py b/cinder/privsep/lvm.py index cfa48af57cd..2da0659d295 100644 --- a/cinder/privsep/lvm.py +++ b/cinder/privsep/lvm.py @@ -36,3 +36,9 @@ def lvrename(vg_name, lv_name, new_name): def create_vg(vg_name, pv_list): cmd = ['vgcreate', vg_name, ','.join(pv_list)] processutils.execute(*cmd) + + +@cinder.privsep.sys_admin_pctxt.entrypoint +def lvconvert(vg_name, snapshot_name): + processutils.execute( + 'lvconvert', '--merge', '%s/%s' % (vg_name, snapshot_name)) diff --git a/etc/cinder/rootwrap.d/volume.filters b/etc/cinder/rootwrap.d/volume.filters index cdd9b084f15..19bf5869845 100644 --- a/etc/cinder/rootwrap.d/volume.filters +++ b/etc/cinder/rootwrap.d/volume.filters @@ -68,9 +68,6 @@ lvextend_lvmconf_fdwarn: EnvFilter, env, root, LVM_SYSTEM_DIR=, LC_ALL=C, LVM_SU # cinder/brick/local_dev/lvm.py: 'lvchange -a y -K ' lvchange: CommandFilter, lvchange, root -# cinder/brick/local_dev/lvm.py: 'lvconvert', '--merge', snapshot_name -lvconvert: CommandFilter, lvconvert, root - # cinder/volume/driver.py: 'iscsiadm', '-m', 'discovery', '-t',... # cinder/volume/driver.py: 'iscsiadm', '-m', 'node', '-T', ... iscsiadm: CommandFilter, iscsiadm, root