mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-09 08:58:27 +03:00
storagepool: Refresh volumes on state change
Otherwise the UI list is out of date
This commit is contained in:
parent
a0075beab4
commit
87098d1273
@ -118,7 +118,7 @@ class vmmStoragePool(vmmLibvirtObject):
|
|||||||
vmmLibvirtObject.__init__(self, conn, backend, key, StoragePool)
|
vmmLibvirtObject.__init__(self, conn, backend, key, StoragePool)
|
||||||
|
|
||||||
self._last_refresh_time = 0
|
self._last_refresh_time = 0
|
||||||
self._volumes = []
|
self._volumes = None
|
||||||
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
@ -150,6 +150,10 @@ class vmmStoragePool(vmmLibvirtObject):
|
|||||||
for vol in self.get_volumes():
|
for vol in self.get_volumes():
|
||||||
vol.init_libvirt_state()
|
vol.init_libvirt_state()
|
||||||
|
|
||||||
|
def _invalidate_xml(self):
|
||||||
|
vmmLibvirtObject._invalidate_xml(self)
|
||||||
|
self._volumes = None
|
||||||
|
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Actions #
|
# Actions #
|
||||||
@ -180,7 +184,7 @@ class vmmStoragePool(vmmLibvirtObject):
|
|||||||
self._backend.refresh(0)
|
self._backend.refresh(0)
|
||||||
if skip_xml_refresh:
|
if skip_xml_refresh:
|
||||||
self.ensure_latest_xml()
|
self.ensure_latest_xml()
|
||||||
self._update_volumes()
|
self._update_volumes(force=True)
|
||||||
self.idle_emit("refreshed")
|
self.idle_emit("refreshed")
|
||||||
self._last_refresh_time = time.time()
|
self._last_refresh_time = time.time()
|
||||||
|
|
||||||
@ -193,6 +197,7 @@ class vmmStoragePool(vmmLibvirtObject):
|
|||||||
###################
|
###################
|
||||||
|
|
||||||
def get_volumes(self):
|
def get_volumes(self):
|
||||||
|
self._update_volumes(force=False)
|
||||||
return self._volumes[:]
|
return self._volumes[:]
|
||||||
|
|
||||||
def get_volume(self, key):
|
def get_volume(self, key):
|
||||||
@ -201,11 +206,14 @@ class vmmStoragePool(vmmLibvirtObject):
|
|||||||
return vol
|
return vol
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _update_volumes(self):
|
def _update_volumes(self, force):
|
||||||
if not self.is_active():
|
if not self.is_active():
|
||||||
self._volumes = []
|
self._volumes = []
|
||||||
return
|
return
|
||||||
|
if not force and self._volumes is not None:
|
||||||
|
return
|
||||||
|
|
||||||
|
self._volumes = []
|
||||||
keymap = dict((o.get_connkey(), o) for o in self._volumes)
|
keymap = dict((o.get_connkey(), o) for o in self._volumes)
|
||||||
(ignore, ignore, allvols) = pollhelpers.fetch_volumes(
|
(ignore, ignore, allvols) = pollhelpers.fetch_volumes(
|
||||||
self.conn.get_backend(), self.get_backend(), keymap,
|
self.conn.get_backend(), self.get_backend(), keymap,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user