[PATCH 9/9] Support mutually-obsoleting actions.
David Lehman
dlehman at redhat.com
Thu Mar 20 17:14:13 UTC 2014
This is for action loops like adding a device as a PV and then removing
it from the VG.
---
blivet/devicetree.py | 5 +++++
tests/action_test.py | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/blivet/devicetree.py b/blivet/devicetree.py
index c18c375..7cbbbb0 100644
--- a/blivet/devicetree.py
+++ b/blivet/devicetree.py
@@ -174,6 +174,11 @@ class DeviceTree(object):
% (obsolete.id, action.id))
self._actions.remove(obsolete)
+ if obsolete.obsoletes(action) and action in self._actions:
+ log.info("removing mutually-obsolete action %d (%d)"
+ % (action.id, obsolete.id))
+ self._actions.remove(action)
+
def sortActions(self):
""" Sort actions based on dependencies. """
if not self._actions:
diff --git a/tests/action_test.py b/tests/action_test.py
index 23d9f3c..146f313 100644
--- a/tests/action_test.py
+++ b/tests/action_test.py
@@ -1023,6 +1023,11 @@ class DeviceActionTestCase(StorageTestCase):
self.assertEqual(remove_sdc1.obsoletes(add_sdc1), True)
self.assertEqual(add_sdc1.obsoletes(remove_sdc1), True)
+ # add/remove loops (same member&container) should obsolete both actions
+ add_sdb1 = ActionAddMember(vg, sdb1)
+ self.assertEqual(add_sdb1.obsoletes(remove_sdb1), True)
+ self.assertEqual(remove_sdb1.obsoletes(add_sdb1), True)
+
sdc2 = self.newDevice(device_class=PartitionDevice, name="sdc2",
size=Size(spec="5 GiB"), parents=[sdc])
create_sdc2 = self.scheduleCreateDevice(device=sdc2)
--
1.8.5.3
More information about the anaconda-patches
mailing list