createvol: Add UI for specifying backing store
This commit is contained in:
parent
cd7837bc4b
commit
b6adf48e56
106
ui/createvol.ui
106
ui/createvol.ui
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.15.4 on Fri Sep 27 13:04:46 2013 -->
|
||||
<!-- Generated with glade 3.16.0 on Sun Sep 29 10:15:56 2013 -->
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<object class="GtkAdjustment" id="adjustment1">
|
||||
|
@ -19,6 +19,11 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-new</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-open</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="vmm-create-vol">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Add a Storage Volume</property>
|
||||
|
@ -112,16 +117,16 @@
|
|||
<property name="label" translatable="yes">Create a storage unit to be used directly by a virtual machine.</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox4">
|
||||
<object class="GtkGrid" id="vbox4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">24</property>
|
||||
<property name="row_spacing">18</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="table1">
|
||||
<property name="visible">True</property>
|
||||
|
@ -201,7 +206,7 @@
|
|||
<object class="GtkLabel" id="label5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">_Format:</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="mnemonic_widget">vol-format</property>
|
||||
|
@ -215,13 +220,14 @@
|
|||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
<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>
|
||||
<object class="GtkVBox" id="vbox5">
|
||||
<object class="GtkVBox" id="size-box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="spacing">5</property>
|
||||
|
@ -311,9 +317,11 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="text" translatable="yes">1.0</property>
|
||||
<property name="adjustment">adjustment2</property>
|
||||
<property name="climb_rate">10</property>
|
||||
<property name="digits">1</property>
|
||||
<property name="value">1</property>
|
||||
<signal name="value-changed" handler="on_vol_capacity_value_changed" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
|
@ -328,9 +336,11 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="text" translatable="yes">1.0</property>
|
||||
<property name="adjustment">adjustment1</property>
|
||||
<property name="climb_rate">10</property>
|
||||
<property name="digits">1</property>
|
||||
<property name="value">1</property>
|
||||
<signal name="value-changed" handler="on_vol_allocation_value_changed" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
|
@ -409,9 +419,81 @@
|
|||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
<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>
|
||||
<object class="GtkExpander" id="backing-expander">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="vexpand">False</property>
|
||||
<child>
|
||||
<object class="GtkGrid" id="grid1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="column_spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label11">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Path:</property>
|
||||
</object>
|
||||
<packing>
|
||||
<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>
|
||||
<object class="GtkEntry" id="backing-store">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<signal name="changed" handler="on_backing_store_changed" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="backing-browse">
|
||||
<property name="label" translatable="yes">Browse...</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="image">image2</property>
|
||||
<signal name="clicked" handler="on_backing_browse_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="width">1</property>
|
||||
<property name="height">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">False</property>
|
||||
<property name="label" translatable="yes">Backing store</property>
|
||||
</object>
|
||||
</child>
|
||||
</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>
|
||||
</object>
|
||||
|
|
|
@ -45,14 +45,18 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
|
||||
self.name_hint = None
|
||||
self.vol = None
|
||||
self.storage_browser = None
|
||||
|
||||
self.builder.connect_signals({
|
||||
"on_vmm_create_vol_delete_event" : self.close,
|
||||
"on_vol_cancel_clicked" : self.close,
|
||||
"on_vol_create_clicked" : self.finish,
|
||||
|
||||
"on_vol_name_changed" : self.vol_name_changed,
|
||||
"on_vol_allocation_value_changed" : self.vol_allocation_changed,
|
||||
"on_vol_capacity_value_changed" : self.vol_capacity_changed,
|
||||
"on_backing_store_changed" : self.backing_store_changed,
|
||||
"on_backing_browse_clicked" : self.browse_backing,
|
||||
})
|
||||
self.bind_escape_key_close()
|
||||
|
||||
|
@ -69,6 +73,8 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
def close(self, ignore1=None, ignore2=None):
|
||||
logging.debug("Closing new volume wizard")
|
||||
self.topwin.hide()
|
||||
if self.storage_browser:
|
||||
self.storage_browser.close()
|
||||
self.set_modal(False)
|
||||
return 1
|
||||
|
||||
|
@ -76,6 +82,10 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
self.conn = None
|
||||
self.parent_pool = None
|
||||
|
||||
if self.storage_browser:
|
||||
self.storage_browser.cleanup()
|
||||
self.storage_browser = None
|
||||
|
||||
def set_name_hint(self, hint):
|
||||
self.name_hint = hint
|
||||
|
||||
|
@ -124,6 +134,11 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
self.vol = StorageVolume(self.conn.get_backend())
|
||||
self.vol.pool = self.parent_pool.get_backend()
|
||||
|
||||
def _can_alloc(self):
|
||||
# Sparse LVM volumes don't auto grow, so alloc=0 is useless
|
||||
islogical = (self.parent_pool.get_type() == "logical")
|
||||
return not islogical
|
||||
|
||||
def reset_state(self):
|
||||
self._make_stub_vol()
|
||||
|
||||
|
@ -139,14 +154,19 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
|
||||
default_alloc = 0
|
||||
default_cap = 8
|
||||
islogical = (self.parent_pool.get_type() == "logical")
|
||||
|
||||
alloc = default_alloc
|
||||
if islogical:
|
||||
# Sparse LVM volumes don't auto grow, so alloc=0 is useless
|
||||
alloc = default_alloc
|
||||
if not self._can_alloc():
|
||||
alloc = default_cap
|
||||
uihelpers.set_grid_row_visible(self.widget("vol-allocation"),
|
||||
not islogical)
|
||||
self._can_alloc())
|
||||
|
||||
canbacking = (self.parent_pool.get_type() == "logical"
|
||||
or self.vol.TYPE_FILE == self.vol.TYPE_FILE)
|
||||
uihelpers.set_grid_row_visible(self.widget("backing-expander"),
|
||||
canbacking)
|
||||
self.widget("backing-expander").set_expanded(False)
|
||||
self.widget("backing-store").set_text("")
|
||||
|
||||
self.widget("vol-allocation").set_range(0,
|
||||
int(self.parent_pool.get_available() / 1024 / 1024 / 1024))
|
||||
|
@ -216,6 +236,16 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
if cap < alloc:
|
||||
alloc_widget.set_value(cap)
|
||||
|
||||
def backing_store_changed(self, src):
|
||||
if not self._can_alloc():
|
||||
return
|
||||
uihelpers.set_grid_row_visible(self.widget("vol-allocation"),
|
||||
not bool(src.get_text()))
|
||||
|
||||
def browse_backing(self, src):
|
||||
ignore = src
|
||||
self._browse_file()
|
||||
|
||||
def _finish_cb(self, error, details):
|
||||
self.topwin.set_sensitive(True)
|
||||
self.topwin.get_window().set_cursor(
|
||||
|
@ -272,15 +302,17 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
fmt = self.get_config_format()
|
||||
alloc = self.widget("vol-allocation").get_value()
|
||||
cap = self.widget("vol-capacity").get_value()
|
||||
backing = self.widget("backing-store").get_text()
|
||||
if not self.widget("vol-allocation").get_visible():
|
||||
alloc = cap
|
||||
|
||||
try:
|
||||
self._make_stub_vol()
|
||||
self.vol.capacity = cap
|
||||
self.vol.name = volname
|
||||
self.vol.allocation = (alloc * 1024 * 1024 * 1024)
|
||||
self.vol.capacity = (cap * 1024 * 1024 * 1024)
|
||||
self.vol.allocation = (alloc * 1024 * 1024 * 1024)
|
||||
if backing:
|
||||
self.vol.backing_store = backing
|
||||
if fmt:
|
||||
self.vol.format = fmt
|
||||
self.vol.validate()
|
||||
|
@ -292,12 +324,20 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||
self.err.show_err(info, details, modal=self.topwin.get_modal())
|
||||
|
||||
def val_err(self, info, details):
|
||||
modal = self.topwin.get_modal()
|
||||
ret = False
|
||||
try:
|
||||
self.topwin.set_modal(False)
|
||||
ret = self.err.val_err(info, details, modal=modal)
|
||||
finally:
|
||||
self.topwin.set_modal(modal)
|
||||
return self.err.val_err(info, details, modal=self.topwin.get_modal())
|
||||
|
||||
return ret
|
||||
def _browse_file(self):
|
||||
if self.storage_browser is None:
|
||||
def cb(src, text):
|
||||
ignore = src
|
||||
self.widget("backing-store").set_text(text)
|
||||
|
||||
from virtManager.storagebrowse import vmmStorageBrowser
|
||||
self.storage_browser = vmmStorageBrowser(self.conn)
|
||||
self.storage_browser.connect("storage-browse-finish", cb)
|
||||
self.storage_browser.topwin.set_modal(self.topwin.get_modal())
|
||||
self.storage_browser.can_new_volume = False
|
||||
self.storage_browser.set_browse_reason(
|
||||
self.config.CONFIG_DIR_IMAGE)
|
||||
|
||||
self.storage_browser.show(self.topwin, self.conn)
|
||||
|
|
|
@ -44,6 +44,7 @@ class vmmStorageBrowser(vmmGObjectUI):
|
|||
|
||||
self.conn_signal_ids = []
|
||||
self.finish_cb_id = None
|
||||
self.can_new_volume = True
|
||||
|
||||
# Add Volume wizard
|
||||
self.addvol = None
|
||||
|
@ -200,6 +201,8 @@ class vmmStorageBrowser(vmmGObjectUI):
|
|||
self.local_args["dialog_type"] = data.get("dialog_type")
|
||||
self.local_args["choose_button"] = data.get("choose_button")
|
||||
|
||||
self.widget("new-volume").set_visible(self.can_new_volume)
|
||||
|
||||
|
||||
# Convenience helpers
|
||||
def allow_create(self):
|
||||
|
|
Loading…
Reference in New Issue