mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-16 18:25:02 -06:00
details: Show disk size if available
This commit is contained in:
parent
5f6a59f118
commit
ac43f4ebe0
@ -105,6 +105,12 @@ def prettyify_disk(devtype, bus, idx):
|
||||
|
||||
return "%s %s" % (ret, idx)
|
||||
|
||||
def prettyify_bytes(bytes):
|
||||
if bytes > (1024*1024*1024):
|
||||
return "%2.2f GB" % (bytes/(1024.0*1024.0*1024.0))
|
||||
else:
|
||||
return "%2.2f MB" % (bytes/(1024.0*1024.0))
|
||||
|
||||
class vmmDetails(gobject.GObject):
|
||||
__gsignals__ = {
|
||||
"action-show-console": (gobject.SIGNAL_RUN_FIRST,
|
||||
@ -1643,6 +1649,18 @@ class vmmDetails(gobject.GObject):
|
||||
bus = diskinfo[8]
|
||||
idx = diskinfo[9]
|
||||
|
||||
size = _("Unknown")
|
||||
if not path:
|
||||
size = "-"
|
||||
else:
|
||||
vol = self.conn.get_vol_by_path(path)
|
||||
if vol:
|
||||
size = vol.get_pretty_capacity()
|
||||
elif not self.conn.is_remote():
|
||||
ignore, bytes = virtinst.VirtualDisk.stat_local_path(path)
|
||||
if bytes != 0:
|
||||
size = prettyify_bytes(bytes)
|
||||
|
||||
is_cdrom = (devtype == virtinst.VirtualDisk.DEVICE_CDROM)
|
||||
is_floppy = (devtype == virtinst.VirtualDisk.DEVICE_FLOPPY)
|
||||
|
||||
@ -1654,6 +1672,7 @@ class vmmDetails(gobject.GObject):
|
||||
self.window.get_widget("disk-readonly").set_active(ro)
|
||||
self.window.get_widget("disk-readonly").set_sensitive(not is_cdrom)
|
||||
self.window.get_widget("disk-shareable").set_active(share)
|
||||
self.window.get_widget("disk-size").set_text(size)
|
||||
|
||||
button = self.window.get_widget("config-cdrom-connect")
|
||||
if is_cdrom or is_floppy:
|
||||
|
@ -2558,7 +2558,7 @@ I/O:</property>
|
||||
<widget class="GtkTable" id="table32">
|
||||
<property name="visible">True</property>
|
||||
<property name="border_width">3</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_rows">5</property>
|
||||
<property name="n_columns">3</property>
|
||||
<property name="column_spacing">8</property>
|
||||
<property name="row_spacing">4</property>
|
||||
@ -2707,6 +2707,34 @@ I/O:</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label4">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Storage size:</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">4</property>
|
||||
<property name="bottom_attach">5</property>
|
||||
<property name="x_options">GTK_FILL</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="disk-size">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">size</property>
|
||||
</widget>
|
||||
<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>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user