diff options
author | Vojtech Trefny <vtrefny@redhat.com> | 2019-12-27 15:29:15 +0100 |
---|---|---|
committer | Tony Asleson <tasleson@redhat.com> | 2020-01-09 13:07:47 -0600 |
commit | c3ef41f620418bc9d5932fc6f7284a600e6cebec (patch) | |
tree | 070e66f49d92310fe8ba041dbd4a72d998daf63e /daemons/lvmdbusd | |
parent | 87e88078c993a149af6d2f104998c508b7aee9be (diff) | |
download | lvm2-c3ef41f620418bc9d5932fc6f7284a600e6cebec.tar.gz |
lvmdbusd: Add VDO enable/disable compress & dedup
Added methods to vdo pool interface to allow enabling and
disabling of VDO:
* Compression
* Deduplication
Diffstat (limited to 'daemons/lvmdbusd')
-rw-r--r-- | daemons/lvmdbusd/cmdhandler.py | 22 | ||||
-rw-r--r-- | daemons/lvmdbusd/lv.py | 66 |
2 files changed, 88 insertions, 0 deletions
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py index e0bb10563..aa5199f18 100644 --- a/daemons/lvmdbusd/cmdhandler.py +++ b/daemons/lvmdbusd/cmdhandler.py @@ -460,6 +460,28 @@ def lv_detach_cache(lv_full_name, detach_options, destroy_cache): return call(cmd) +def lv_vdo_compression(lv_path, enable, comp_options): + cmd = ['lvchange', '--compression'] + if enable: + cmd.append('y') + else: + cmd.append('n') + cmd.extend(options_to_cli_args(comp_options)) + cmd.append(lv_path) + return call(cmd) + + +def lv_vdo_deduplication(lv_path, enable, dedup_options): + cmd = ['lvchange', '--deduplication'] + if enable: + cmd.append('y') + else: + cmd.append('n') + cmd.extend(options_to_cli_args(dedup_options)) + cmd.append(lv_path) + return call(cmd) + + def supports_json(): cmd = ['help'] rc, out, err = call(cmd) diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py index 301874955..fd46f348b 100644 --- a/daemons/lvmdbusd/lv.py +++ b/daemons/lvmdbusd/lv.py @@ -780,6 +780,72 @@ class LvVdoPool(Lv): def DataLv(self): return dbus.ObjectPath(self._data_lv) + @staticmethod + def _enable_disable_compression(pool_uuid, pool_name, enable, comp_options): + # Make sure we have a dbus object representing it + LvCommon.validate_dbus_object(pool_uuid, pool_name) + # Rename the logical volume + LvCommon.handle_execute(*cmdhandler.lv_vdo_compression( + pool_name, enable, comp_options)) + return '/' + + @dbus.service.method( + dbus_interface=VDO_POOL_INTERFACE, + in_signature='ia{sv}', + out_signature='o', + async_callbacks=('cb', 'cbe')) + def EnableCompression(self, tmo, comp_options, cb, cbe): + r = RequestEntry( + tmo, LvVdoPool._enable_disable_compression, + (self.Uuid, self.lvm_id, True, comp_options), + cb, cbe, False) + cfg.worker_q.put(r) + + @dbus.service.method( + dbus_interface=VDO_POOL_INTERFACE, + in_signature='ia{sv}', + out_signature='o', + async_callbacks=('cb', 'cbe')) + def DisableCompression(self, tmo, comp_options, cb, cbe): + r = RequestEntry( + tmo, LvVdoPool._enable_disable_compression, + (self.Uuid, self.lvm_id, False, comp_options), + cb, cbe, False) + cfg.worker_q.put(r) + + @staticmethod + def _enable_disable_deduplication(pool_uuid, pool_name, enable, dedup_options): + # Make sure we have a dbus object representing it + LvCommon.validate_dbus_object(pool_uuid, pool_name) + # Rename the logical volume + LvCommon.handle_execute(*cmdhandler.lv_vdo_deduplication( + pool_name, enable, dedup_options)) + return '/' + + @dbus.service.method( + dbus_interface=VDO_POOL_INTERFACE, + in_signature='ia{sv}', + out_signature='o', + async_callbacks=('cb', 'cbe')) + def EnableDeduplication(self, tmo, dedup_options, cb, cbe): + r = RequestEntry( + tmo, LvVdoPool._enable_disable_deduplication, + (self.Uuid, self.lvm_id, True, dedup_options), + cb, cbe, False) + cfg.worker_q.put(r) + + @dbus.service.method( + dbus_interface=VDO_POOL_INTERFACE, + in_signature='ia{sv}', + out_signature='o', + async_callbacks=('cb', 'cbe')) + def DisableDeduplication(self, tmo, dedup_options, cb, cbe): + r = RequestEntry( + tmo, LvVdoPool._enable_disable_deduplication, + (self.Uuid, self.lvm_id, False, dedup_options), + cb, cbe, False) + cfg.worker_q.put(r) + # noinspection PyPep8Naming class LvThinPool(Lv): |