delete: Add _delete_disks method
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
52782a4958
commit
928c049c9d
|
@ -44,7 +44,6 @@ class _vmmDeleteBase(vmmGObjectUI):
|
|||
def __init__(self):
|
||||
vmmGObjectUI.__init__(self, "delete.ui", "vmm-delete")
|
||||
self.vm = None
|
||||
self.disk = None
|
||||
|
||||
self.builder.connect_signals({
|
||||
"on_vmm_delete_delete_event": self.close,
|
||||
|
@ -72,6 +71,21 @@ class _vmmDeleteBase(vmmGObjectUI):
|
|||
def _delete_vm(self, vm):
|
||||
raise NotImplementedError
|
||||
|
||||
def _delete_disks(self, vm, paths, conn, meter):
|
||||
storage_errors = []
|
||||
if not paths:
|
||||
return
|
||||
for path in paths:
|
||||
try:
|
||||
log.debug("Deleting path: %s", path)
|
||||
meter.start(text=_("Deleting path '%s'") % path)
|
||||
self._async_delete_dev(vm, conn, path, meter)
|
||||
except Exception as e:
|
||||
storage_errors.append((str(e),
|
||||
"".join(traceback.format_exc())))
|
||||
meter.end(0)
|
||||
return storage_errors
|
||||
|
||||
def _init_state(self):
|
||||
blue = Gdk.Color.parse("#0072A8")[1]
|
||||
self.widget("header").modify_bg(Gtk.StateType.NORMAL, blue)
|
||||
|
@ -198,7 +212,6 @@ class _vmmDeleteBase(vmmGObjectUI):
|
|||
self._set_vm(None)
|
||||
|
||||
def _async_delete(self, asyncjob, vm, paths):
|
||||
storage_errors = []
|
||||
details = ""
|
||||
|
||||
try:
|
||||
|
@ -208,18 +221,7 @@ class _vmmDeleteBase(vmmGObjectUI):
|
|||
|
||||
conn = vm.conn.get_backend()
|
||||
meter = asyncjob.get_meter()
|
||||
if not paths and self.disk:
|
||||
vm.remove_device(self.disk)
|
||||
|
||||
for path in paths:
|
||||
try:
|
||||
log.debug("Deleting path: %s", path)
|
||||
meter.start(text=_("Deleting path '%s'") % path)
|
||||
self._async_delete_dev(vm, conn, path, meter)
|
||||
except Exception as e:
|
||||
storage_errors.append((str(e),
|
||||
"".join(traceback.format_exc())))
|
||||
meter.end(0)
|
||||
storage_errors = self._delete_disks(vm, paths, conn, meter)
|
||||
|
||||
self._delete_vm(vm)
|
||||
except Exception as e:
|
||||
|
@ -227,7 +229,6 @@ class _vmmDeleteBase(vmmGObjectUI):
|
|||
(vm.get_name(), str(e)))
|
||||
details = "".join(traceback.format_exc())
|
||||
|
||||
|
||||
storage_errstr = ""
|
||||
for errinfo in storage_errors:
|
||||
storage_errstr += "%s\n%s\n" % (errinfo[0], errinfo[1])
|
||||
|
@ -322,6 +323,13 @@ class vmmDeleteStorage(_vmmDeleteBase):
|
|||
def _delete_vm(self, vm):
|
||||
pass
|
||||
|
||||
def _delete_disks(self, vm, paths, conn, meter):
|
||||
storage_errors = []
|
||||
vm.remove_device(self.disk)
|
||||
if paths:
|
||||
super()._delete_disks(vm, paths, conn, meter)
|
||||
return storage_errors
|
||||
|
||||
|
||||
###################
|
||||
# UI init helpers #
|
||||
|
|
Loading…
Reference in New Issue