Francesco Romani has uploaded a new change for review. Change subject: GuestManager: reorganize internals ......................................................................
GuestManager: reorganize internals this apparently large patch reorganize the internals of GuestManager with only renames and code move inside the class, to mark private methods as such and to make room for another implementation using a single thread. Change-Id: I8ecc6f56f326b2eb20ef84479387c4aaf3e7f147 Signed-off-by: Francesco Romani <from...@redhat.com> --- M mom/GuestManager.py 1 file changed, 43 insertions(+), 43 deletions(-) git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/25/37825/1 diff --git a/mom/GuestManager.py b/mom/GuestManager.py index f6205ce..889c12b 100644 --- a/mom/GuestManager.py +++ b/mom/GuestManager.py @@ -42,7 +42,46 @@ self.guests = {} self.guests_sem = threading.Semaphore() - def spawn_guest_monitors(self, domain_list): + def interrogate(self): + """ + Interrogate all active GuestMonitors + Return: A dictionary of Entities, indexed by guest id + """ + ret = {} + with self.guests_sem: + for uuid, guest in self.guests.items(): + entity = guest.monitor.interrogate() + if entity is not None: + ret[uuid] = entity + return ret + + def rpc_get_active_guests(self): + ret = [] + with self.guests_sem: + for uuid, guest in self.guests.items(): + if guest.monitor.isReady(): + name = guest.monitor.getGuestName() + if name is not None: + ret.append(name) + return ret + + def run(self): + try: + self.logger.info("Guest Manager starting"); + interval = self.config.getint('main', 'guest-manager-interval') + while self.config.getint('__int__', 'running') == 1: + domain_list = self.hypervisor_iface.getVmList() + if domain_list is not None: + self._spawn_guest_monitors(domain_list) + self._check_guest_monitors(domain_list) + time.sleep(interval) + self._wait_for_guest_monitors() + except Exception as e: + self.logger.error("Guest Manager crashed", exc_info=True) + else: + self.logger.info("Guest Manager ending") + + def _spawn_guest_monitors(self, domain_list): """ Get the list of running domains and spawn GuestMonitors for any guests we are not already tracking. The GuestMonitor constructor might block @@ -63,7 +102,7 @@ with self.guests_sem: self._register_guest(id, GuestData(guest, thread)) - def wait_for_guest_monitors(self): + def _wait_for_guest_monitors(self): """ Wait for GuestMonitors to exit """ @@ -79,9 +118,9 @@ else: break - def check_threads(self, domain_list): + def _check_guest_monitors(self, domain_list): """ - Check for stale and/or deceased threads and remove them. + Check for stale and/or deceased guest monitors and remove them. """ with self.guests_sem: for uuid, guest in self.guests.items(): @@ -94,45 +133,6 @@ # Check if the domain has ended according to hypervisor interface elif uuid not in domain_list: self._unregister_guest(uuid) - - def interrogate(self): - """ - Interrogate all active GuestMonitors - Return: A dictionary of Entities, indexed by guest id - """ - ret = {} - with self.guests_sem: - for uuid, guest in self.guests.items(): - entity = guest.monitor.interrogate() - if entity is not None: - ret[uuid] = entity - return ret - - def run(self): - try: - self.logger.info("Guest Manager starting"); - interval = self.config.getint('main', 'guest-manager-interval') - while self.config.getint('__int__', 'running') == 1: - domain_list = self.hypervisor_iface.getVmList() - if domain_list is not None: - self.spawn_guest_monitors(domain_list) - self.check_threads(domain_list) - time.sleep(interval) - self.wait_for_guest_monitors() - except Exception as e: - self.logger.error("Guest Manager crashed", exc_info=True) - else: - self.logger.info("Guest Manager ending") - - def rpc_get_active_guests(self): - ret = [] - with self.guests_sem: - for uuid, guest in self.guests.items(): - if guest.monitor.isReady(): - name = guest.monitor.getGuestName() - if name is not None: - ret.append(name) - return ret def _register_guest(self, uuid, guest): if uuid not in self.guests: -- To view, visit http://gerrit.ovirt.org/37825 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8ecc6f56f326b2eb20ef84479387c4aaf3e7f147 Gerrit-PatchSet: 1 Gerrit-Project: mom Gerrit-Branch: master Gerrit-Owner: Francesco Romani <from...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches