1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

lvmdbusd: cmdhandler.py, remove duplicate code

Move similar code to common functions, less is more!
This commit is contained in:
Tony Asleson 2017-02-01 19:05:41 -06:00
parent 3eccbb4b47
commit 875ce04c61

View File

@ -295,7 +295,7 @@ def vg_lv_snapshot(vg_name, snapshot_options, name, size_bytes):
return call(cmd) return call(cmd)
def vg_lv_create_linear(vg_name, create_options, name, size_bytes, thin_pool): def _vg_lv_create_common_cmd(create_options, size_bytes, thin_pool):
cmd = ['lvcreate'] cmd = ['lvcreate']
cmd.extend(options_to_cli_args(create_options)) cmd.extend(options_to_cli_args(create_options))
@ -303,20 +303,18 @@ def vg_lv_create_linear(vg_name, create_options, name, size_bytes, thin_pool):
cmd.extend(['--size', str(size_bytes) + 'B']) cmd.extend(['--size', str(size_bytes) + 'B'])
else: else:
cmd.extend(['--thin', '--size', str(size_bytes) + 'B']) cmd.extend(['--thin', '--size', str(size_bytes) + 'B'])
return cmd
def vg_lv_create_linear(vg_name, create_options, name, size_bytes, thin_pool):
cmd = _vg_lv_create_common_cmd(create_options, size_bytes, thin_pool)
cmd.extend(['--name', name, vg_name]) cmd.extend(['--name', name, vg_name])
return call(cmd) return call(cmd)
def vg_lv_create_striped(vg_name, create_options, name, size_bytes, def vg_lv_create_striped(vg_name, create_options, name, size_bytes,
num_stripes, stripe_size_kb, thin_pool): num_stripes, stripe_size_kb, thin_pool):
cmd = ['lvcreate'] cmd = _vg_lv_create_common_cmd(create_options, size_bytes, thin_pool)
cmd.extend(options_to_cli_args(create_options))
if not thin_pool:
cmd.extend(['--size', str(size_bytes) + 'B'])
else:
cmd.extend(['--thin', '--size', str(size_bytes) + 'B'])
cmd.extend(['--stripes', str(num_stripes)]) cmd.extend(['--stripes', str(num_stripes)])
if stripe_size_kb != 0: if stripe_size_kb != 0: