From 7f669267217528396d89c4f9f559ad4324571cb1 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Sat, 18 Jan 2014 14:57:39 -0500 Subject: Fix first time remote URL installs from virt-manager (bz 1049852) On first run, the remote URL install handling creates a storage pool for /var/lib/libvirt/boot on the remote host. After this, it clears the VirtualConnection's object cache, so the next time all pools are fetched, it returns an accurate list. However that clear_cache call wasn't propagated up to virt-manager's cache. Add a new cb to fix it. --- virtinst/connection.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'virtinst/connection.py') diff --git a/virtinst/connection.py b/virtinst/connection.py index 70bb6031..60990d54 100644 --- a/virtinst/connection.py +++ b/virtinst/connection.py @@ -104,6 +104,7 @@ class VirtualConnection(object): self.cb_fetch_all_guests = None self.cb_fetch_all_pools = None self.cb_fetch_all_vols = None + self.cb_clear_cache = None ############## @@ -164,8 +165,12 @@ class VirtualConnection(object): self._uri = self._libvirtconn.getURI() self._urisplits = util.uri_split(self._uri) + _FETCH_KEY_GUESTS = "vms" + _FETCH_KEY_POOLS = "pools" + _FETCH_KEY_VOLS = "vols" + def _fetch_all_guests_cached(self): - key = "vms" + key = self._FETCH_KEY_GUESTS if key in self._fetch_cache: return self._fetch_cache[key] @@ -186,7 +191,7 @@ class VirtualConnection(object): return self._fetch_all_guests_cached() def _fetch_all_pools_cached(self): - key = "pools" + key = self._FETCH_KEY_POOLS if key in self._fetch_cache: return self._fetch_cache[key] @@ -207,7 +212,7 @@ class VirtualConnection(object): return self._fetch_all_pools_cached() def _fetch_all_vols_cached(self): - key = "vols" + key = self._FETCH_KEY_VOLS if key in self._fetch_cache: return self._fetch_cache[key] @@ -231,8 +236,13 @@ class VirtualConnection(object): return self.cb_fetch_all_vols() # pylint: disable=E1102 return self._fetch_all_vols_cached() - def clear_cache(self): - self._fetch_cache = {} + def clear_cache(self, pools=False): + if self.cb_clear_cache: + self.cb_clear_cache(pools=pools) # pylint: disable=E1102 + return + + if pools: + self._fetch_cache.pop(self._FETCH_KEY_POOLS, None) ######################### -- cgit v1.2.1