From 0560e757e44c5b86c07a21dfa22741e4bb8e261f Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 26 Aug 2008 12:58:53 -0400 Subject: [PATCH] Update pool size meter when state changes. --- src/virtManager/host.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/virtManager/host.py b/src/virtManager/host.py index 7e7d1df0..17d4b852 100644 --- a/src/virtManager/host.py +++ b/src/virtManager/host.py @@ -539,11 +539,17 @@ class vmmHost(gobject.GObject): def refresh_storage_pool(self, src, uri, uuid): sel = self.window.get_widget("pool-list").get_selection() + model = self.window.get_widget("pool-list").get_model() active = sel.get_selected() if active[1] != None: curruuid = active[0].get_value(active[1], 0) - if curruuid == uuid: - self.pool_selected(sel) + if curruuid != uuid: + return + self.pool_selected(sel) + for row in model: + if row[0] == curruuid: + row[2] = self.get_pool_size_percent(uuid) + break def reset_pool_state(self): self.window.get_widget("pool-details").set_sensitive(False) @@ -577,16 +583,21 @@ class vmmHost(gobject.GObject): def repopulate_storage_pools(self, src, uri, uuid): self.populate_storage_pools(self.window.get_widget("pool-list").get_model()) + def get_pool_size_percent(self, uuid): + pool = self.conn.get_pool(uuid) + cap = pool.get_capacity() + all = pool.get_allocation() + if not cap or all is None: + per = 0 + else: + per = int(((float(all) / float(cap)) * 100)) + return per + def populate_storage_pools(self, model): model.clear() for uuid in self.conn.list_pool_uuids(): + per = self.get_pool_size_percent(uuid) pool = self.conn.get_pool(uuid) - cap = pool.get_capacity() - all = pool.get_allocation() - if not cap or all is None: - per = 0 - else: - per = int(((float(all) / float(cap)) * 100)) model.append([uuid, pool.get_name(), per]) def populate_storage_volumes(self):