addstorage: Rate limit the default pool refresh

This commit is contained in:
Cole Robinson 2014-09-12 12:08:44 -04:00
parent 76bc8e5ab9
commit 3753fcbaa3
2 changed files with 10 additions and 3 deletions

View File

@ -20,6 +20,7 @@
import logging
import os
import statvfs
import time
from gi.repository import GObject
from gi.repository import Gtk
@ -78,9 +79,9 @@ class vmmAddStorage(vmmGObjectUI):
avail = 0
if pool and pool.is_active():
# FIXME: make sure not inactive?
# FIXME: use a conn specific function after we send pool-added
pool.refresh()
# Rate limit this, since it can be spammed at dialog startup time
if ((time.time() - pool.get_last_refresh_time()) > 10):
pool.refresh()
avail = int(pool.get_available())
elif not self.conn.is_remote() and os.path.exists(path):

View File

@ -19,6 +19,7 @@
#
import logging
import time
from gi.repository import GObject
@ -104,6 +105,7 @@ class vmmStoragePool(vmmLibvirtObject):
self._active = True
self._support_isactive = None
self._last_refresh_time = 0
self._volumes = {}
@ -182,6 +184,10 @@ class vmmStoragePool(vmmLibvirtObject):
self.refresh_xml()
self._update_volumes()
self.idle_emit("refreshed")
self._last_refresh_time = time.time()
def get_last_refresh_time(self):
return self._last_refresh_time
def define_name(self, newname):
return self._define_name_helper("storagepool",