diff options
author | Cole Robinson <crobinso@redhat.com> | 2014-01-18 14:57:39 -0500 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2014-01-18 14:57:39 -0500 |
commit | 7f669267217528396d89c4f9f559ad4324571cb1 (patch) | |
tree | 08c3e516107c963797ede433ce3b65479e57fc87 /virtinst/connection.py | |
parent | a82b60dcff5d2a54bdd98ca65030fd254b217f92 (diff) | |
download | virt-manager-7f669267217528396d89c4f9f559ad4324571cb1.tar.gz |
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.
Diffstat (limited to 'virtinst/connection.py')
-rw-r--r-- | virtinst/connection.py | 20 |
1 files changed, 15 insertions, 5 deletions
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) ######################### |