host: storage: Add pool refresh button

This commit is contained in:
Cole Robinson 2010-04-21 10:56:06 -04:00
parent 13d61f97c9
commit db4879b42e
3 changed files with 57 additions and 10 deletions

View File

@ -128,6 +128,7 @@ class vmmHost(gobject.GObject):
"on_pool_stop_clicked": self.stop_pool,
"on_pool_start_clicked": self.start_pool,
"on_pool_delete_clicked": self.delete_pool,
"on_pool_refresh_clicked": self.pool_refresh,
"on_pool_autostart_toggled": self.pool_autostart_changed,
"on_vol_delete_clicked": self.delete_vol,
"on_vol_list_button_press_event": self.popup_vol_menu,
@ -604,6 +605,19 @@ class vmmHost(gobject.GObject):
self.err.show_err(_("Error deleting pool: %s") % str(e),
"".join(traceback.format_exc()))
def pool_refresh(self, src):
pool = self.current_pool()
if pool is None:
return
try:
pool.refresh()
self.refresh_current_pool()
except Exception, e:
self.err.show_err(_("Error refreshing pool '%s': %s") % \
(pool.get_name(), str(e)),
"".join(traceback.format_exc()))
def delete_vol(self, src):
vol = self.current_vol()
if vol is None:

View File

@ -25,7 +25,9 @@ import virtinst.util as util
from virtManager.storagevol import vmmStorageVolume
class vmmStoragePool(gobject.GObject):
__gsignals__ = { }
__gsignals__ = {
"refreshed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, []),
}
def __init__(self, config, connection, pool, uuid, active):
self.__gobject_init__()
@ -40,8 +42,6 @@ class vmmStoragePool(gobject.GObject):
self._xml = None # xml cache
self.refresh()
self._update_xml()
self.update_volumes()
def set_active(self, state):
self.active = state
@ -120,9 +120,13 @@ class vmmStoragePool(gobject.GObject):
return self._volumes[uuid]
def refresh(self):
if self.active:
self.pool.refresh(0)
self._update_xml()
if not self.active:
return
self.pool.refresh(0)
self._update_xml()
self.update_volumes()
self.emit("refreshed")
def update_volumes(self):
if not self.is_active():

View File

@ -1229,11 +1229,40 @@
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<widget class="GtkLabel" id="label77">
<widget class="GtkHBox" id="hbox12">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Volumes&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="label77">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Volumes&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="pool-refresh">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_pool_refresh_clicked"/>
<child>
<widget class="GtkImage" id="image8">
<property name="visible">True</property>
<property name="stock">gtk-refresh</property>
</widget>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>