]> sourceware.org Git - lvm2.git/commitdiff
lvmdbusd: Add VDO enable/disable compress & dedup
authorVojtech Trefny <vtrefny@redhat.com>
Fri, 27 Dec 2019 14:29:15 +0000 (15:29 +0100)
committerTony Asleson <tasleson@redhat.com>
Thu, 9 Jan 2020 19:07:47 +0000 (13:07 -0600)
Added methods to vdo pool interface to allow enabling and
disabling of VDO:
 * Compression
 * Deduplication

daemons/lvmdbusd/cmdhandler.py
daemons/lvmdbusd/lv.py
test/dbus/lvmdbustest.py

index e0bb105631a88a9c18c6ebba621a9624c6b18aff..aa5199f18574d602a3cd3ba75f6ce14d3eed75c8 100644 (file)
@@ -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)
index 301874955e9ec4f11f7375e1dd468925a21df0e7..fd46f348b6a84c9e4d54668dd47892819d6c7164 100644 (file)
@@ -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):
index 82159685d73c5745d346068939b0fb6be91e8acf..b819a049e743150282e6ac1f9ae53ed94238e5b0 100755 (executable)
@@ -1858,11 +1858,11 @@ class TestDbusService(unittest.TestCase):
                self.assertEqual(pv_object_path, self._lookup(symlink))
                self.assertEqual(pv_object_path, self._lookup(pv_device_path))
 
-       def _create_vdo_pool_and_lv(self):
+       def _create_vdo_pool_and_lv(self, vg_prefix="vdo_"):
                pool_name = lv_n("_vdo_pool")
                lv_name = lv_n()
 
-               vg_proxy = self._vg_create(vg_prefix="vdo_")
+               vg_proxy = self._vg_create(vg_prefix=vg_prefix)
                vdo_pool_object_path = self.handle_return(
                        vg_proxy.VgVdo.CreateVdoPoolandLv(
                                pool_name, lv_name,
@@ -1903,6 +1903,34 @@ class TestDbusService(unittest.TestCase):
                        vg, _, _ = self._create_vdo_pool_and_lv()
                        self.handle_return(vg.Vg.Remove(dbus.Int32(g_tmo), EOD))
 
+       def test_vdo_pool_compression_deduplication(self):
+               if not self.vdo:
+                       raise unittest.SkipTest('vdo not supported')
+
+               vg, pool, _lv = self._create_vdo_pool_and_lv(vg_prefix="vdo2_")
+
+               # compression and deduplication should be enabled by default
+               self.assertEqual(pool.VdoPool.Compression, "enabled")
+               self.assertEqual(pool.VdoPool.Deduplication, "enabled")
+
+               self.handle_return(
+                       pool.VdoPool.DisableCompression(dbus.Int32(g_tmo), EOD))
+               self.handle_return(
+                       pool.VdoPool.DisableDeduplication(dbus.Int32(g_tmo), EOD))
+               pool.update()
+               self.assertEqual(pool.VdoPool.Compression, "")
+               self.assertEqual(pool.VdoPool.Deduplication, "")
+
+               self.handle_return(
+                       pool.VdoPool.EnableCompression(dbus.Int32(g_tmo), EOD))
+               self.handle_return(
+                       pool.VdoPool.EnableDeduplication(dbus.Int32(g_tmo), EOD))
+               pool.update()
+               self.assertEqual(pool.VdoPool.Compression, "enabled")
+               self.assertEqual(pool.VdoPool.Deduplication, "enabled")
+
+               self.handle_return(vg.Vg.Remove(dbus.Int32(g_tmo), EOD))
+
        def _test_lv_method_interface(self, lv):
                self._rename_lv_test(lv)
                self._test_activate_deactivate(lv)
This page took 0.041111 seconds and 5 git commands to generate.