Prune actions by device based on path, not object-id.
Since we instantiate a new Device for most of the "create device"
dialogs, we cannot expect to be able to do simple comparison of
the instances.
---
storage/devicetree.py | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/storage/devicetree.py b/storage/devicetree.py
index b0694e5..1692b0e 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -183,7 +183,7 @@ class DeviceTree(object):
continue
# XXX this may finally necessitate object ids
- loops = self.findActions(device=a.device,
+ loops = self.findActions(path=a.device.path,
type="destroy",
object="device")
@@ -192,7 +192,7 @@ class DeviceTree(object):
# remove all actions on this device from after the first
# destroy up through the last destroy
- dev_actions = self.findActions(device=a.device)
+ dev_actions = self.findActions(path=a.device.path)
for rem in dev_actions:
start = self._actions.index(a)
end = self._actions.index(loops[-1])
@@ -207,7 +207,7 @@ class DeviceTree(object):
# iteration of this loop
continue
@@ -215,7 +215,7 @@ class DeviceTree(object):
continue
# remove all all actions on this device up to the last create
- dev_actions = self.findActions(device=a.device)
+ dev_actions = self.findActions(path=a.device.path)
for rem in dev_actions:
end = self._actions.index(loops[-1])
if self._actions.index(rem) < end:
@@ -229,7 +229,7 @@ class DeviceTree(object):
# iteration of this loop
continue
# remove all actions on this device's format from after the
# first destroy up through the last destroy
- dev_actions = self.findActions(device=a.device, object="format")
+ dev_actions = self.findActions(path=a.device.path,
+ object="format")
for rem in dev_actions:
start = self._actions.index(a)
end = self._actions.index(loops[-1])
@@ -283,7 +284,8 @@ class DeviceTree(object):
# remove all all actions on this device's format up to the last
# create
- dev_actions = self.findActions(device=a.device, object="format")
+ dev_actions = self.findActions(path=a.device.path,
+ object="format")
for rem in dev_actions:
end = self._actions.index(loops[-1])
if self._actions.index(rem) < end:
@@ -297,7 +299,7 @@ class DeviceTree(object):
# iteration of this loop
continue
@@ -569,7 +571,7 @@ class DeviceTree(object):
# add the device back into the tree
self._addDevice(action.device)
- def findActions(self, device=None, type=None, object=None):
+ def findActions(self, device=None, type=None, object=None, path=None):
""" Find all actions that match all specified parameters.
Keyword arguments:
@@ -577,6 +579,7 @@ class DeviceTree(object):
device -- device to match (Device, or None to match any)
type -- action type to match (string, or None to match any)
object -- operand type to match (string, or None to match any)
+ path -- device path to match (string, or None to match any)
"""
if device is None and type is None and object is None:
@@ -596,6 +599,9 @@ class DeviceTree(object):
if _object is not None and action.obj != _object:
continue
+
+ if path is not None and action.device.path != path:
+ continue
actions.append(action)
--
1.6.0.6
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
03-09-2009, 11:56 PM
David Cantrell
Prune actions by device based on path, not object-id.
Looks good.
On 03/09/2009 11:25 AM, David Lehman wrote:
Since we instantiate a new Device for most of the "create device"
dialogs, we cannot expect to be able to do simple comparison of
the instances.
---
storage/devicetree.py | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/storage/devicetree.py b/storage/devicetree.py
index b0694e5..1692b0e 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -183,7 +183,7 @@ class DeviceTree(object):
continue
# XXX this may finally necessitate object ids
- loops = self.findActions(device=a.device,
+ loops = self.findActions(path=a.device.path,
type="destroy",
object="device")
@@ -192,7 +192,7 @@ class DeviceTree(object):
# remove all actions on this device from after the first
# destroy up through the last destroy
- dev_actions = self.findActions(device=a.device)
+ dev_actions = self.findActions(path=a.device.path)
for rem in dev_actions:
start = self._actions.index(a)
end = self._actions.index(loops[-1])
@@ -207,7 +207,7 @@ class DeviceTree(object):
# iteration of this loop
continue
@@ -215,7 +215,7 @@ class DeviceTree(object):
continue
# remove all all actions on this device up to the last create
- dev_actions = self.findActions(device=a.device)
+ dev_actions = self.findActions(path=a.device.path)
for rem in dev_actions:
end = self._actions.index(loops[-1])
if self._actions.index(rem)< end:
@@ -229,7 +229,7 @@ class DeviceTree(object):
# iteration of this loop
continue
# remove all actions on this device's format from after the
# first destroy up through the last destroy
- dev_actions = self.findActions(device=a.device, object="format")
+ dev_actions = self.findActions(path=a.device.path,
+ object="format")
for rem in dev_actions:
start = self._actions.index(a)
end = self._actions.index(loops[-1])
@@ -283,7 +284,8 @@ class DeviceTree(object):
# remove all all actions on this device's format up to the last
# create
- dev_actions = self.findActions(device=a.device, object="format")
+ dev_actions = self.findActions(path=a.device.path,
+ object="format")
for rem in dev_actions:
end = self._actions.index(loops[-1])
if self._actions.index(rem)< end:
@@ -297,7 +299,7 @@ class DeviceTree(object):
# iteration of this loop
continue
@@ -569,7 +571,7 @@ class DeviceTree(object):
# add the device back into the tree
self._addDevice(action.device)
- def findActions(self, device=None, type=None, object=None):
+ def findActions(self, device=None, type=None, object=None, path=None):
""" Find all actions that match all specified parameters.
Keyword arguments:
@@ -577,6 +579,7 @@ class DeviceTree(object):
device -- device to match (Device, or None to match any)
type -- action type to match (string, or None to match any)
object -- operand type to match (string, or None to match any)
+ path -- device path to match (string, or None to match any)
"""
if device is None and type is None and object is None:
@@ -596,6 +599,9 @@ class DeviceTree(object):
if _object is not None and action.obj != _object:
continue
+
+ if path is not None and action.device.path != path:
+ continue
actions.append(action)
--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list