master - lvmdbustest.py: Add function for lv path check
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b8d496911765ec07f80...
Commit: b8d496911765ec07f80eee174623e503506e7401
Parent: 22a22a735fef7bcd0f1acc80e99f500925e3572c
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Oct 3 15:19:51 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbustest.py: Add function for lv path check
---
test/dbus/lvmdbustest.py | 55 +++++++++++++++++++--------------------------
1 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 0384d5e..1ab4ce6 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -489,6 +489,26 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(path == '/')
self._check_consistency()
+ def _verify_lv_paths(self, vg, new_name):
+ """
+ # Go through each LV and make sure it has the correct path back to the
+ # VG
+ :return:
+ """
+ lv_paths = vg.Lvs
+
+ for l in lv_paths:
+ lv_proxy = ClientProxy(self.bus, l,
+ interfaces=(LV_COMMON_INT,)).LvCommon
+ self.assertTrue(
+ lv_proxy.Vg == vg.object_path, "%s != %s" %
+ (lv_proxy.Vg, vg.object_path))
+ full_name = "%s/%s" % (new_name, lv_proxy.Name)
+ lv_path = self._lookup(full_name)
+ self.assertTrue(
+ lv_path == lv_proxy.object_path, "%s != %s" %
+ (lv_path, lv_proxy.object_path))
+
# noinspection PyUnresolvedReferences
def test_vg_rename(self):
vg = self._vg_create().Vg
@@ -524,20 +544,8 @@ class TestDbusService(unittest.TestCase):
# VG
vg.update()
- lv_paths = vg.Lvs
- self.assertTrue(len(lv_paths) == 5)
-
- for l in lv_paths:
- lv_proxy = ClientProxy(self.bus, l,
- interfaces=(LV_COMMON_INT,)).LvCommon
- self.assertTrue(
- lv_proxy.Vg == vg.object_path, "%s != %s" %
- (lv_proxy.Vg, vg.object_path))
- full_name = "%s/%s" % (new_name, lv_proxy.Name)
- lv_path = self._lookup(full_name)
- self.assertTrue(
- lv_path == lv_proxy.object_path, "%s != %s" %
- (lv_path, lv_proxy.object_path))
+ self.assertTrue(len(vg.Lvs) == 5)
+ self._verify_lv_paths(vg, new_name)
def _verify_hidden_lookups(self, lv_common_object, vgname):
hidden_lv_paths = lv_common_object.HiddenLvs
@@ -602,26 +610,9 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(path == '/')
self._check_consistency()
- # Go through each LV and make sure it has the correct path back to the
- # VG
vg.update()
thin_pool.update()
-
- lv_paths = vg.Lvs
-
- for l in lv_paths:
- lv_proxy = ClientProxy(self.bus, l,
- interfaces=(LV_COMMON_INT,)).LvCommon
- self.assertTrue(
- lv_proxy.Vg == vg.object_path, "%s != %s" %
- (lv_proxy.Vg, vg.object_path))
- full_name = "%s/%s" % (new_name, lv_proxy.Name)
- # print('Full Name %s' % (full_name))
- lv_path = self._lookup(full_name)
- self.assertTrue(
- lv_path == lv_proxy.object_path, "%s != %s" %
- (lv_path, lv_proxy.object_path))
-
+ self._verify_lv_paths(vg, new_name)
# noinspection PyTypeChecker
self._verify_hidden_lookups(thin_pool.LvCommon, new_name)
4 years, 6 months
master - lvmdbusdtest.py: Use common function for tag add
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=22a22a735fef7bcd0f1...
Commit: 22a22a735fef7bcd0f1acc80e99f500925e3572c
Parent: 62136c056a506568ede876ce41e826478399085b
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Oct 3 15:05:37 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbusdtest.py: Use common function for tag add
---
test/dbus/lvmdbustest.py | 40 +++++++++++++++-------------------------
1 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index da1fc69..0384d5e 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1715,23 +1715,25 @@ class TestDbusService(unittest.TestCase):
dbus.Int32(g_tmo),
EOD))
+ def _tag_add_common(self, vg_proxy, tag):
+ tmp = self.handle_return(
+ vg_proxy.Vg.TagsAdd(
+ dbus.Array([tag], 's'),
+ dbus.Int32(g_tmo),
+ EOD))
+ self.assertTrue(tmp == '/')
+ vg_proxy.update()
+
+ self.assertTrue(
+ tag in vg_proxy.Vg.Tags,
+ "%s not in %s" % (tag, str(vg_proxy.Vg.Tags)))
+
def test_tag_names(self):
vg_proxy = self._vg_create()
for i in range(1, 64):
tag = rs(i, "", self._ALLOWABLE_TAG_CH)
-
- tmp = self.handle_return(
- vg_proxy.Vg.TagsAdd(
- dbus.Array([tag], 's'),
- dbus.Int32(g_tmo),
- EOD))
- self.assertTrue(tmp == '/')
- vg_proxy.update()
-
- self.assertTrue(
- tag in vg_proxy.Vg.Tags,
- "%s not in %s" % (tag, str(vg_proxy.Vg.Tags)))
+ self._tag_add_common(vg_proxy, tag)
self.assertEqual(
i, len(vg_proxy.Vg.Tags),
@@ -1739,20 +1741,8 @@ class TestDbusService(unittest.TestCase):
def test_tag_regression(self):
vg_proxy = self._vg_create()
-
tag = '--h/K.6g0A4FOEatf3+k_nI/Yp&L_u2oy-=j649x:+dUcYWPEo6.IWT0c'
-
- tmp = self.handle_return(
- vg_proxy.Vg.TagsAdd(
- dbus.Array([tag], 's'),
- dbus.Int32(g_tmo),
- EOD))
- self.assertTrue(tmp == '/')
- vg_proxy.update()
-
- self.assertTrue(
- tag in vg_proxy.Vg.Tags,
- "%s not in %s" % (tag, str(vg_proxy.Vg.Tags)))
+ self._tag_add_common(vg_proxy, tag)
def _verify_existence(self, cmd, operation, resource_name):
ec, stdout, stderr = call_lvm(cmd)
4 years, 6 months
master - lvmdbustest.py: Remove duplicate setup code
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=62136c056a506568ede...
Commit: 62136c056a506568ede876ce41e826478399085b
Parent: 12c47e0c98a24de619af63a8756a458cf6c069b3
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Oct 3 14:55:51 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbustest.py: Remove duplicate setup code
Remove the same copy & pasted code which simply creates a VG to
use.
---
test/dbus/lvmdbustest.py | 40 +++-------------------------------------
1 files changed, 3 insertions(+), 37 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 31dc4ff..da1fc69 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1697,19 +1697,7 @@ class TestDbusService(unittest.TestCase):
return ''.join(bad_tag_ch_set)
def test_invalid_tags(self):
- mgr = self.objs[MANAGER_INT][0].Manager
- pv_paths = [self.objs[PV_INT][0].object_path]
- vg_name = vg_n()
-
- vg_path = self.handle_return(
- mgr.VgCreate(
- dbus.String(vg_name),
- dbus.Array(pv_paths, 'o'),
- dbus.Int32(g_tmo),
- EOD))
- self._validate_lookup(vg_name, vg_path)
-
- vg_proxy = ClientProxy(self.bus, vg_path, interfaces=(VG_INT, ))
+ vg_proxy = self._vg_create()
for c in self._invalid_tag_characters():
with self.assertRaises(dbus.exceptions.DBusException):
@@ -1728,18 +1716,7 @@ class TestDbusService(unittest.TestCase):
EOD))
def test_tag_names(self):
- mgr = self.objs[MANAGER_INT][0].Manager
- pv_paths = [self.objs[PV_INT][0].object_path]
- vg_name = vg_n()
-
- vg_path = self.handle_return(
- mgr.VgCreate(
- dbus.String(vg_name),
- dbus.Array(pv_paths, 'o'),
- dbus.Int32(g_tmo),
- EOD))
- self._validate_lookup(vg_name, vg_path)
- vg_proxy = ClientProxy(self.bus, vg_path, interfaces=(VG_INT, ))
+ vg_proxy = self._vg_create()
for i in range(1, 64):
tag = rs(i, "", self._ALLOWABLE_TAG_CH)
@@ -1761,18 +1738,7 @@ class TestDbusService(unittest.TestCase):
"%d != %d" % (i, len(vg_proxy.Vg.Tags)))
def test_tag_regression(self):
- mgr = self.objs[MANAGER_INT][0].Manager
- pv_paths = [self.objs[PV_INT][0].object_path]
- vg_name = vg_n()
-
- vg_path = self.handle_return(
- mgr.VgCreate(
- dbus.String(vg_name),
- dbus.Array(pv_paths, 'o'),
- dbus.Int32(g_tmo),
- EOD))
- self._validate_lookup(vg_name, vg_path)
- vg_proxy = ClientProxy(self.bus, vg_path, interfaces=(VG_INT, ))
+ vg_proxy = self._vg_create()
tag = '--h/K.6g0A4FOEatf3+k_nI/Yp&L_u2oy-=j649x:+dUcYWPEo6.IWT0c'
4 years, 6 months
master - man lvmvdo: Correct spellings
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=12c47e0c98a24de619a...
Commit: 12c47e0c98a24de619af63a8756a458cf6c069b3
Parent: 75628a5f4c10c35f37f0a0c68f44e705eb9d1eef
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Oct 9 09:35:14 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
man lvmvdo: Correct spellings
---
man/lvmvdo.7_main | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/man/lvmvdo.7_main b/man/lvmvdo.7_main
index d42c1bd..582f7a8 100644
--- a/man/lvmvdo.7_main
+++ b/man/lvmvdo.7_main
@@ -86,7 +86,7 @@ The primary methods for using VDO with lvm2:
.SS 1. Create VDOPoolLV with VDOLV
-Create an VDOPoolLV that will holds VDO data togehther with
+Create an VDOPoolLV that will holds VDO data together with
virtual size VDOLV, that user can use. When the virtual size
is not specified, then such LV is created with maximum size that
always fits into data volume even if there cannot happen any
@@ -117,8 +117,8 @@ operation.
Convert an already created/existing LV into a volume that can hold
VDO data and metadata (a volume reference by VDOPoolLV).
User will be prompted to confirm such conversion as it is \fBIRREVERSIBLY
-DESTROYING\fP content of such volume, as it's being immediatelly
-formated by \fBvdoformat\fP(8) as VDO pool data volume. User can
+DESTROYING\fP content of such volume, as it's being immediately
+formatted by \fBvdoformat\fP(8) as VDO pool data volume. User can
specify virtual size of associated VDOLV with this VDOPoolLV.
When the virtual size is not specified, it will set to the maximum size
that can keep 100% uncompressible data there.
4 years, 6 months
master - man: Include '_vdata' as reserved name
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=75628a5f4c10c35f37f...
Commit: 75628a5f4c10c35f37f0a0c68f44e705eb9d1eef
Parent: bafe5d15b1e3c1e31b9c4c32cd875dc5dfe2a2fb
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Oct 3 12:30:18 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
man: Include '_vdata' as reserved name
---
man/lvm.8_main | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/man/lvm.8_main b/man/lvm.8_main
index 3e67b1b..9816f5f 100644
--- a/man/lvm.8_main
+++ b/man/lvm.8_main
@@ -274,7 +274,7 @@ not be used as LV or VG names. A VG cannot be called anything that exists in
An LV cannot be called '.', '..', 'snapshot' or 'pvmove'.
The LV name may also not contain any of the following strings:
\fR'_cdata', '_cmeta', '_corig', '_mlog', '_mimage', '_pmspare',
-\fR'_rimage', '_rmeta', '_tdata', '_tmeta' or '_vorigin'.
+\fR'_rimage', '_rmeta', '_tdata', '_tmeta', '_vorigin' or '_vdata'.
A directory bearing the name of each Volume Group is created under
\fI/dev\fP when any of its Logical Volumes are activated.
Each active Logical Volume is accessible from this directory as a symbolic
4 years, 6 months
master - lvmdbusd: Add check for reserved name '_vdata'
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bafe5d15b1e3c1e31b9...
Commit: bafe5d15b1e3c1e31b9c4c32cd875dc5dfe2a2fb
Parent: b7c64fe8e29ffc003364da93047b9e003c35fc96
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Oct 3 12:19:07 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbusd: Add check for reserved name '_vdata'
Added for vdo support.
---
daemons/lvmdbusd/utils.py | 2 +-
test/dbus/lvmdbustest.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index 8d64117..40b8a68 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -455,7 +455,7 @@ _ALLOWABLE_CH_SET = set(_ALLOWABLE_CH)
_ALLOWABLE_VG_LV_CH = string.ascii_letters + string.digits + '.-_+'
_ALLOWABLE_VG_LV_CH_SET = set(_ALLOWABLE_VG_LV_CH)
_LV_NAME_RESERVED = ("_cdata", "_cmeta", "_corig", "_mimage", "_mlog",
- "_pmspare", "_rimage", "_rmeta", "_tdata", "_tmeta", "_vorigin")
+ "_pmspare", "_rimage", "_rmeta", "_tdata", "_tmeta", "_vorigin", "_vdata")
# Tags can have the characters, based on the code
# a-zA-Z0-9._-+/=!:&#
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 4ae8b25..31dc4ff 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1670,7 +1670,7 @@ class TestDbusService(unittest.TestCase):
for reserved in (
"_cdata", "_cmeta", "_corig", "_mimage", "_mlog",
"_pmspare", "_rimage", "_rmeta", "_tdata", "_tmeta",
- "_vorigin"):
+ "_vorigin", "_vdata"):
with self.assertRaises(dbus.exceptions.DBusException):
self.handle_return(
vg_proxy.Vg.LvCreateLinear(
4 years, 6 months
master - lvmdbustest.py: Add blurb about scan_lvs = 1
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b7c64fe8e29ffc00336...
Commit: b7c64fe8e29ffc003364da93047b9e003c35fc96
Parent: b0286fa1277a9fc7a293916a3c8a3e460d276aa2
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Oct 3 11:57:10 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbustest.py: Add blurb about scan_lvs = 1
When developing and testing on a local system, to get the unit
test to pass the test_nesting test, editing the test conf will achieve
the success too.
---
test/dbus/lvmdbustest.py | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index 9bc1683..4ae8b25 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -1871,6 +1871,10 @@ class TestDbusService(unittest.TestCase):
#
# NOTE: This needs an equivalent of aux extend_filter_LVMTEST
# when run from lvm2 testsuite. See dbustest.sh.
+ # Also if developing locally with actual devices one can achieve this
+ # by editing lvm.conf with "devices/scan_lvs = 1" As testing
+ # typically utilizes loopback, this test is skipped in
+ # those environments.
pv_object_path = self.objs[PV_INT][0].object_path
if not self.objs[PV_INT][0].Pv.Name.startswith("/dev"):
4 years, 6 months
master - lvmdbusd: Add d and D to type map for VolumeType
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b0286fa1277a9fc7a29...
Commit: b0286fa1277a9fc7a293916a3c8a3e460d276aa2
Parent: 1839702cb4fa4f66c41c774f46d65b8dfa7a00f0
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Oct 1 16:36:11 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbusd: Add d and D to type map for VolumeType
These were added for vdo integration.
---
daemons/lvmdbusd/lv.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index 147e51c..9290c19 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -315,6 +315,7 @@ class LvCommon(AutomatedProperties):
'l': 'mirror log device', 'c': 'under conversion',
'V': 'thin Volume', 't': 'thin pool', 'T': 'Thin pool data',
'e': 'raid or pool metadata or pool metadata spare',
+ 'd': 'vdo pool', 'D': 'vdo pool data',
'-': 'Unspecified'}
return self.attr_struct(0, type_map)
4 years, 6 months
master - lvmdbusd: Remove use of tmp variables
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1839702cb4fa4f66c41...
Commit: 1839702cb4fa4f66c41c774f46d65b8dfa7a00f0
Parent: df38eb49aba94308804efdf309c08521165664d0
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Oct 1 15:18:46 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbusd: Remove use of tmp variables
We can use tuple expansion from the command handler functions
directly.
---
daemons/lvmdbusd/lv.py | 35 +++++++++---------------
daemons/lvmdbusd/pv.py | 14 +++------
daemons/lvmdbusd/vg.py | 67 ++++++++++++++++++------------------------------
3 files changed, 43 insertions(+), 73 deletions(-)
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index f65e7da..147e51c 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -450,8 +450,7 @@ class Lv(LvCommon):
# Make sure we have a dbus object representing it
LvCommon.validate_dbus_object(lv_uuid, lv_name)
# Remove the LV, if successful then remove from the model
- rc, out, err = cmdhandler.lv_remove(lv_name, remove_options)
- LvCommon.handle_execute(rc, out, err)
+ LvCommon.handle_execute(*cmdhandler.lv_remove(lv_name, remove_options))
return '/'
@dbus.service.method(
@@ -471,9 +470,8 @@ class Lv(LvCommon):
# Make sure we have a dbus object representing it
LvCommon.validate_dbus_object(lv_uuid, lv_name)
# Rename the logical volume
- rc, out, err = cmdhandler.lv_rename(lv_name, new_name,
- rename_options)
- LvCommon.handle_execute(rc, out, err)
+ LvCommon.handle_execute(*cmdhandler.lv_rename(lv_name, new_name,
+ rename_options))
return '/'
@dbus.service.method(
@@ -522,13 +520,11 @@ class Lv(LvCommon):
remainder = space % 512
optional_size = space + 512 - remainder
- rc, out, err = cmdhandler.vg_lv_snapshot(
- lv_name, snapshot_options, name, optional_size)
- LvCommon.handle_execute(rc, out, err)
+ LvCommon.handle_execute(*cmdhandler.vg_lv_snapshot(
+ lv_name, snapshot_options,name, optional_size))
full_name = "%s/%s" % (dbo.vg_name_lookup(), name)
return cfg.om.get_object_path_by_lvm_id(full_name)
-
@dbus.service.method(
dbus_interface=LV_INTERFACE,
in_signature='stia{sv}',
@@ -564,9 +560,8 @@ class Lv(LvCommon):
pv_dests.append((pv_dbus_obj.lvm_id, pr[1], pr[2]))
size_change = new_size_bytes - dbo.SizeBytes
- rc, out, err = cmdhandler.lv_resize(dbo.lvm_id, size_change,
- pv_dests, resize_options)
- LvCommon.handle_execute(rc, out, err)
+ LvCommon.handle_execute(*cmdhandler.lv_resize(
+ dbo.lvm_id, size_change,pv_dests, resize_options))
return "/"
@dbus.service.method(
@@ -601,9 +596,8 @@ class Lv(LvCommon):
options):
# Make sure we have a dbus object representing it
LvCommon.validate_dbus_object(uuid, lv_name)
- rc, out, err = cmdhandler.activate_deactivate(
- 'lvchange', lv_name, activate, control_flags, options)
- LvCommon.handle_execute(rc, out, err)
+ LvCommon.handle_execute(*cmdhandler.activate_deactivate(
+ 'lvchange', lv_name, activate, control_flags, options))
return '/'
@dbus.service.method(
@@ -637,9 +631,8 @@ class Lv(LvCommon):
def _add_rm_tags(uuid, lv_name, tags_add, tags_del, tag_options):
# Make sure we have a dbus object representing it
LvCommon.validate_dbus_object(uuid, lv_name)
- rc, out, err = cmdhandler.lv_tag(
- lv_name, tags_add, tags_del, tag_options)
- LvCommon.handle_execute(rc, out, err)
+ LvCommon.handle_execute(*cmdhandler.lv_tag(
+ lv_name, tags_add, tags_del, tag_options))
return '/'
@dbus.service.method(
@@ -699,10 +692,8 @@ class LvThinPool(Lv):
def _lv_create(lv_uuid, lv_name, name, size_bytes, create_options):
# Make sure we have a dbus object representing it
dbo = LvCommon.validate_dbus_object(lv_uuid, lv_name)
-
- rc, out, err = cmdhandler.lv_lv_create(
- lv_name, create_options, name, size_bytes)
- LvCommon.handle_execute(rc, out, err)
+ LvCommon.handle_execute(*cmdhandler.lv_lv_create(
+ lv_name, create_options, name, size_bytes))
full_name = "%s/%s" % (dbo.vg_name_lookup(), name)
return cfg.om.get_object_path_by_lvm_id(full_name)
diff --git a/daemons/lvmdbusd/pv.py b/daemons/lvmdbusd/pv.py
index 9c0f1b2..8a25cbf 100644
--- a/daemons/lvmdbusd/pv.py
+++ b/daemons/lvmdbusd/pv.py
@@ -138,8 +138,7 @@ class Pv(AutomatedProperties):
# Remove the PV, if successful then remove from the model
# Make sure we have a dbus object representing it
Pv.validate_dbus_object(pv_uuid, pv_name)
- rc, out, err = cmdhandler.pv_remove(pv_name, remove_options)
- Pv.handle_execute(rc, out, err)
+ Pv.handle_execute(*cmdhandler.pv_remove(pv_name, remove_options))
return '/'
@staticmethod
@@ -172,10 +171,8 @@ class Pv(AutomatedProperties):
def _resize(pv_uuid, pv_name, new_size_bytes, resize_options):
# Make sure we have a dbus object representing it
Pv.validate_dbus_object(pv_uuid, pv_name)
-
- rc, out, err = cmdhandler.pv_resize(pv_name, new_size_bytes,
- resize_options)
- Pv.handle_execute(rc, out, err)
+ Pv.handle_execute(*cmdhandler.pv_resize(pv_name, new_size_bytes,
+ resize_options))
return '/'
@dbus.service.method(
@@ -194,9 +191,8 @@ class Pv(AutomatedProperties):
def _allocation_enabled(pv_uuid, pv_name, yes_no, allocation_options):
# Make sure we have a dbus object representing it
Pv.validate_dbus_object(pv_uuid, pv_name)
- rc, out, err = cmdhandler.pv_allocatable(
- pv_name, yes_no, allocation_options)
- Pv.handle_execute(rc, out, err)
+ Pv.handle_execute(*cmdhandler.pv_allocatable(pv_name, yes_no,
+ allocation_options))
return '/'
@dbus.service.method(
diff --git a/daemons/lvmdbusd/vg.py b/daemons/lvmdbusd/vg.py
index cfcc53b..d022ff1 100644
--- a/daemons/lvmdbusd/vg.py
+++ b/daemons/lvmdbusd/vg.py
@@ -171,9 +171,8 @@ class Vg(AutomatedProperties):
def _rename(uuid, vg_name, new_name, rename_options):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = cmdhandler.vg_rename(
- uuid, new_name, rename_options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_rename(
+ uuid, new_name, rename_options))
return '/'
@dbus.service.method(
@@ -192,8 +191,7 @@ class Vg(AutomatedProperties):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
# Remove the VG, if successful then remove from the model
- rc, out, err = cmdhandler.vg_remove(vg_name, remove_options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_remove(vg_name, remove_options))
return '/'
@dbus.service.method(
@@ -209,8 +207,7 @@ class Vg(AutomatedProperties):
@staticmethod
def _change(uuid, vg_name, change_options):
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = cmdhandler.vg_change(change_options, vg_name)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_change(change_options, vg_name))
return '/'
# TODO: This should be broken into a number of different methods
@@ -246,9 +243,8 @@ class Vg(AutomatedProperties):
VG_INTERFACE,
'PV Object path not found = %s!' % pv_op)
- rc, out, err = cmdhandler.vg_reduce(vg_name, missing, pv_devices,
- reduce_options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_reduce(
+ vg_name, missing, pv_devices, reduce_options))
return '/'
@dbus.service.method(
@@ -278,9 +274,8 @@ class Vg(AutomatedProperties):
VG_INTERFACE, 'PV Object path not found = %s!' % i)
if len(extend_devices):
- rc, out, err = cmdhandler.vg_extend(vg_name, extend_devices,
- extend_options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_extend(
+ vg_name, extend_devices, extend_options))
else:
raise dbus.exceptions.DBusException(
VG_INTERFACE, 'No pv_object_paths provided!')
@@ -334,10 +329,8 @@ class Vg(AutomatedProperties):
pv_dests.append((pv_dbus_obj.lvm_id, pr[1], pr[2]))
- rc, out, err = cmdhandler.vg_lv_create(
- vg_name, create_options, name, size_bytes, pv_dests)
-
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_lv_create(
+ vg_name, create_options, name, size_bytes, pv_dests))
return Vg.fetch_new_lv(vg_name, name)
@dbus.service.method(
@@ -375,11 +368,8 @@ class Vg(AutomatedProperties):
thin_pool, create_options):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
-
- rc, out, err = cmdhandler.vg_lv_create_linear(
- vg_name, create_options, name, size_bytes, thin_pool)
-
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_lv_create_linear(
+ vg_name, create_options, name, size_bytes, thin_pool))
return Vg.fetch_new_lv(vg_name, name)
@dbus.service.method(
@@ -401,10 +391,9 @@ class Vg(AutomatedProperties):
stripe_size_kb, thin_pool, create_options):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = cmdhandler.vg_lv_create_striped(
+ Vg.handle_execute(*cmdhandler.vg_lv_create_striped(
vg_name, create_options, name, size_bytes,
- num_stripes, stripe_size_kb, thin_pool)
- Vg.handle_execute(rc, out, err)
+ num_stripes, stripe_size_kb, thin_pool))
return Vg.fetch_new_lv(vg_name, name)
@dbus.service.method(
@@ -429,9 +418,8 @@ class Vg(AutomatedProperties):
num_copies, create_options):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = cmdhandler.vg_lv_create_mirror(
- vg_name, create_options, name, size_bytes, num_copies)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_lv_create_mirror(
+ vg_name, create_options, name, size_bytes, num_copies))
return Vg.fetch_new_lv(vg_name, name)
@dbus.service.method(
@@ -454,10 +442,9 @@ class Vg(AutomatedProperties):
num_stripes, stripe_size_kb, create_options):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = cmdhandler.vg_lv_create_raid(
+ Vg.handle_execute(*cmdhandler.vg_lv_create_raid(
vg_name, create_options, name, raid_type, size_bytes,
- num_stripes, stripe_size_kb)
- Vg.handle_execute(rc, out, err)
+ num_stripes, stripe_size_kb))
return Vg.fetch_new_lv(vg_name, name)
@dbus.service.method(
@@ -555,9 +542,8 @@ class Vg(AutomatedProperties):
raise dbus.exceptions.DBusException(
VG_INTERFACE, 'PV object path = %s not found' % p)
- rc, out, err = cmdhandler.pv_tag(
- pv_devices, tags_add, tags_del, tag_options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.pv_tag(
+ pv_devices, tags_add, tags_del, tag_options))
return '/'
@dbus.service.method(
@@ -598,9 +584,8 @@ class Vg(AutomatedProperties):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = cmdhandler.vg_tag(
- vg_name, tags_add, tags_del, tag_options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.vg_tag(
+ vg_name, tags_add, tags_del, tag_options))
return '/'
@dbus.service.method(
@@ -639,8 +624,7 @@ class Vg(AutomatedProperties):
def _vg_change_set(uuid, vg_name, method, value, options):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = method(vg_name, value, options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*method(vg_name, value, options))
return '/'
@dbus.service.method(
@@ -700,9 +684,8 @@ class Vg(AutomatedProperties):
options):
# Make sure we have a dbus object representing it
Vg.validate_dbus_object(uuid, vg_name)
- rc, out, err = cmdhandler.activate_deactivate(
- 'vgchange', vg_name, activate, control_flags, options)
- Vg.handle_execute(rc, out, err)
+ Vg.handle_execute(*cmdhandler.activate_deactivate(
+ 'vgchange', vg_name, activate, control_flags, options))
return '/'
@dbus.service.method(
4 years, 6 months
master - lvmdbusd: Remove duplicate error handling code
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=df38eb49aba94308804...
Commit: df38eb49aba94308804efdf309c08521165664d0
Parent: 25e7bf021a4e7c5ad5f925b86605bf025ff1a949
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Tue Oct 1 15:17:30 2019 -0500
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Oct 30 10:38:40 2019 -0500
lvmdbusd: Remove duplicate error handling code
vg, lv, pv code had the same function for handling command execution.
Move to utility function and abstract the difference.
---
daemons/lvmdbusd/lv.py | 10 ++--------
daemons/lvmdbusd/pv.py | 10 ++--------
daemons/lvmdbusd/utils.py | 9 +++++++++
daemons/lvmdbusd/vg.py | 11 +++--------
4 files changed, 16 insertions(+), 24 deletions(-)
diff --git a/daemons/lvmdbusd/lv.py b/daemons/lvmdbusd/lv.py
index c0029b8..f65e7da 100644
--- a/daemons/lvmdbusd/lv.py
+++ b/daemons/lvmdbusd/lv.py
@@ -10,7 +10,7 @@
from .automatedproperties import AutomatedProperties
from . import utils
-from .utils import vg_obj_path_generate, log_error
+from .utils import vg_obj_path_generate, log_error, _handle_execute
import dbus
from . import cmdhandler
from . import cfg
@@ -275,13 +275,7 @@ class LvCommon(AutomatedProperties):
@staticmethod
def handle_execute(rc, out, err):
- if rc == 0:
- cfg.load()
- else:
- # Need to work on error handling, need consistent
- raise dbus.exceptions.DBusException(
- LV_INTERFACE,
- 'Exit code %s, stderr = %s' % (str(rc), err))
+ _handle_execute(rc, out, err, LV_INTERFACE)
@staticmethod
def validate_dbus_object(lv_uuid, lv_name):
diff --git a/daemons/lvmdbusd/pv.py b/daemons/lvmdbusd/pv.py
index e5f8b9d..9c0f1b2 100644
--- a/daemons/lvmdbusd/pv.py
+++ b/daemons/lvmdbusd/pv.py
@@ -14,7 +14,7 @@ import dbus
from .cfg import PV_INTERFACE
from . import cmdhandler
from .utils import vg_obj_path_generate, n, pv_obj_path_generate, \
- lv_object_path_method
+ lv_object_path_method, _handle_execute
from .loader import common
from .request import RequestEntry
from .state import State
@@ -144,13 +144,7 @@ class Pv(AutomatedProperties):
@staticmethod
def handle_execute(rc, out, err):
- if rc == 0:
- cfg.load()
- else:
- # Need to work on error handling, need consistent
- raise dbus.exceptions.DBusException(
- PV_INTERFACE,
- 'Exit code %s, stderr = %s' % (str(rc), err))
+ return _handle_execute(rc, out, err, PV_INTERFACE)
@staticmethod
def validate_dbus_object(pv_uuid, pv_name):
diff --git a/daemons/lvmdbusd/utils.py b/daemons/lvmdbusd/utils.py
index 3c006c4..8d64117 100644
--- a/daemons/lvmdbusd/utils.py
+++ b/daemons/lvmdbusd/utils.py
@@ -26,6 +26,15 @@ import signal
STDOUT_TTY = os.isatty(sys.stdout.fileno())
+def _handle_execute(rc, out, err, interface):
+ if rc == 0:
+ cfg.load()
+ else:
+ # Need to work on error handling, need consistent
+ raise dbus.exceptions.DBusException(
+ interface, 'Exit code %s, stderr = %s' % (str(rc), err))
+
+
def rtype(dbus_type):
"""
Decorator making sure that the decorated function returns a value of
diff --git a/daemons/lvmdbusd/vg.py b/daemons/lvmdbusd/vg.py
index 7011ff8..cfcc53b 100644
--- a/daemons/lvmdbusd/vg.py
+++ b/daemons/lvmdbusd/vg.py
@@ -10,7 +10,8 @@
from .automatedproperties import AutomatedProperties
from . import utils
-from .utils import pv_obj_path_generate, vg_obj_path_generate, n
+from .utils import pv_obj_path_generate, vg_obj_path_generate, n, \
+ _handle_execute
import dbus
from . import cfg
from .cfg import VG_INTERFACE
@@ -154,13 +155,7 @@ class Vg(AutomatedProperties):
@staticmethod
def handle_execute(rc, out, err):
- if rc == 0:
- cfg.load()
- else:
- # Need to work on error handling, need consistent
- raise dbus.exceptions.DBusException(
- VG_INTERFACE,
- 'Exit code %s, stderr = %s' % (str(rc), err))
+ return _handle_execute(rc, out, err, VG_INTERFACE)
@staticmethod
def validate_dbus_object(vg_uuid, vg_name):
4 years, 6 months