mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-25 23:21:45 +03:00
Add destroy option to details and console menus
This commit is contained in:
parent
e2d5bdf197
commit
e4d8bf592c
@ -643,7 +643,7 @@ Jeremy Katz <katzj@redhat.com>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="details-menu-shutdown">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Shutdown</property>
|
||||
<property name="label" translatable="yes">S_hutdown</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_details_menu_shutdown_activate" last_modification_time="Fri, 01 Sep 2006 14:58:20 GMT"/>
|
||||
</widget>
|
||||
@ -658,6 +658,15 @@ Jeremy Katz <katzj@redhat.com>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="details-menu-destroy">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Destroy</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_details_menu_destroy_activate" last_modification_time="Wed, 15 Nov 2006 16:07:29 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separator8">
|
||||
<property name="visible">True</property>
|
||||
@ -3268,7 +3277,7 @@ For all domains</property>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu-vm-shutdown">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Shutdown</property>
|
||||
<property name="label" translatable="yes">S_hutdown</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menu_vm_shutdown_activate" last_modification_time="Fri, 14 Jul 2006 14:26:39 GMT"/>
|
||||
</widget>
|
||||
@ -3283,6 +3292,15 @@ For all domains</property>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menu-vm-destroy">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Destroy</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_menu_vm_destroy_activate" last_modification_time="Wed, 15 Nov 2006 16:47:34 GMT"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkSeparatorMenuItem" id="separatormenuitem2">
|
||||
<property name="visible">True</property>
|
||||
|
@ -33,6 +33,8 @@ class vmmConsole(gobject.GObject):
|
||||
"action-show-terminal": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
"action-save-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
"action-destroy-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str))
|
||||
}
|
||||
def __init__(self, config, vm):
|
||||
@ -74,6 +76,7 @@ class vmmConsole(gobject.GObject):
|
||||
"on_menu_vm_shutdown_activate": self.control_vm_shutdown,
|
||||
"on_menu_vm_pause_activate": self.control_vm_pause,
|
||||
"on_menu_vm_save_activate": self.control_vm_save_domain,
|
||||
"on_menu_vm_destroy_activate": self.control_vm_destroy,
|
||||
"on_menu_vm_screenshot_activate": self.control_vm_screenshot,
|
||||
|
||||
"on_menu_view_serial_activate": self.control_vm_terminal,
|
||||
@ -334,6 +337,9 @@ class vmmConsole(gobject.GObject):
|
||||
def control_vm_save_domain(self, src):
|
||||
self.emit("action-save-domain", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
|
||||
def control_vm_destroy(self, src):
|
||||
self.emit("action-destroy-domain", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
|
||||
def control_vm_details(self, src):
|
||||
self.emit("action-show-details", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
|
||||
@ -351,6 +357,12 @@ class vmmConsole(gobject.GObject):
|
||||
else:
|
||||
self.window.get_widget("menu-view-serial").set_sensitive(False)
|
||||
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF ] or vm.is_read_only():
|
||||
# apologies for the spaghetti, but the destroy choice is a special case
|
||||
self.window.get_widget("menu-vm-destroy").set_sensitive(False)
|
||||
else:
|
||||
self.window.get_widget("menu-vm-destroy").set_sensitive(True)
|
||||
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF ,libvirt.VIR_DOMAIN_CRASHED ] or vm.is_read_only():
|
||||
self.window.get_widget("control-pause").set_sensitive(False)
|
||||
self.window.get_widget("control-shutdown").set_sensitive(False)
|
||||
|
@ -124,7 +124,7 @@ class vmmCreate(gobject.GObject):
|
||||
self.hal_iface = None
|
||||
msg = gtk.MessageDialog(parent=None, flags=0, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK,
|
||||
message_format="Unable to enumerate CDROM volumes")
|
||||
msg.format_secondary_text("Can not connect to HAL device manager")
|
||||
msg.format_secondary_text("Cannot connect to HAL device manager")
|
||||
msg.run()
|
||||
msg.destroy()
|
||||
|
||||
|
@ -31,6 +31,8 @@ class vmmDetails(gobject.GObject):
|
||||
"action-show-terminal": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
"action-save-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str)),
|
||||
"action-destroy-domain": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE, (str,str))
|
||||
}
|
||||
def __init__(self, config, vm):
|
||||
@ -97,6 +99,7 @@ class vmmDetails(gobject.GObject):
|
||||
"on_details_menu_pause_activate": self.control_vm_pause,
|
||||
"on_details_menu_shutdown_activate": self.control_vm_shutdown,
|
||||
"on_details_menu_save_activate": self.control_vm_save_domain,
|
||||
"on_details_menu_destroy_activate": self.control_vm_destroy,
|
||||
|
||||
"on_details_menu_graphics_activate": self.control_vm_console,
|
||||
"on_details_menu_serial_activate": self.control_vm_terminal,
|
||||
@ -221,8 +224,16 @@ class vmmDetails(gobject.GObject):
|
||||
def control_vm_save_domain(self, src):
|
||||
self.emit("action-save-domain", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
|
||||
def control_vm_destroy(self, src):
|
||||
self.emit("action-destroy-domain", self.vm.get_connection().get_uri(), self.vm.get_uuid())
|
||||
|
||||
def update_widget_states(self, vm, status):
|
||||
self.ignorePause = True
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN, libvirt.VIR_DOMAIN_SHUTOFF ] or vm.is_read_only():
|
||||
# apologies for the spaghetti, but the destroy choice is a special case
|
||||
self.window.get_widget("details-menu-destroy").set_sensitive(False)
|
||||
else:
|
||||
self.window.get_widget("details-menu-destroy").set_sensitive(True)
|
||||
try:
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTOFF, libvirt.VIR_DOMAIN_CRASHED ]:
|
||||
self.window.get_widget("control-run").set_sensitive(True)
|
||||
|
@ -63,7 +63,7 @@ class vmmDomain(gobject.GObject):
|
||||
if id < 0:
|
||||
return "-"
|
||||
return str(id)
|
||||
|
||||
|
||||
def get_name(self):
|
||||
return self.vm.name()
|
||||
|
||||
@ -318,6 +318,9 @@ class vmmDomain(gobject.GObject):
|
||||
self.vm.save(file)
|
||||
self._update_status()
|
||||
|
||||
def destroy(self):
|
||||
self.vm.destroy()
|
||||
|
||||
def status(self):
|
||||
return self.lastStatus
|
||||
|
||||
|
@ -165,6 +165,8 @@ class vmmEngine:
|
||||
self.show_serial_console(uri, uuid)
|
||||
def _do_save_domain(self, src, uri, uuid):
|
||||
self.save_domain(src, uri, uuid)
|
||||
def _do_destroy_domain(self, src, uri, uuid):
|
||||
self.destroy_domain(src, uri, uuid)
|
||||
|
||||
def show_about(self):
|
||||
if self.windowAbout == None:
|
||||
@ -192,6 +194,7 @@ class vmmEngine:
|
||||
console.connect("action-show-details", self._do_show_details)
|
||||
console.connect("action-show-terminal", self._do_show_terminal)
|
||||
console.connect("action-save-domain", self._do_save_domain)
|
||||
console.connect("action-destroy-domain", self._do_destroy_domain)
|
||||
self.connections[uri]["windowConsole"][uuid] = console
|
||||
self.connections[uri]["windowConsole"][uuid].show()
|
||||
|
||||
@ -221,6 +224,7 @@ class vmmEngine:
|
||||
details.connect("action-show-console", self._do_show_console)
|
||||
details.connect("action-show-terminal", self._do_show_terminal)
|
||||
details.connect("action-save-domain", self._do_save_domain)
|
||||
details.connect("action-destroy-domain", self._do_destroy_domain)
|
||||
self.connections[uri]["windowDetails"][uuid] = details
|
||||
self.connections[uri]["windowDetails"][uuid].show()
|
||||
return self.connections[uri]["windowDetails"][uuid]
|
||||
@ -290,3 +294,24 @@ class vmmEngine:
|
||||
_("Saving Virtual Machine"))
|
||||
progWin.run()
|
||||
self.fcdialog.destroy()
|
||||
|
||||
def destroy_domain(self, src, uri, uuid):
|
||||
con = self.get_connection(uri, False)
|
||||
vm = con.get_vm(uuid)
|
||||
status = vm.status()
|
||||
if status in [ libvirt.VIR_DOMAIN_SHUTDOWN,
|
||||
libvirt.VIR_DOMAIN_SHUTOFF ]:
|
||||
logging.warning("Destroy requested, but machine is shutdown / shutoff")
|
||||
else:
|
||||
message_box = gtk.MessageDialog(None, \
|
||||
gtk.DIALOG_MODAL, \
|
||||
gtk.MESSAGE_WARNING, \
|
||||
gtk.BUTTONS_OK_CANCEL, \
|
||||
_("About to destroy virtual machine %s" % vm.get_name()))
|
||||
message_box.format_secondary_text(_("This will immediately destroy the VM and may corrupt its disk image. Are you sure?"))
|
||||
response_id = message_box.run()
|
||||
message_box.destroy()
|
||||
if response_id == gtk.RESPONSE_OK:
|
||||
vm.destroy()
|
||||
else:
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user