From 2c98d9fc94cc97ede13bdefd119e92ac77365e89 Mon Sep 17 00:00:00 2001 From: David Lehman Date: Fri, 6 Mar 2015 12:51:15 -0600 Subject: [PATCH 14/19] Notify containers and formats when UUID has been set/updated. _postCreate methods can wait until the UUID has been set if they need it for further post-processing of the create action. --- blivet/devices/container.py | 18 ++---------------- blivet/handler.py | 8 ++++++++ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/blivet/devices/container.py b/blivet/devices/container.py index 569936f..5963c32 100644 --- a/blivet/devices/container.py +++ b/blivet/devices/container.py @@ -203,22 +203,8 @@ class ContainerDevice(StorageDevice): # they have no format.create method. parent.format.exists = True - ## Benefits to doing the below here: - ## 1. less type-specific code in the change handler - ## 2. container gets uuid set sooner - ## - ## Drawbacks to doing the below here: - ## 1. ... - ## - - # Make sure that member and container UUIDs are synced up. - uuid = getattr(parent.format, self._formatUUIDAttr) - if uuid and not self.uuid: - # XXX This is also happening in DeviceTree._deviceChangedCB. - self.uuid = uuid - #elif self.uuid and not uuid: - # # XXX I don't think this will ever happen. - # setattr(parent.format, self._formatUUIDAttr, self.uuid) + # wait a couple seconds to get a UUID set by the event handler + self.modifySync.wait(2) # Container device operations manifest as events on member devices. We use # the parents' controlSync since it monitors events on the device itself diff --git a/blivet/handler.py b/blivet/handler.py index 90babca..2cdda7f 100644 --- a/blivet/handler.py +++ b/blivet/handler.py @@ -552,6 +552,14 @@ class EventHandler(object): container = self.devicetree.getChildren(device)[0] except IndexError: pass + else: + # notify the container in case it's waiting on the UUID + # in _postCreate + container.modifySync.notify() + + # notify the event sync now that we're done updating UUID in + # case it is waiting on us to set it + device.format.eventSync.notify() if expected: return -- 1.9.3