mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmdbusd: Add function to convert LV into a VDO pool
This commit is contained in:
parent
c3ef41f620
commit
c496ba6505
@ -398,6 +398,14 @@ def vg_create_vdo_pool_lv_and_lv(vg_name, pool_name, lv_name, data_size,
|
||||
return call(cmd)
|
||||
|
||||
|
||||
def vg_create_vdo_pool(pool_full_name, lv_name, virtual_size, create_options):
|
||||
cmd = ['lvconvert']
|
||||
cmd.extend(options_to_cli_args(create_options))
|
||||
cmd.extend(['--type', 'vdo-pool', '-n', lv_name, '--force', '-y',
|
||||
'-V', '%dB' % virtual_size, pool_full_name])
|
||||
return call(cmd)
|
||||
|
||||
|
||||
def lv_remove(lv_path, remove_options):
|
||||
cmd = ['lvremove']
|
||||
cmd.extend(options_to_cli_args(remove_options))
|
||||
|
@ -813,3 +813,35 @@ class VgVdo(Vg):
|
||||
round_size(virtual_size),
|
||||
create_options), cb, cbe)
|
||||
cfg.worker_q.put(r)
|
||||
|
||||
@staticmethod
|
||||
def _vdo_pool_create(uuid, vg_name, pool_lv, name, virtual_size, create_options):
|
||||
Vg.validate_dbus_object(uuid, vg_name)
|
||||
|
||||
# Retrieve the full name of the pool lv
|
||||
pool = cfg.om.get_object_by_path(pool_lv)
|
||||
if not pool:
|
||||
msg = 'LV with object path %s not present!' % \
|
||||
(pool_lv)
|
||||
raise dbus.exceptions.DBusException(VG_VDO_INTERFACE, msg)
|
||||
|
||||
Vg.handle_execute(*cmdhandler.vg_create_vdo_pool(
|
||||
pool.lv_full_name(), name, virtual_size,
|
||||
create_options))
|
||||
return Vg.fetch_new_lv(vg_name, pool.Name)
|
||||
|
||||
@dbus.service.method(
|
||||
dbus_interface=VG_VDO_INTERFACE,
|
||||
in_signature='ostia{sv}',
|
||||
out_signature='(oo)',
|
||||
async_callbacks=('cb', 'cbe'))
|
||||
def CreateVdoPool(self, pool_lv, name, virtual_size,
|
||||
tmo, create_options, cb, cbe):
|
||||
utils.validate_lv_name(VG_VDO_INTERFACE, self.Name, name)
|
||||
|
||||
r = RequestEntry(tmo, VgVdo._vdo_pool_create,
|
||||
(self.state.Uuid, self.state.lvm_id,
|
||||
pool_lv, name,
|
||||
round_size(virtual_size),
|
||||
create_options), cb, cbe)
|
||||
cfg.worker_q.put(r)
|
||||
|
@ -1903,6 +1903,44 @@ class TestDbusService(unittest.TestCase):
|
||||
vg, _, _ = self._create_vdo_pool_and_lv()
|
||||
self.handle_return(vg.Vg.Remove(dbus.Int32(g_tmo), EOD))
|
||||
|
||||
def _create_vdo_pool(self):
|
||||
pool_name = lv_n('_vdo_pool')
|
||||
lv_name = lv_n('_vdo_data')
|
||||
vg_proxy = self._vg_create(vg_prefix="vdo_conv_")
|
||||
lv = self._test_lv_create(
|
||||
vg_proxy.Vg.LvCreate,
|
||||
(dbus.String(pool_name), dbus.UInt64(mib(4096)),
|
||||
dbus.Array([], signature='(ott)'), dbus.Int32(g_tmo),
|
||||
EOD), vg_proxy.Vg, LV_BASE_INT)
|
||||
lv_obj_path = self._lookup("%s/%s" % (vg_proxy.Vg.Name, pool_name))
|
||||
self.assertNotEqual(lv_obj_path, "/")
|
||||
|
||||
vdo_pool_path = self.handle_return(
|
||||
vg_proxy.VgVdo.CreateVdoPool(
|
||||
dbus.ObjectPath(lv.object_path), lv_name,
|
||||
dbus.UInt64(mib(8192)),
|
||||
dbus.Int32(g_tmo),
|
||||
EOD))
|
||||
|
||||
self.assertNotEqual(vdo_pool_path, "/")
|
||||
self.assertEqual(
|
||||
vdo_pool_path,
|
||||
self._lookup("%s/%s" % (vg_proxy.Vg.Name, pool_name)))
|
||||
intf = [LV_COMMON_INT, LV_INT]
|
||||
vdo_lv_obj_path = self._lookup("%s/%s" % (vg_proxy.Vg.Name, lv_name))
|
||||
vdo_lv = ClientProxy(self.bus, vdo_lv_obj_path, interfaces=intf)
|
||||
intf.append(VDOPOOL_INT)
|
||||
vdo_pool_lv = ClientProxy(self.bus, vdo_pool_path, interfaces=intf)
|
||||
return vg_proxy, vdo_pool_lv, vdo_lv
|
||||
|
||||
def test_vdo_pool_convert(self):
|
||||
# Basic vdo sanity testing
|
||||
if not self.vdo:
|
||||
raise unittest.SkipTest('vdo not supported')
|
||||
|
||||
vg, _pool, _lv = self._create_vdo_pool()
|
||||
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')
|
||||
|
Loading…
Reference in New Issue
Block a user