summaryrefslogtreecommitdiff
path: root/daemons
diff options
context:
space:
mode:
authorVojtech Trefny <vtrefny@redhat.com>2020-01-06 11:28:41 +0100
committerTony Asleson <tasleson@redhat.com>2020-01-09 13:07:55 -0600
commitc496ba6505dda29bb1fb48b326cfd959ab0facd4 (patch)
treeffdb8d0c75fbf13e58ead54daf8cdbdee3894fa4 /daemons
parentc3ef41f620418bc9d5932fc6f7284a600e6cebec (diff)
downloadlvm2-c496ba6505dda29bb1fb48b326cfd959ab0facd4.tar.gz
lvmdbusd: Add function to convert LV into a VDO pool
Diffstat (limited to 'daemons')
-rw-r--r--daemons/lvmdbusd/cmdhandler.py8
-rw-r--r--daemons/lvmdbusd/vg.py32
2 files changed, 40 insertions, 0 deletions
diff --git a/daemons/lvmdbusd/cmdhandler.py b/daemons/lvmdbusd/cmdhandler.py
index aa5199f18..7d2f4c4ba 100644
--- a/daemons/lvmdbusd/cmdhandler.py
+++ b/daemons/lvmdbusd/cmdhandler.py
@@ -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))
diff --git a/daemons/lvmdbusd/vg.py b/daemons/lvmdbusd/vg.py
index 789626c98..51fd07e8c 100644
--- a/daemons/lvmdbusd/vg.py
+++ b/daemons/lvmdbusd/vg.py
@@ -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)