host: Allow renaming a storage pool

This commit is contained in:
Cole Robinson 2013-09-29 12:28:01 -04:00
parent 369a17160a
commit 8f0bfb1ad6
4 changed files with 138 additions and 89 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.0 on Sun Sep 29 11:40:23 2013 -->
<!-- Generated with glade 3.16.0 on Sun Sep 29 12:24:13 2013 -->
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAccelGroup" id="accelgroup1"/>
@ -1341,13 +1341,11 @@
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkTable" id="table5">
<object class="GtkGrid" id="table5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">5</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">5</property>
<property name="column_spacing">8</property>
<child>
<object class="GtkLabel" id="label73">
<property name="visible">True</property>
@ -1356,10 +1354,10 @@
<property name="label" translatable="yes">Pool Type:</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -1372,11 +1370,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -1388,8 +1384,10 @@
<property name="use_markup">True</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -1402,37 +1400,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label60">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Location:</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label75">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">State:</property>
</object>
<packing>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -1468,27 +1438,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
</child>
<child>
<object class="GtkLabel" id="label76">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">A_utostart:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">pool-autostart</property>
</object>
<packing>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -1504,11 +1456,9 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">4</property>
<property name="bottom_attach">5</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
@ -1521,10 +1471,80 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"/>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="pool-name-entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<signal name="changed" handler="on_pool_name_changed" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Name:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label60">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Location:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label75">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">State:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label76">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">A_utostart:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">pool-autostart</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>

View File

@ -779,6 +779,9 @@ class vmmConnection(vmmGObject):
def rename_network(self, obj, origxml, newxml):
return self._rename_helper("network", self.define_network,
obj, origxml, newxml)
def rename_pool(self, obj, origxml, newxml):
return self._rename_helper("storagepool", self.define_pool,
obj, origxml, newxml)
####################

View File

@ -44,7 +44,11 @@ INTERFACE_PAGE_INFO = 0
INTERFACE_PAGE_ERROR = 1
(EDIT_NET_NAME,
EDIT_NET_AUTOSTART) = range(2)
EDIT_NET_AUTOSTART,
EDIT_POOL_NAME,
EDIT_POOL_AUTOSTART,
) = range(4)
class vmmHost(vmmGObjectUI):
@ -73,7 +77,7 @@ class vmmHost(vmmGObjectUI):
self.volmenu = None
self._in_refresh = False
self.net_active_edits = []
self.active_edits = []
self.cpu_usage_graph = None
self.memory_usage_graph = None
@ -113,6 +117,8 @@ class vmmHost(vmmGObjectUI):
"on_vol_list_button_press_event": self.popup_vol_menu,
"on_pool_apply_clicked": self.pool_apply,
"on_vol_list_changed": self.vol_selected,
"on_pool_name_changed": (lambda *x:
self.enable_pool_apply(x, EDIT_POOL_NAME)),
"on_interface_add_clicked" : self.add_interface,
"on_interface_start_clicked" : self.start_interface,
@ -469,10 +475,10 @@ class vmmHost(vmmGObjectUI):
logging.debug("Applying changes for network '%s'", net.get_name())
try:
if EDIT_NET_AUTOSTART in self.net_active_edits:
if EDIT_NET_AUTOSTART in self.active_edits:
auto = self.widget("net-autostart").get_active()
net.set_autostart(auto)
if EDIT_NET_NAME in self.net_active_edits:
if EDIT_NET_NAME in self.active_edits:
net.define_name(self.widget("net-name").get_text())
self.repopulate_networks()
except Exception, e:
@ -482,14 +488,14 @@ class vmmHost(vmmGObjectUI):
self.disable_net_apply()
def disable_net_apply(self):
self.net_active_edits = []
self.active_edits = []
self.widget("net-apply").set_sensitive(False)
def enable_net_apply(self, *arglist):
edittype = arglist[-1]
self.widget("net-apply").set_sensitive(True)
if edittype not in self.net_active_edits:
self.net_active_edits.append(edittype)
if edittype not in self.active_edits:
self.active_edits.append(edittype)
def net_autostart_changed(self, src_ignore):
auto = self.widget("net-autostart").get_active()
@ -824,19 +830,33 @@ class vmmHost(vmmGObjectUI):
logging.debug("Applying changes for pool '%s'", pool.get_name())
try:
do_auto = self.widget("pool-autostart").get_active()
pool.set_autostart(do_auto)
if EDIT_POOL_AUTOSTART in self.active_edits:
auto = self.widget("pool-autostart").get_active()
pool.set_autostart(auto)
if EDIT_POOL_NAME in self.active_edits:
pool.define_name(self.widget("pool-name-entry").get_text())
self.repopulate_storage_pools()
except Exception, e:
self.err.show_err(_("Error setting pool autostart: %s") % str(e))
return
self.disable_pool_apply()
def disable_pool_apply(self):
self.active_edits = []
self.widget("pool-apply").set_sensitive(False)
def enable_pool_apply(self, *arglist):
edittype = arglist[-1]
self.widget("pool-apply").set_sensitive(True)
if edittype not in self.active_edits:
self.active_edits.append(edittype)
def pool_autostart_changed(self, src_ignore):
auto = self.widget("pool-autostart").get_active()
self.widget("pool-autostart").set_label(auto and
_("On Boot") or
_("Never"))
self.widget("pool-apply").set_sensitive(True)
self.enable_pool_apply(EDIT_POOL_AUTOSTART)
def set_storage_error_page(self, msg):
self.reset_pool_state()
@ -858,8 +878,7 @@ class vmmHost(vmmGObjectUI):
except Exception, e:
logging.exception(e)
self.set_storage_error_page(_("Error selecting pool: %s") % e)
self.widget("pool-apply").set_sensitive(False)
self.disable_pool_apply()
def populate_pool_state(self, uuid):
pool = self.conn.get_pool(uuid)
@ -871,6 +890,8 @@ class vmmHost(vmmGObjectUI):
self.widget("pool-details").set_sensitive(True)
self.widget("pool-name").set_markup("<b>%s:</b>" %
pool.get_name())
self.widget("pool-name-entry").set_text(pool.get_name())
self.widget("pool-name-entry").set_editable(not active)
self.widget("pool-sizes").set_markup(
"""<span size="large">%s Free</span> / <i>%s In Use</i>""" %
(pool.get_pretty_available(), pool.get_pretty_allocation()))
@ -915,6 +936,7 @@ class vmmHost(vmmGObjectUI):
def reset_pool_state(self):
self.widget("pool-details").set_sensitive(False)
self.widget("pool-name").set_text("")
self.widget("pool-name-entry").set_text("")
self.widget("pool-sizes").set_markup("""<span size="large"> </span>""")
self.widget("pool-type").set_text("")
self.widget("pool-location").set_text("")
@ -928,10 +950,10 @@ class vmmHost(vmmGObjectUI):
self.widget("pool-delete").set_sensitive(False)
self.widget("pool-stop").set_sensitive(False)
self.widget("pool-start").set_sensitive(False)
self.widget("pool-apply").set_sensitive(False)
self.widget("vol-add").set_sensitive(False)
self.widget("vol-delete").set_sensitive(False)
self.widget("vol-list").set_sensitive(False)
self.disable_pool_apply()
def vol_selected(self, src):
selected = src.get_selected()

View File

@ -174,6 +174,10 @@ class vmmStoragePool(vmmLibvirtObject):
self._backend.refresh(0)
self.idle_add(cb)
def define_name(self, newname):
return self._define_name_helper("storagepool",
self.conn.rename_pool,
newname)
###################
# Volume handling #