Francesco Romani has uploaded a new change for review. Change subject: guest manager: add method to register the monitor ......................................................................
guest manager: add method to register the monitor This patch add an explicit registration step for Guest Monitor objects inside the Guest Manager. Besides a little cleanup, this patch makes room for a future patch want to optionally demand the collection of the MOM stats to hypervisor. The old behaviour is preserved through fallback code. Change-Id: I67dd35aa491f47dbcb926ae3a1e4e0fb94527f84 Signed-off-by: Francesco Romani <[email protected]> --- M mom/GuestManager.py 1 file changed, 20 insertions(+), 12 deletions(-) git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/05/31605/1 diff --git a/mom/GuestManager.py b/mom/GuestManager.py index b6a1245..9ddc1d2 100644 --- a/mom/GuestManager.py +++ b/mom/GuestManager.py @@ -51,13 +51,10 @@ "can't start", id) continue guest = GuestMonitor(self.config, info, self.hypervisor_iface) - guest.start() + t = GuestMonitorThread(info, guest) + t.start() if guest.isAlive(): - with self.guests_sem: - if id not in self.guests: - self.guests[id] = guest - else: - del guest + self._register_guest(guest, t) def wait_for_guest_monitors(self): """ @@ -65,12 +62,13 @@ """ while True: with self.guests_sem: - if len(self.guests) > 0: - (id, thread) = self.guests.popitem() + if self.guests: + (id, (mon, thread)) = self.guests.popitem() else: - id = None + id, thread = None, None if id is not None: - thread.join(0) + if thread is not None: + thread.join(0) else: break @@ -80,6 +78,9 @@ """ with self.guests_sem: for (id, (mon, thread)) in self.guests.items(): + if thread is None: + # no thread to babysit + continue # Check if the thread has died if not thread.isAlive(): del self.guests[id] @@ -95,7 +96,7 @@ """ ret = {} with self.guests_sem: - for (id, monitor) in self.guests.items(): + for (id, (monitor, thread)) in self.guests.items(): entity = monitor.interrogate() if entity is not None: ret[id] = entity @@ -120,9 +121,16 @@ def rpc_get_active_guests(self): ret = [] with self.guests_sem: - for (id, monitor) in self.guests.items(): + for (id, (monitor, thread)) in self.guests.items(): if monitor.isReady(): name = monitor.getGuestName() if name is not None: ret.append(name) return ret + + def _register_guest(self, guest, thread=None): + with self.guests_sem: + if id not in self.guests: + self.guests[id] = (guest, thread) + else: + del guest -- To view, visit http://gerrit.ovirt.org/31605 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I67dd35aa491f47dbcb926ae3a1e4e0fb94527f84 Gerrit-PatchSet: 1 Gerrit-Project: mom Gerrit-Branch: master Gerrit-Owner: Francesco Romani <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
