mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
Switch to python3 style 'except X as Y' notation
Which also works with python2.7
This commit is contained in:
parent
fcebefd3bb
commit
62feeb02a8
@ -162,7 +162,7 @@ class Command(object):
|
|||||||
ret = virtconvert.main(conn=conn)
|
ret = virtconvert.main(conn=conn)
|
||||||
elif app.count("virt-xml"):
|
elif app.count("virt-xml"):
|
||||||
ret = virtxml.main(conn=conn)
|
ret = virtxml.main(conn=conn)
|
||||||
except SystemExit, sys_e:
|
except SystemExit as sys_e:
|
||||||
ret = sys_e.code
|
ret = sys_e.code
|
||||||
except Exception:
|
except Exception:
|
||||||
ret = -1
|
ret = -1
|
||||||
@ -193,7 +193,7 @@ class Command(object):
|
|||||||
|
|
||||||
logging.debug(output + "\n")
|
logging.debug(output + "\n")
|
||||||
return code, output
|
return code, output
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return (-1, "".join(traceback.format_exc()) + str(e))
|
return (-1, "".join(traceback.format_exc()) + str(e))
|
||||||
|
|
||||||
def _check_support(self, tests, conn, check, skipmsg):
|
def _check_support(self, tests, conn, check, skipmsg):
|
||||||
@ -264,7 +264,7 @@ class Command(object):
|
|||||||
|
|
||||||
utils.diff_compare(output, filename)
|
utils.diff_compare(output, filename)
|
||||||
|
|
||||||
except AssertionError, e:
|
except AssertionError as e:
|
||||||
err = self.cmdstr + "\n" + str(e)
|
err = self.cmdstr + "\n" + str(e)
|
||||||
|
|
||||||
if err:
|
if err:
|
||||||
|
@ -134,7 +134,7 @@ class TestClone(unittest.TestCase):
|
|||||||
# We shouldn't succeed, so test fails
|
# We shouldn't succeed, so test fails
|
||||||
raise AssertionError("Remote clone with storage passed "
|
raise AssertionError("Remote clone with storage passed "
|
||||||
"when it shouldn't.")
|
"when it shouldn't.")
|
||||||
except (ValueError, RuntimeError), e:
|
except (ValueError, RuntimeError) as e:
|
||||||
# Exception expected
|
# Exception expected
|
||||||
logging.debug("Received expected exception: %s", str(e))
|
logging.debug("Received expected exception: %s", str(e))
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ def _fetch_distro(distro):
|
|||||||
cleanup.append(initrd)
|
cleanup.append(initrd)
|
||||||
distro.kernel = kernel
|
distro.kernel = kernel
|
||||||
distro.initrd = initrd
|
distro.initrd = initrd
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print "fetching distro=%s failed: %s" % (distro.name, e)
|
print "fetching distro=%s failed: %s" % (distro.name, e)
|
||||||
finally:
|
finally:
|
||||||
fetcher.cleanupLocation()
|
fetcher.cleanupLocation()
|
||||||
|
@ -200,7 +200,7 @@ def _storeForDistro(fetcher, guest):
|
|||||||
for ignore in range(0, 10):
|
for ignore in range(0, 10):
|
||||||
try:
|
try:
|
||||||
return urlfetcher.getDistroStore(guest, fetcher)
|
return urlfetcher.getDistroStore(guest, fetcher)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if str(e).count("502"):
|
if str(e).count("502"):
|
||||||
logging.debug("Caught proxy error: %s", str(e))
|
logging.debug("Caught proxy error: %s", str(e))
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
|
@ -41,7 +41,7 @@ class _FuzzyPredicate(dogtail.predicate.Predicate):
|
|||||||
if not self._labeller_pattern.match(node.labeller.text):
|
if not self._labeller_pattern.match(node.labeller.text):
|
||||||
return
|
return
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print "got predicate exception: %s" % e
|
print "got predicate exception: %s" % e
|
||||||
|
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ def print_nodes(root):
|
|||||||
def _walk(node):
|
def _walk(node):
|
||||||
try:
|
try:
|
||||||
print node_string(node)
|
print node_string(node)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print "got exception: %s" % e
|
print "got exception: %s" % e
|
||||||
|
|
||||||
root.findChildren(_walk, isLambda=True)
|
root.findChildren(_walk, isLambda=True)
|
||||||
@ -173,7 +173,7 @@ def focused_nodes(root):
|
|||||||
try:
|
try:
|
||||||
if node.focused:
|
if node.focused:
|
||||||
return node
|
return node
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print "got exception: %s" % e
|
print "got exception: %s" % e
|
||||||
|
|
||||||
return root.findChildren(_walk, isLambda=True)
|
return root.findChildren(_walk, isLambda=True)
|
||||||
|
@ -146,7 +146,7 @@ def test_create(testconn, xml, define_func="defineXML"):
|
|||||||
try:
|
try:
|
||||||
func = getattr(testconn, define_func)
|
func = getattr(testconn, define_func)
|
||||||
obj = func(xml)
|
obj = func(xml)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise RuntimeError(str(e) + "\n" + xml)
|
raise RuntimeError(str(e) + "\n" + xml)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -52,7 +52,7 @@ def get_original_guest(guest_name, origfile, design):
|
|||||||
try:
|
try:
|
||||||
design.original_xml = origxml
|
design.original_xml = origxml
|
||||||
return
|
return
|
||||||
except (ValueError, RuntimeError), e:
|
except (ValueError, RuntimeError) as e:
|
||||||
fail(e)
|
fail(e)
|
||||||
|
|
||||||
if not guest_name:
|
if not guest_name:
|
||||||
@ -219,9 +219,9 @@ def main(conn=None):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
except SystemExit, sys_e:
|
except SystemExit as sys_e:
|
||||||
sys.exit(sys_e.code)
|
sys.exit(sys_e.code)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print_stderr(_("Installation aborted at user request"))
|
print_stderr(_("Installation aborted at user request"))
|
||||||
except Exception, main_e:
|
except Exception as main_e:
|
||||||
fail(main_e)
|
fail(main_e)
|
||||||
|
@ -133,9 +133,9 @@ def main(conn=None):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
except SystemExit, sys_e:
|
except SystemExit as sys_e:
|
||||||
sys.exit(sys_e.code)
|
sys.exit(sys_e.code)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print_stderr(_("Aborted at user request"))
|
print_stderr(_("Aborted at user request"))
|
||||||
except Exception, main_e:
|
except Exception as main_e:
|
||||||
fail(main_e)
|
fail(main_e)
|
||||||
|
14
virt-install
14
virt-install
@ -367,7 +367,7 @@ def get_guest(conn, options):
|
|||||||
arch=arch,
|
arch=arch,
|
||||||
typ=req_hv_type,
|
typ=req_hv_type,
|
||||||
machine=options.machine)
|
machine=options.machine)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
fail(e)
|
fail(e)
|
||||||
|
|
||||||
if (not req_virt_type and
|
if (not req_virt_type and
|
||||||
@ -400,7 +400,7 @@ def set_install_media(guest, location, cdpath, distro_variant):
|
|||||||
guest.os_variant = guest.installer.detect_distro(guest)
|
guest.os_variant = guest.installer.detect_distro(guest)
|
||||||
elif distro_variant != "none":
|
elif distro_variant != "none":
|
||||||
guest.os_variant = distro_variant
|
guest.os_variant = distro_variant
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
fail(_("Error validating install location: %s") % str(e))
|
fail(_("Error validating install location: %s") % str(e))
|
||||||
|
|
||||||
|
|
||||||
@ -627,7 +627,7 @@ def build_guest_instance(conn, options):
|
|||||||
guest.os.nvram is None):
|
guest.os.nvram is None):
|
||||||
try:
|
try:
|
||||||
guest.set_uefi_default()
|
guest.set_uefi_default()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error setting UEFI default for aarch64",
|
logging.debug("Error setting UEFI default for aarch64",
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
logging.warn("Couldn't configure UEFI: %s", e)
|
logging.warn("Couldn't configure UEFI: %s", e)
|
||||||
@ -713,7 +713,7 @@ def start_install(guest, options):
|
|||||||
logging.debug("", exc_info=True)
|
logging.debug("", exc_info=True)
|
||||||
print_stderr(_("Domain install interrupted."))
|
print_stderr(_("Domain install interrupted."))
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
fail(e, do_exit=False)
|
fail(e, do_exit=False)
|
||||||
if guest.domain is None:
|
if guest.domain is None:
|
||||||
guest.cleanup_created_disks(meter)
|
guest.cleanup_created_disks(meter)
|
||||||
@ -736,7 +736,7 @@ def check_domain(guest, conscb, transient,
|
|||||||
fail(_("Domain has crashed."))
|
fail(_("Domain has crashed."))
|
||||||
|
|
||||||
return not guest.domain.isActive()
|
return not guest.domain.isActive()
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if transient and e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
if transient and e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
logging.debug("transient VM shutdown and disappeared.")
|
logging.debug("transient VM shutdown and disappeared.")
|
||||||
return True
|
return True
|
||||||
@ -995,10 +995,10 @@ def main(conn=None):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
except SystemExit, sys_e:
|
except SystemExit as sys_e:
|
||||||
sys.exit(sys_e.code)
|
sys.exit(sys_e.code)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logging.debug("", exc_info=True)
|
logging.debug("", exc_info=True)
|
||||||
print_stderr(_("Installation aborted at user request"))
|
print_stderr(_("Installation aborted at user request"))
|
||||||
except Exception, main_e:
|
except Exception as main_e:
|
||||||
fail(main_e)
|
fail(main_e)
|
||||||
|
@ -85,7 +85,7 @@ def _import_gtk(leftovers):
|
|||||||
globals()["Gtk"] = Gtk
|
globals()["Gtk"] = Gtk
|
||||||
import virtManager.config
|
import virtManager.config
|
||||||
ignore = virtManager.config
|
ignore = virtManager.config
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Don't just let the exception raise here. abrt reports bugs
|
# Don't just let the exception raise here. abrt reports bugs
|
||||||
# when users mess up su/sudo and DISPLAY isn't set. Printing
|
# when users mess up su/sudo and DISPLAY isn't set. Printing
|
||||||
# it avoids the issue
|
# it avoids the issue
|
||||||
@ -282,7 +282,7 @@ if __name__ == "__main__":
|
|||||||
logging.debug("Received KeyboardInterrupt. Exiting application.")
|
logging.debug("Received KeyboardInterrupt. Exiting application.")
|
||||||
except SystemExit:
|
except SystemExit:
|
||||||
raise
|
raise
|
||||||
except Exception, run_e:
|
except Exception as run_e:
|
||||||
if "Gtk" not in globals():
|
if "Gtk" not in globals():
|
||||||
raise
|
raise
|
||||||
_show_startup_error(str(run_e), "".join(traceback.format_exc()))
|
_show_startup_error(str(run_e), "".join(traceback.format_exc()))
|
||||||
|
8
virt-xml
8
virt-xml
@ -94,7 +94,7 @@ def get_domain_and_guest(conn, domstr):
|
|||||||
domain = conn.lookupByUUIDString(domstr)
|
domain = conn.lookupByUUIDString(domstr)
|
||||||
else:
|
else:
|
||||||
domain = conn.lookupByName(domstr)
|
domain = conn.lookupByName(domstr)
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
fail(_("Could not find domain '%s': %s") % (domstr, e))
|
fail(_("Could not find domain '%s': %s") % (domstr, e))
|
||||||
|
|
||||||
state = domain.info()[0]
|
state = domain.info()[0]
|
||||||
@ -295,7 +295,7 @@ def update_changes(domain, devs, action, confirm):
|
|||||||
domain.detachDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
domain.detachDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
||||||
elif action == "update":
|
elif action == "update":
|
||||||
domain.updateDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
domain.updateDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
fail(_("Error attempting device %s: %s") % (action, e))
|
fail(_("Error attempting device %s: %s") % (action, e))
|
||||||
|
|
||||||
print_stdout(_("Device %s successful.") % action)
|
print_stdout(_("Device %s successful.") % action)
|
||||||
@ -476,10 +476,10 @@ def main(conn=None):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
except SystemExit, sys_e:
|
except SystemExit as sys_e:
|
||||||
sys.exit(sys_e.code)
|
sys.exit(sys_e.code)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
logging.debug("", exc_info=True)
|
logging.debug("", exc_info=True)
|
||||||
print_stderr(_("Aborted at user request"))
|
print_stderr(_("Aborted at user request"))
|
||||||
except Exception, main_e:
|
except Exception as main_e:
|
||||||
fail(main_e)
|
fail(main_e)
|
||||||
|
@ -779,7 +779,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
else:
|
else:
|
||||||
# Guest XML editing
|
# Guest XML editing
|
||||||
define_func(**define_args)
|
define_func(**define_args)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
err.show_err((_("Error changing VM configuration: %s") %
|
err.show_err((_("Error changing VM configuration: %s") %
|
||||||
str(e)))
|
str(e)))
|
||||||
return False
|
return False
|
||||||
@ -797,7 +797,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
elif hotplug_args:
|
elif hotplug_args:
|
||||||
did_hotplug = True
|
did_hotplug = True
|
||||||
vm.hotplug(**hotplug_args)
|
vm.hotplug(**hotplug_args)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
did_hotplug = True
|
did_hotplug = True
|
||||||
logging.debug("Hotplug failed: %s", str(e))
|
logging.debug("Hotplug failed: %s", str(e))
|
||||||
hotplug_err = ((str(e), "".join(traceback.format_exc())))
|
hotplug_err = ((str(e), "".join(traceback.format_exc())))
|
||||||
@ -1311,7 +1311,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
if controller is not None:
|
if controller is not None:
|
||||||
self.vm.attach_device(controller)
|
self.vm.attach_device(controller)
|
||||||
self.vm.attach_device(self._dev)
|
self.vm.attach_device(self._dev)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Device could not be hotplugged: %s", str(e))
|
logging.debug("Device could not be hotplugged: %s", str(e))
|
||||||
attach_err = (str(e), "".join(traceback.format_exc()))
|
attach_err = (str(e), "".join(traceback.format_exc()))
|
||||||
|
|
||||||
@ -1335,7 +1335,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
if controller is not None:
|
if controller is not None:
|
||||||
self.vm.add_device(controller)
|
self.vm.add_device(controller)
|
||||||
self.vm.add_device(self._dev)
|
self.vm.add_device(self._dev)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error adding device: %s") % str(e))
|
self.err.show_err(_("Error adding device: %s") % str(e))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -1346,7 +1346,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
if not error:
|
if not error:
|
||||||
try:
|
try:
|
||||||
failure = self._add_device()
|
failure = self._add_device()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
failure = True
|
failure = True
|
||||||
error = _("Unable to add device: %s") % str(e)
|
error = _("Unable to add device: %s") % str(e)
|
||||||
details = "".join(traceback.format_exc())
|
details = "".join(traceback.format_exc())
|
||||||
@ -1364,7 +1364,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
if self._validate() is False:
|
if self._validate() is False:
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Uncaught error validating hardware "
|
self.err.show_err(_("Uncaught error validating hardware "
|
||||||
"input: %s") % str(e))
|
"input: %s") % str(e))
|
||||||
return
|
return
|
||||||
@ -1485,7 +1485,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
disk = self.addstorage.validate_storage(self.vm.get_name(),
|
disk = self.addstorage.validate_storage(self.vm.get_name(),
|
||||||
collidelist=collidelist, device=device)
|
collidelist=collidelist, device=device)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Storage parameter error."), e)
|
return self.err.val_err(_("Storage parameter error."), e)
|
||||||
|
|
||||||
if disk is False:
|
if disk is False:
|
||||||
@ -1508,7 +1508,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
disk, controller_model, disks)
|
disk, controller_model, disks)
|
||||||
|
|
||||||
disk.generate_target(used, prefer_ctrl)
|
disk.generate_target(used, prefer_ctrl)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Storage parameter error."), e)
|
return self.err.val_err(_("Storage parameter error."), e)
|
||||||
|
|
||||||
if self.addstorage.validate_disk_object(disk) is False:
|
if self.addstorage.validate_disk_object(disk) is False:
|
||||||
@ -1568,7 +1568,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
raise ValueError(_("invalid listen type"))
|
raise ValueError(_("invalid listen type"))
|
||||||
if keymap:
|
if keymap:
|
||||||
self._dev.keymap = keymap
|
self._dev.keymap = keymap
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
self.err.val_err(_("Graphics device parameter error"), e)
|
self.err.val_err(_("Graphics device parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_sound(self):
|
def _validate_page_sound(self):
|
||||||
@ -1577,7 +1577,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
self._dev = virtinst.VirtualAudio(self.conn.get_backend())
|
self._dev = virtinst.VirtualAudio(self.conn.get_backend())
|
||||||
self._dev.model = smodel
|
self._dev.model = smodel
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Sound device parameter error"), e)
|
return self.err.val_err(_("Sound device parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_hostdev(self):
|
def _validate_page_hostdev(self):
|
||||||
@ -1603,7 +1603,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
return False
|
return False
|
||||||
dev.set_from_nodedev(nodedev)
|
dev.set_from_nodedev(nodedev)
|
||||||
self._dev = dev
|
self._dev = dev
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Host device parameter error"), e)
|
return self.err.val_err(_("Host device parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_char(self):
|
def _validate_page_char(self):
|
||||||
@ -1668,7 +1668,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
|
|
||||||
# Dump XML for sanity checking
|
# Dump XML for sanity checking
|
||||||
self._dev.get_xml_config()
|
self._dev.get_xml_config()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(
|
return self.err.val_err(
|
||||||
_("%s device parameter error") %
|
_("%s device parameter error") %
|
||||||
char_class.virtual_device_type.capitalize(), e)
|
char_class.virtual_device_type.capitalize(), e)
|
||||||
@ -1680,7 +1680,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
self._dev = VirtualVideoDevice(conn)
|
self._dev = VirtualVideoDevice(conn)
|
||||||
self._dev.model = model
|
self._dev.model = model
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Video device parameter error"), e)
|
return self.err.val_err(_("Video device parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_watchdog(self):
|
def _validate_page_watchdog(self):
|
||||||
@ -1692,7 +1692,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
self._dev = VirtualWatchdog(conn)
|
self._dev = VirtualWatchdog(conn)
|
||||||
self._dev.model = model
|
self._dev.model = model
|
||||||
self._dev.action = action
|
self._dev.action = action
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Watchdog parameter error"), e)
|
return self.err.val_err(_("Watchdog parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_filesystem(self):
|
def _validate_page_filesystem(self):
|
||||||
@ -1707,7 +1707,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
self._dev = VirtualSmartCardDevice(conn)
|
self._dev = VirtualSmartCardDevice(conn)
|
||||||
self._dev.mode = mode
|
self._dev.mode = mode
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Smartcard device parameter error"), e)
|
return self.err.val_err(_("Smartcard device parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_usbredir(self):
|
def _validate_page_usbredir(self):
|
||||||
@ -1726,7 +1726,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
self._dev.host = host
|
self._dev.host = host
|
||||||
if service:
|
if service:
|
||||||
self._dev.service = service
|
self._dev.service = service
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("USB redirected device parameter error"),
|
return self.err.val_err(_("USB redirected device parameter error"),
|
||||||
str(e))
|
str(e))
|
||||||
|
|
||||||
@ -1746,7 +1746,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
for param_name, val in value_mappings.items():
|
for param_name, val in value_mappings.items():
|
||||||
if self._dev.supports_property(param_name):
|
if self._dev.supports_property(param_name):
|
||||||
setattr(self._dev, param_name, val)
|
setattr(self._dev, param_name, val)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("TPM device parameter error"), e)
|
return self.err.val_err(_("TPM device parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_panic(self):
|
def _validate_page_panic(self):
|
||||||
@ -1764,7 +1764,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
iobase = self._dev.IOBASE_DEFAULT
|
iobase = self._dev.IOBASE_DEFAULT
|
||||||
for param_name, val in value_mappings.items():
|
for param_name, val in value_mappings.items():
|
||||||
setattr(self._dev, param_name, val)
|
setattr(self._dev, param_name, val)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Panic device parameter error"), e)
|
return self.err.val_err(_("Panic device parameter error"), e)
|
||||||
|
|
||||||
def _validate_page_controller(self):
|
def _validate_page_controller(self):
|
||||||
@ -1857,7 +1857,7 @@ class vmmAddHardware(vmmGObjectUI):
|
|||||||
for param_name, val in value_mappings.items():
|
for param_name, val in value_mappings.items():
|
||||||
if self._dev.supports_property(param_name):
|
if self._dev.supports_property(param_name):
|
||||||
setattr(self._dev, param_name, val)
|
setattr(self._dev, param_name, val)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("RNG device parameter error"), e)
|
return self.err.val_err(_("RNG device parameter error"), e)
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ class vmmAddStorage(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
default_pool.start()
|
default_pool.start()
|
||||||
logging.info("Started pool '%s'", default_pool.get_name())
|
logging.info("Started pool '%s'", default_pool.get_name())
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.show_err(_("Could not start storage_pool "
|
return self.err.show_err(_("Could not start storage_pool "
|
||||||
"'%s': %s") %
|
"'%s': %s") %
|
||||||
(default_pool.get_name(), str(e)))
|
(default_pool.get_name(), str(e)))
|
||||||
|
@ -86,7 +86,7 @@ class vmmMeter(virtinst.progress.BaseMeter):
|
|||||||
def cb_wrapper(callback, asyncjob, *args, **kwargs):
|
def cb_wrapper(callback, asyncjob, *args, **kwargs):
|
||||||
try:
|
try:
|
||||||
callback(asyncjob, *args, **kwargs)
|
callback(asyncjob, *args, **kwargs)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# If job is cancelled, don't report error to user.
|
# If job is cancelled, don't report error to user.
|
||||||
if (isinstance(e, libvirt.libvirtError) and
|
if (isinstance(e, libvirt.libvirtError) and
|
||||||
asyncjob.can_cancel() and
|
asyncjob.can_cancel() and
|
||||||
|
@ -116,7 +116,7 @@ class vmmChooseCD(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.disk.path = path
|
self.disk.path = path
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Invalid Media Path"), e)
|
return self.err.val_err(_("Invalid Media Path"), e)
|
||||||
|
|
||||||
names = self.disk.is_conflict_disk()
|
names = self.disk.is_conflict_disk()
|
||||||
|
@ -405,7 +405,7 @@ class vmmCloneVM(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
cd.skip_target = skip_targets
|
cd.skip_target = skip_targets
|
||||||
cd.setup_original()
|
cd.setup_original()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Disk target '%s' caused clone error",
|
logging.exception("Disk target '%s' caused clone error",
|
||||||
force_target)
|
force_target)
|
||||||
storage_add(str(e))
|
storage_add(str(e))
|
||||||
@ -432,7 +432,7 @@ class vmmCloneVM(vmmGObjectUI):
|
|||||||
|
|
||||||
cd.clone_paths = clone_path
|
cd.clone_paths = clone_path
|
||||||
size = cd.original_disks[0].get_size()
|
size = cd.original_disks[0].get_size()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Error setting generated path '%s'",
|
logging.exception("Error setting generated path '%s'",
|
||||||
clone_path)
|
clone_path)
|
||||||
storage_add(str(e))
|
storage_add(str(e))
|
||||||
@ -469,7 +469,7 @@ class vmmCloneVM(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
newpath = self.generate_clone_path_name(origpath, newname)
|
newpath = self.generate_clone_path_name(origpath, newname)
|
||||||
row[STORAGE_INFO_NEW_PATH] = newpath
|
row[STORAGE_INFO_NEW_PATH] = newpath
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Generating new path from clone name failed: " +
|
logging.debug("Generating new path from clone name failed: " +
|
||||||
str(e))
|
str(e))
|
||||||
|
|
||||||
@ -592,7 +592,7 @@ class vmmCloneVM(vmmGObjectUI):
|
|||||||
self.clone_design.skip_target = skip_targets
|
self.clone_design.skip_target = skip_targets
|
||||||
try:
|
try:
|
||||||
self.clone_design.clone_paths = new_disks
|
self.clone_design.clone_paths = new_disks
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Just log the error and go on. The UI will fail later if needed
|
# Just log the error and go on. The UI will fail later if needed
|
||||||
logging.debug("Error setting clone_paths: %s", str(e))
|
logging.debug("Error setting clone_paths: %s", str(e))
|
||||||
|
|
||||||
@ -695,7 +695,7 @@ class vmmCloneVM(vmmGObjectUI):
|
|||||||
if msg:
|
if msg:
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg)
|
||||||
row[NETWORK_INFO_NEW_MAC] = new
|
row[NETWORK_INFO_NEW_MAC] = new
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error changing MAC address: %s") % str(e))
|
self.err.show_err(_("Error changing MAC address: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -735,7 +735,7 @@ class vmmCloneVM(vmmGObjectUI):
|
|||||||
row[STORAGE_INFO_NEW_PATH] = new_path
|
row[STORAGE_INFO_NEW_PATH] = new_path
|
||||||
row[STORAGE_INFO_MANUAL_PATH] = True
|
row[STORAGE_INFO_MANUAL_PATH] = True
|
||||||
self.populate_storage_lists()
|
self.populate_storage_lists()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error changing storage path: %s") % str(e))
|
self.err.show_err(_("Error changing storage path: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -818,7 +818,7 @@ class vmmCloneVM(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
if not self.validate():
|
if not self.validate():
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Uncaught error validating input: %s") % str(e))
|
self.err.show_err(_("Uncaught error validating input: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class vmmConnect(vmmGObjectUI):
|
|||||||
# Call any API, so we detect if avahi is even available or not
|
# Call any API, so we detect if avahi is even available or not
|
||||||
self.avahiserver.GetAPIVersion()
|
self.avahiserver.GetAPIVersion()
|
||||||
logging.debug("Connected to avahi")
|
logging.debug("Connected to avahi")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.dbus = None
|
self.dbus = None
|
||||||
self.avahiserver = None
|
self.avahiserver = None
|
||||||
logging.debug("Couldn't contact avahi: %s", str(e))
|
logging.debug("Couldn't contact avahi: %s", str(e))
|
||||||
@ -232,7 +232,7 @@ class vmmConnect(vmmGObjectUI):
|
|||||||
|
|
||||||
sig = resint.connect("g-signal", cb)
|
sig = resint.connect("g-signal", cb)
|
||||||
self.browser_sigs.append((resint, sig))
|
self.browser_sigs.append((resint, sig))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
|
|
||||||
def remove_service(self, interface, protocol, name, typ, domain, flags):
|
def remove_service(self, interface, protocol, name, typ, domain, flags):
|
||||||
@ -248,7 +248,7 @@ class vmmConnect(vmmGObjectUI):
|
|||||||
for row in model:
|
for row in model:
|
||||||
if row[0] == name:
|
if row[0] == name:
|
||||||
model.remove(row.iter)
|
model.remove(row.iter)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
|
|
||||||
def add_conn_to_list(self, interface, protocol, name, typ, domain,
|
def add_conn_to_list(self, interface, protocol, name, typ, domain,
|
||||||
@ -271,7 +271,7 @@ class vmmConnect(vmmGObjectUI):
|
|||||||
|
|
||||||
host = self.sanitize_hostname(str(host))
|
host = self.sanitize_hostname(str(host))
|
||||||
model.append([str(address), str(host), str(name)])
|
model.append([str(address), str(host), str(name)])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
|
|
||||||
def start_browse(self):
|
def start_browse(self):
|
||||||
|
@ -161,7 +161,7 @@ def acquire_tgt():
|
|||||||
"/org/gnome/KrbAuthDialog",
|
"/org/gnome/KrbAuthDialog",
|
||||||
"org.freedesktop.KrbAuthDialog", None)
|
"org.freedesktop.KrbAuthDialog", None)
|
||||||
ret = ka.acquireTgt("(s)", "")
|
ret = ka.acquireTgt("(s)", "")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.info("Cannot acquire tgt" + str(e))
|
logging.info("Cannot acquire tgt" + str(e))
|
||||||
ret = False
|
ret = False
|
||||||
return ret
|
return ret
|
||||||
|
@ -281,7 +281,7 @@ class vmmConnection(vmmGObject):
|
|||||||
for vol in pool.get_volumes():
|
for vol in pool.get_volumes():
|
||||||
try:
|
try:
|
||||||
ret.append(vol.get_xmlobj(refresh_if_nec=False))
|
ret.append(vol.get_xmlobj(refresh_if_nec=False))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Fetching volume XML failed: %s", e)
|
logging.debug("Fetching volume XML failed: %s", e)
|
||||||
return ret
|
return ret
|
||||||
self._backend.cb_fetch_all_vols = fetch_all_vols
|
self._backend.cb_fetch_all_vols = fetch_all_vols
|
||||||
@ -550,7 +550,7 @@ class vmmConnection(vmmGObject):
|
|||||||
try:
|
try:
|
||||||
if vol.get_target_path() == path:
|
if vol.get_target_path() == path:
|
||||||
return vol
|
return vol
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Errors can happen if the volume disappeared, bug 1092739
|
# Errors can happen if the volume disappeared, bug 1092739
|
||||||
logging.debug("Error looking up volume from path=%s: %s",
|
logging.debug("Error looking up volume from path=%s: %s",
|
||||||
path, e)
|
path, e)
|
||||||
@ -625,7 +625,7 @@ class vmmConnection(vmmGObject):
|
|||||||
for dev in self.list_nodedevs():
|
for dev in self.list_nodedevs():
|
||||||
try:
|
try:
|
||||||
xmlobj = dev.get_xmlobj()
|
xmlobj = dev.get_xmlobj()
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
# Libvirt nodedev XML fetching can be busted
|
# Libvirt nodedev XML fetching can be busted
|
||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1225771
|
# https://bugzilla.redhat.com/show_bug.cgi?id=1225771
|
||||||
if e.get_error_code() != libvirt.VIR_ERR_NO_NODE_DEVICE:
|
if e.get_error_code() != libvirt.VIR_ERR_NO_NODE_DEVICE:
|
||||||
@ -700,12 +700,12 @@ class vmmConnection(vmmGObject):
|
|||||||
try:
|
try:
|
||||||
# Redefine new domain
|
# Redefine new domain
|
||||||
newobj = define_cb(newxml)
|
newobj = define_cb(newxml)
|
||||||
except Exception, renameerr:
|
except Exception as renameerr:
|
||||||
try:
|
try:
|
||||||
logging.debug("Error defining new name %s XML",
|
logging.debug("Error defining new name %s XML",
|
||||||
obj.class_name(), exc_info=True)
|
obj.class_name(), exc_info=True)
|
||||||
newobj = define_cb(origxml)
|
newobj = define_cb(origxml)
|
||||||
except Exception, fixerr:
|
except Exception as fixerr:
|
||||||
logging.debug("Failed to redefine original %s!",
|
logging.debug("Failed to redefine original %s!",
|
||||||
obj.class_name(), exc_info=True)
|
obj.class_name(), exc_info=True)
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
@ -840,7 +840,7 @@ class vmmConnection(vmmGObject):
|
|||||||
self._domain_lifecycle_event, None))
|
self._domain_lifecycle_event, None))
|
||||||
self.using_domain_events = True
|
self.using_domain_events = True
|
||||||
logging.debug("Using domain events")
|
logging.debug("Using domain events")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.using_domain_events = False
|
self.using_domain_events = False
|
||||||
logging.debug("Error registering domain events: %s", e)
|
logging.debug("Error registering domain events: %s", e)
|
||||||
|
|
||||||
@ -851,7 +851,7 @@ class vmmConnection(vmmGObject):
|
|||||||
self._domain_cb_ids.append(
|
self._domain_cb_ids.append(
|
||||||
self.get_backend().domainEventRegisterAny(
|
self.get_backend().domainEventRegisterAny(
|
||||||
None, eventid, self._domain_xml_misc_event, None))
|
None, eventid, self._domain_xml_misc_event, None))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error registering domain %s event: %s",
|
logging.debug("Error registering domain %s event: %s",
|
||||||
typestr, e)
|
typestr, e)
|
||||||
|
|
||||||
@ -877,7 +877,7 @@ class vmmConnection(vmmGObject):
|
|||||||
None, eventid, self._network_lifecycle_event, None))
|
None, eventid, self._network_lifecycle_event, None))
|
||||||
self.using_network_events = True
|
self.using_network_events = True
|
||||||
logging.debug("Using network events")
|
logging.debug("Using network events")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.using_network_events = False
|
self.using_network_events = False
|
||||||
logging.debug("Error registering network events: %s", e)
|
logging.debug("Error registering network events: %s", e)
|
||||||
|
|
||||||
@ -897,7 +897,7 @@ class vmmConnection(vmmGObject):
|
|||||||
None, refreshid, self._storage_pool_refresh_event, None))
|
None, refreshid, self._storage_pool_refresh_event, None))
|
||||||
self.using_storage_pool_events = True
|
self.using_storage_pool_events = True
|
||||||
logging.debug("Using storage pool events")
|
logging.debug("Using storage pool events")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.using_storage_pool_events = False
|
self.using_storage_pool_events = False
|
||||||
logging.debug("Error registering storage pool events: %s", e)
|
logging.debug("Error registering storage pool events: %s", e)
|
||||||
|
|
||||||
@ -916,7 +916,7 @@ class vmmConnection(vmmGObject):
|
|||||||
|
|
||||||
self.using_node_device_events = True
|
self.using_node_device_events = True
|
||||||
logging.debug("Using node device events")
|
logging.debug("Using node device events")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.using_network_events = False
|
self.using_network_events = False
|
||||||
logging.debug("Error registering node device events: %s", e)
|
logging.debug("Error registering node device events: %s", e)
|
||||||
|
|
||||||
@ -1000,7 +1000,7 @@ class vmmConnection(vmmGObject):
|
|||||||
try:
|
try:
|
||||||
self._backend.open(self._do_creds_password)
|
self._backend.open(self._do_creds_password)
|
||||||
return True, None
|
return True, None
|
||||||
except Exception, exc:
|
except Exception as exc:
|
||||||
tb = "".join(traceback.format_exc())
|
tb = "".join(traceback.format_exc())
|
||||||
if isinstance(exc, libvirt.libvirtError):
|
if isinstance(exc, libvirt.libvirtError):
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
@ -1043,7 +1043,7 @@ class vmmConnection(vmmGObject):
|
|||||||
# We want this before events setup to save some needless polling
|
# We want this before events setup to save some needless polling
|
||||||
try:
|
try:
|
||||||
virtinst.StoragePool.build_default_pool(self.get_backend())
|
virtinst.StoragePool.build_default_pool(self.get_backend())
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Building default pool failed: %s", str(e))
|
logging.debug("Building default pool failed: %s", str(e))
|
||||||
|
|
||||||
self._add_conn_events()
|
self._add_conn_events()
|
||||||
@ -1053,7 +1053,7 @@ class vmmConnection(vmmGObject):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._backend.setKeepAlive(20, 1)
|
self._backend.setKeepAlive(20, 1)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if (type(e) is not AttributeError and
|
if (type(e) is not AttributeError and
|
||||||
not util.is_error_nosupport(e)):
|
not util.is_error_nosupport(e)):
|
||||||
raise
|
raise
|
||||||
@ -1085,7 +1085,7 @@ class vmmConnection(vmmGObject):
|
|||||||
|
|
||||||
self.idle_add(self._change_state, is_active and
|
self.idle_add(self._change_state, is_active and
|
||||||
self._STATE_ACTIVE or self._STATE_DISCONNECTED)
|
self._STATE_ACTIVE or self._STATE_DISCONNECTED)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
is_active = False
|
is_active = False
|
||||||
self._schedule_close()
|
self._schedule_close()
|
||||||
connectError = (str(e), "".join(traceback.format_exc()), False)
|
connectError = (str(e), "".join(traceback.format_exc()), False)
|
||||||
@ -1311,7 +1311,7 @@ class vmmConnection(vmmGObject):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
obj.tick(stats_update=stats_update)
|
obj.tick(stats_update=stats_update)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Tick for %s failed", obj)
|
logging.exception("Tick for %s failed", obj)
|
||||||
if (isinstance(e, libvirt.libvirtError) and
|
if (isinstance(e, libvirt.libvirtError) and
|
||||||
(getattr(e, "get_error_code")() ==
|
(getattr(e, "get_error_code")() ==
|
||||||
@ -1400,7 +1400,7 @@ class vmmConnection(vmmGObject):
|
|||||||
self._tick(*args, **kwargs)
|
self._tick(*args, **kwargs)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if e is None:
|
if e is None:
|
||||||
|
@ -690,7 +690,7 @@ class vmmConsolePages(vmmGObjectUI):
|
|||||||
gdev = gdevs and gdevs[0] or None
|
gdev = gdevs and gdevs[0] or None
|
||||||
if gdev:
|
if gdev:
|
||||||
ginfo = ConnectionInfo(self.vm.conn, gdev)
|
ginfo = ConnectionInfo(self.vm.conn, gdev)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# We can fail here if VM is destroyed: xen is a bit racy
|
# We can fail here if VM is destroyed: xen is a bit racy
|
||||||
# and can't handle domain lookups that soon after
|
# and can't handle domain lookups that soon after
|
||||||
logging.exception("Getting graphics console failed: %s", str(e))
|
logging.exception("Getting graphics console failed: %s", str(e))
|
||||||
@ -733,7 +733,7 @@ class vmmConsolePages(vmmGObjectUI):
|
|||||||
self._refresh_enable_accel()
|
self._refresh_enable_accel()
|
||||||
|
|
||||||
self._viewer.console_open()
|
self._viewer.console_open()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Error connection to graphical console")
|
logging.exception("Error connection to graphical console")
|
||||||
self._activate_unavailable_page(
|
self._activate_unavailable_page(
|
||||||
_("Error connecting to graphical console") + ":\n%s" % e)
|
_("Error connecting to graphical console") + ":\n%s" % e)
|
||||||
|
@ -467,7 +467,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
guest.set_uefi_default()
|
guest.set_uefi_default()
|
||||||
installable_arch = True
|
installable_arch = True
|
||||||
logging.debug("UEFI found for aarch64, setting it as default.")
|
logging.debug("UEFI found for aarch64, setting it as default.")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
installable_arch = False
|
installable_arch = False
|
||||||
logging.debug("Error checking for aarch64 UEFI default",
|
logging.debug("Error checking for aarch64 UEFI default",
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
@ -700,7 +700,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._populate_conn_state()
|
self._populate_conn_state()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Error setting create wizard conn state.")
|
logging.exception("Error setting create wizard conn state.")
|
||||||
return self._show_startup_error(str(e))
|
return self._show_startup_error(str(e))
|
||||||
|
|
||||||
@ -1733,7 +1733,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
elif pagenum == PAGE_FINISH:
|
elif pagenum == PAGE_FINISH:
|
||||||
try:
|
try:
|
||||||
self._populate_summary()
|
self._populate_summary()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error populating summary page: %s") %
|
self.err.show_err(_("Error populating summary page: %s") %
|
||||||
str(e))
|
str(e))
|
||||||
return
|
return
|
||||||
@ -1767,7 +1767,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
# Generate UUID (makes customize dialog happy)
|
# Generate UUID (makes customize dialog happy)
|
||||||
try:
|
try:
|
||||||
guest.uuid = util.randomUUID(guest.conn)
|
guest.uuid = util.randomUUID(guest.conn)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error setting UUID: %s") % str(e))
|
self.err.show_err(_("Error setting UUID: %s") % str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -1775,7 +1775,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
if variant:
|
if variant:
|
||||||
guest.os_variant = variant
|
guest.os_variant = variant
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
self.err.val_err(_("Error setting OS information."), str(e))
|
self.err.val_err(_("Error setting OS information."), str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -1797,7 +1797,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
for_cpu=True)
|
for_cpu=True)
|
||||||
|
|
||||||
guest.add_default_devices()
|
guest.add_default_devices()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error setting up default devices:") + str(e))
|
self.err.show_err(_("Error setting up default devices:") + str(e))
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -1815,7 +1815,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
return self._validate_storage_page()
|
return self._validate_storage_page()
|
||||||
elif pagenum == PAGE_FINISH:
|
elif pagenum == PAGE_FINISH:
|
||||||
return self._validate_final_page()
|
return self._validate_final_page()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Uncaught error validating install "
|
self.err.show_err(_("Uncaught error validating install "
|
||||||
"parameters: %s") % str(e))
|
"parameters: %s") % str(e))
|
||||||
return
|
return
|
||||||
@ -1935,7 +1935,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
if not self._guest:
|
if not self._guest:
|
||||||
return False
|
return False
|
||||||
self._guest.installer = installer
|
self._guest.installer = installer
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(
|
return self.err.val_err(
|
||||||
_("Error setting installer parameters."), e)
|
_("Error setting installer parameters."), e)
|
||||||
|
|
||||||
@ -1965,7 +1965,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
fsdev.source = template
|
fsdev.source = template
|
||||||
self._guest.add_device(fsdev)
|
self._guest.add_device(fsdev)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(
|
return self.err.val_err(
|
||||||
_("Error setting install media location."), e)
|
_("Error setting install media location."), e)
|
||||||
|
|
||||||
@ -1998,7 +1998,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
name = self._generate_default_name(distro, variant)
|
name = self._generate_default_name(distro, variant)
|
||||||
self.widget("create-vm-name").set_text(name)
|
self.widget("create-vm-name").set_text(name)
|
||||||
self._guest.name = name
|
self._guest.name = name
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Error setting default name."), e)
|
return self.err.val_err(_("Error setting default name."), e)
|
||||||
|
|
||||||
# Kind of wonky, run storage validation now, which will assign
|
# Kind of wonky, run storage validation now, which will assign
|
||||||
@ -2053,14 +2053,14 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
# VCPUS
|
# VCPUS
|
||||||
try:
|
try:
|
||||||
self._guest.vcpus = int(cpus)
|
self._guest.vcpus = int(cpus)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Error setting CPUs."), e)
|
return self.err.val_err(_("Error setting CPUs."), e)
|
||||||
|
|
||||||
# Memory
|
# Memory
|
||||||
try:
|
try:
|
||||||
self._guest.memory = int(mem) * 1024
|
self._guest.memory = int(mem) * 1024
|
||||||
self._guest.maxmemory = int(mem) * 1024
|
self._guest.maxmemory = int(mem) * 1024
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Error setting guest memory."), e)
|
return self.err.val_err(_("Error setting guest memory."), e)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -2101,7 +2101,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
if storage_enabled:
|
if storage_enabled:
|
||||||
disk = self._addstorage.validate_storage(self._guest.name,
|
disk = self._addstorage.validate_storage(self._guest.name,
|
||||||
path=path)
|
path=path)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Storage parameter error."), e)
|
return self.err.val_err(_("Storage parameter error."), e)
|
||||||
|
|
||||||
if disk is False:
|
if disk is False:
|
||||||
@ -2132,7 +2132,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
if name != self._guest.name:
|
if name != self._guest.name:
|
||||||
try:
|
try:
|
||||||
self._guest.name = name
|
self._guest.name = name
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Invalid guest name"), str(e))
|
return self.err.val_err(_("Invalid guest name"), str(e))
|
||||||
if self._is_default_storage():
|
if self._is_default_storage():
|
||||||
logging.debug("User changed VM name and using default "
|
logging.debug("User changed VM name and using default "
|
||||||
@ -2318,7 +2318,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
logging.debug("User requested 'customize', launching dialog")
|
logging.debug("User requested 'customize', launching dialog")
|
||||||
try:
|
try:
|
||||||
self._show_customize_dialog(guest)
|
self._show_customize_dialog(guest)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.reset_finish_cursor()
|
self.reset_finish_cursor()
|
||||||
self.err.show_err(_("Error starting installation: ") + str(e))
|
self.err.show_err(_("Error starting installation: ") + str(e))
|
||||||
return
|
return
|
||||||
@ -2471,7 +2471,7 @@ class vmmCreate(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
logging.debug("Install should be completed, starting VM.")
|
logging.debug("Install should be completed, starting VM.")
|
||||||
vm.startup()
|
vm.startup()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error continue install: %s") % str(e))
|
self.err.show_err(_("Error continue install: %s") % str(e))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -549,7 +549,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||||||
key = Interface(self.conn.get_backend())
|
key = Interface(self.conn.get_backend())
|
||||||
key.type = Interface.INTERFACE_TYPE_ETHERNET
|
key.type = Interface.INTERFACE_TYPE_ETHERNET
|
||||||
key.name = name
|
key.name = name
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error creating stub interface '%s': %s",
|
logging.debug("Error creating stub interface '%s': %s",
|
||||||
name, e)
|
name, e)
|
||||||
continue
|
continue
|
||||||
@ -907,7 +907,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||||||
elif pagenum == PAGE_DETAILS:
|
elif pagenum == PAGE_DETAILS:
|
||||||
return self.validate_details_page()
|
return self.validate_details_page()
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Uncaught error validating install "
|
self.err.show_err(_("Uncaught error validating install "
|
||||||
"parameters: %s") % str(e))
|
"parameters: %s") % str(e))
|
||||||
return
|
return
|
||||||
@ -1011,7 +1011,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||||||
iobj.validate()
|
iobj.validate()
|
||||||
|
|
||||||
self.interface = iobj
|
self.interface = iobj
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(
|
return self.err.val_err(
|
||||||
_("Error setting interface parameters."), e)
|
_("Error setting interface parameters."), e)
|
||||||
|
|
||||||
@ -1078,7 +1078,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
|||||||
def validate_ip_info(self):
|
def validate_ip_info(self):
|
||||||
try:
|
try:
|
||||||
self.build_ip_info()
|
self.build_ip_info()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error validating IP configuration: %s") %
|
self.err.show_err(_("Error validating IP configuration: %s") %
|
||||||
str(e))
|
str(e))
|
||||||
return False
|
return False
|
||||||
|
@ -301,7 +301,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
net = self._build_xmlstub()
|
net = self._build_xmlstub()
|
||||||
net.name = self.widget("net-name").get_text()
|
net.name = self.widget("net-name").get_text()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Invalid network name"), str(e))
|
return self.err.val_err(_("Invalid network name"), str(e))
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -823,7 +823,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
net = self._build_xmlobj()
|
net = self._build_xmlobj()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error generating network xml: %s") % str(e))
|
self.err.show_err(_("Error generating network xml: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ class vmmCreatePool(vmmGObjectUI):
|
|||||||
self.finish()
|
self.finish()
|
||||||
else:
|
else:
|
||||||
notebook.next_page()
|
notebook.next_page()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Uncaught error validating input: %s") % str(e))
|
self.err.show_err(_("Uncaught error validating input: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ class vmmCreatePool(vmmGObjectUI):
|
|||||||
else:
|
else:
|
||||||
self._pool = self._make_stub_pool()
|
self._pool = self._make_stub_pool()
|
||||||
self._pool.name = self.get_config_name()
|
self._pool.name = self.get_config_name()
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
return self.err.val_err(_("Pool Parameter Error"), e)
|
return self.err.val_err(_("Pool Parameter Error"), e)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -525,7 +525,7 @@ class vmmCreatePool(vmmGObjectUI):
|
|||||||
self._pool.source_name = source_name
|
self._pool.source_name = source_name
|
||||||
|
|
||||||
self._pool.validate()
|
self._pool.validate()
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
return self.err.val_err(_("Pool Parameter Error"), e)
|
return self.err.val_err(_("Pool Parameter Error"), e)
|
||||||
|
|
||||||
buildval = self.widget("pool-build").get_active()
|
buildval = self.widget("pool-build").get_active()
|
||||||
|
@ -289,7 +289,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
if not self.validate():
|
if not self.validate():
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.show_err(_("Uncaught error validating input: %s") % str(e))
|
self.show_err(_("Uncaught error validating input: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -337,7 +337,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
|||||||
if fmt:
|
if fmt:
|
||||||
self.vol.format = fmt
|
self.vol.format = fmt
|
||||||
self.vol.validate()
|
self.vol.validate()
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
return self.val_err(_("Volume Parameter Error"), e)
|
return self.val_err(_("Volume Parameter Error"), e)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
|||||||
logging.debug("Deleting path: %s", path)
|
logging.debug("Deleting path: %s", path)
|
||||||
meter.start(text=_("Deleting path '%s'") % path)
|
meter.start(text=_("Deleting path '%s'") % path)
|
||||||
self._async_delete_path(conn, path, meter)
|
self._async_delete_path(conn, path, meter)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
storage_errors.append((str(e),
|
storage_errors.append((str(e),
|
||||||
"".join(traceback.format_exc())))
|
"".join(traceback.format_exc())))
|
||||||
meter.end(0)
|
meter.end(0)
|
||||||
@ -184,7 +184,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
|||||||
logging.debug("Removing VM '%s'", self.vm.get_name())
|
logging.debug("Removing VM '%s'", self.vm.get_name())
|
||||||
self.vm.delete()
|
self.vm.delete()
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
error = (_("Error deleting virtual machine '%s': %s") %
|
error = (_("Error deleting virtual machine '%s': %s") %
|
||||||
(self.vm.get_name(), str(e)))
|
(self.vm.get_name(), str(e)))
|
||||||
details = "".join(traceback.format_exc())
|
details = "".join(traceback.format_exc())
|
||||||
@ -390,7 +390,7 @@ def do_we_default(conn, vm_name, vol, path, ro, shared, is_media):
|
|||||||
namestr = append_str(namestr, name, delim="\n- ")
|
namestr = append_str(namestr, name, delim="\n- ")
|
||||||
info = append_str(info, _("Storage is in use by the following "
|
info = append_str(info, _("Storage is in use by the following "
|
||||||
"virtual machines:\n- %s " % namestr))
|
"virtual machines:\n- %s " % namestr))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Failed checking disk conflict: %s", str(e))
|
logging.exception("Failed checking disk conflict: %s", str(e))
|
||||||
|
|
||||||
return (not info, info)
|
return (not info, info)
|
||||||
|
@ -1226,7 +1226,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
self.refresh_panic_page()
|
self.refresh_panic_page()
|
||||||
else:
|
else:
|
||||||
pagetype = -1
|
pagetype = -1
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error refreshing hardware page: %s") % str(e))
|
self.err.show_err(_("Error refreshing hardware page: %s") % str(e))
|
||||||
# Don't return, we want the rest of the bits to run regardless
|
# Don't return, we want the rest of the bits to run regardless
|
||||||
|
|
||||||
@ -1415,7 +1415,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
self.addhw = vmmAddHardware(self.vm, self.is_customize_dialog)
|
self.addhw = vmmAddHardware(self.vm, self.is_customize_dialog)
|
||||||
|
|
||||||
self.addhw.show(self.topwin)
|
self.addhw.show(self.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err((_("Error launching hardware dialog: %s") %
|
self.err.show_err((_("Error launching hardware dialog: %s") %
|
||||||
str(e)))
|
str(e)))
|
||||||
|
|
||||||
@ -1496,7 +1496,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
ignore = src
|
ignore = src
|
||||||
try:
|
try:
|
||||||
return self._take_screenshot()
|
return self._take_screenshot()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error taking screenshot: %s") % str(e))
|
self.err.show_err(_("Error taking screenshot: %s") % str(e))
|
||||||
|
|
||||||
def control_vm_usb_redirection(self, src):
|
def control_vm_usb_redirection(self, src):
|
||||||
@ -1833,7 +1833,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
def _eject_media(self, disk):
|
def _eject_media(self, disk):
|
||||||
try:
|
try:
|
||||||
self._change_storage_media(disk, None)
|
self._change_storage_media(disk, None)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err((_("Error disconnecting media: %s") % e))
|
self.err.show_err((_("Error disconnecting media: %s") % e))
|
||||||
|
|
||||||
def _insert_media(self, disk):
|
def _insert_media(self, disk):
|
||||||
@ -1854,7 +1854,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
dialog.disk = disk
|
dialog.disk = disk
|
||||||
|
|
||||||
dialog.show(self.topwin)
|
dialog.show(self.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err((_("Error launching media dialog: %s") % e))
|
self.err.show_err((_("Error launching media dialog: %s") % e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1920,7 +1920,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
ret = self.config_hostdev_apply(key)
|
ret = self.config_hostdev_apply(key)
|
||||||
else:
|
else:
|
||||||
ret = False
|
ret = False
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.show_err(_("Error apply changes: %s") % e)
|
return self.err.show_err(_("Error apply changes: %s") % e)
|
||||||
|
|
||||||
if ret is not False:
|
if ret is not False:
|
||||||
@ -2052,7 +2052,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
auto = self.widget("boot-autostart")
|
auto = self.widget("boot-autostart")
|
||||||
try:
|
try:
|
||||||
self.vm.set_autostart(auto.get_active())
|
self.vm.set_autostart(auto.get_active())
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(
|
self.err.show_err(
|
||||||
(_("Error changing autostart value: %s") % str(e)))
|
(_("Error changing autostart value: %s") % str(e)))
|
||||||
return False
|
return False
|
||||||
@ -2289,7 +2289,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
# Define the change
|
# Define the change
|
||||||
try:
|
try:
|
||||||
self.vm.remove_device(devobj)
|
self.vm.remove_device(devobj)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error Removing Device: %s") % str(e))
|
self.err.show_err(_("Error Removing Device: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -2298,7 +2298,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
if self.vm.is_active():
|
if self.vm.is_active():
|
||||||
self.vm.detach_device(devobj)
|
self.vm.detach_device(devobj)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Device could not be hotUNplugged: %s", str(e))
|
logging.debug("Device could not be hotUNplugged: %s", str(e))
|
||||||
detach_err = (str(e), "".join(traceback.format_exc()))
|
detach_err = (str(e), "".join(traceback.format_exc()))
|
||||||
|
|
||||||
@ -2328,7 +2328,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
if self.is_visible():
|
if self.is_visible():
|
||||||
self.vm.ensure_latest_xml()
|
self.vm.ensure_latest_xml()
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
if util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||||
self.close()
|
self.close()
|
||||||
return
|
return
|
||||||
|
@ -1538,7 +1538,7 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
if self._has_managed_save is None:
|
if self._has_managed_save is None:
|
||||||
try:
|
try:
|
||||||
self._has_managed_save = self._backend.hasManagedSaveImage(0)
|
self._has_managed_save = self._backend.hasManagedSaveImage(0)
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if not util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
if not util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||||
raise
|
raise
|
||||||
return False
|
return False
|
||||||
@ -1853,7 +1853,7 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
if io:
|
if io:
|
||||||
rx += io[0]
|
rx += io[0]
|
||||||
tx += io[4]
|
tx += io[4]
|
||||||
except libvirt.libvirtError, err:
|
except libvirt.libvirtError as err:
|
||||||
if util.is_error_nosupport(err):
|
if util.is_error_nosupport(err):
|
||||||
logging.debug("Net stats not supported: %s", err)
|
logging.debug("Net stats not supported: %s", err)
|
||||||
self._stats_net_supported = False
|
self._stats_net_supported = False
|
||||||
@ -1903,7 +1903,7 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
if io:
|
if io:
|
||||||
rd += io[1]
|
rd += io[1]
|
||||||
wr += io[3]
|
wr += io[3]
|
||||||
except libvirt.libvirtError, err:
|
except libvirt.libvirtError as err:
|
||||||
if util.is_error_nosupport(err):
|
if util.is_error_nosupport(err):
|
||||||
logging.debug("Disk stats not supported: %s", err)
|
logging.debug("Disk stats not supported: %s", err)
|
||||||
self._stats_disk_supported = False
|
self._stats_disk_supported = False
|
||||||
@ -1935,7 +1935,7 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
secs = 5
|
secs = 5
|
||||||
self._backend.setMemoryStatsPeriod(secs,
|
self._backend.setMemoryStatsPeriod(secs,
|
||||||
libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error setting memstats period: %s", e)
|
logging.debug("Error setting memstats period: %s", e)
|
||||||
|
|
||||||
def _sample_mem_stats(self):
|
def _sample_mem_stats(self):
|
||||||
@ -1958,7 +1958,7 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
|
|
||||||
if "unused" in stats:
|
if "unused" in stats:
|
||||||
curmem = max(0, totalmem - stats.get("unused", totalmem))
|
curmem = max(0, totalmem - stats.get("unused", totalmem))
|
||||||
except libvirt.libvirtError, err:
|
except libvirt.libvirtError as err:
|
||||||
logging.error("Error reading mem stats: %s", err)
|
logging.error("Error reading mem stats: %s", err)
|
||||||
|
|
||||||
pcentCurrMem = (curmem / float(totalmem)) * 100
|
pcentCurrMem = (curmem / float(totalmem)) * 100
|
||||||
|
@ -383,7 +383,7 @@ class vmmEngine(vmmGObject):
|
|||||||
ignore1, ignore2, conn, kwargs = self._tick_queue.get()
|
ignore1, ignore2, conn, kwargs = self._tick_queue.get()
|
||||||
try:
|
try:
|
||||||
conn.tick_from_engine(**kwargs)
|
conn.tick_from_engine(**kwargs)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
tb = "".join(traceback.format_exc())
|
tb = "".join(traceback.format_exc())
|
||||||
error_msg = (_("Error polling connection '%s': %s")
|
error_msg = (_("Error polling connection '%s': %s")
|
||||||
% (conn.get_uri(), e))
|
% (conn.get_uri(), e))
|
||||||
@ -717,7 +717,7 @@ class vmmEngine(vmmGObject):
|
|||||||
if self.windowAbout is None:
|
if self.windowAbout is None:
|
||||||
self.windowAbout = vmmAbout()
|
self.windowAbout = vmmAbout()
|
||||||
self.windowAbout.show()
|
self.windowAbout.show()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching 'About' dialog: %s") % str(e))
|
src.err.show_err(_("Error launching 'About' dialog: %s") % str(e))
|
||||||
|
|
||||||
def _get_preferences(self):
|
def _get_preferences(self):
|
||||||
@ -731,7 +731,7 @@ class vmmEngine(vmmGObject):
|
|||||||
def _do_show_preferences(self, src):
|
def _do_show_preferences(self, src):
|
||||||
try:
|
try:
|
||||||
self._get_preferences().show(src.topwin)
|
self._get_preferences().show(src.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching preferences: %s") % str(e))
|
src.err.show_err(_("Error launching preferences: %s") % str(e))
|
||||||
|
|
||||||
def _get_host_dialog(self, uri):
|
def _get_host_dialog(self, uri):
|
||||||
@ -752,7 +752,7 @@ class vmmEngine(vmmGObject):
|
|||||||
def _do_show_host(self, src, uri):
|
def _do_show_host(self, src, uri):
|
||||||
try:
|
try:
|
||||||
self._get_host_dialog(uri).show()
|
self._get_host_dialog(uri).show()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching host dialog: %s") % str(e))
|
src.err.show_err(_("Error launching host dialog: %s") % str(e))
|
||||||
|
|
||||||
|
|
||||||
@ -778,7 +778,7 @@ class vmmEngine(vmmGObject):
|
|||||||
def _do_show_connect(self, src, reset_state=True):
|
def _do_show_connect(self, src, reset_state=True):
|
||||||
try:
|
try:
|
||||||
self._get_connect_dialog().show(src.topwin, reset_state)
|
self._get_connect_dialog().show(src.topwin, reset_state)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching connect dialog: %s") % str(e))
|
src.err.show_err(_("Error launching connect dialog: %s") % str(e))
|
||||||
|
|
||||||
def _do_edit_connect(self, src, connection):
|
def _do_edit_connect(self, src, connection):
|
||||||
@ -830,7 +830,7 @@ class vmmEngine(vmmGObject):
|
|||||||
details.activate_default_page()
|
details.activate_default_page()
|
||||||
|
|
||||||
details.show()
|
details.show()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching details: %s") % str(e))
|
src.err.show_err(_("Error launching details: %s") % str(e))
|
||||||
|
|
||||||
def _do_show_vm(self, src, uri, connkey):
|
def _do_show_vm(self, src, uri, connkey):
|
||||||
@ -882,7 +882,7 @@ class vmmEngine(vmmGObject):
|
|||||||
try:
|
try:
|
||||||
manager = self.get_manager()
|
manager = self.get_manager()
|
||||||
manager.show()
|
manager.show()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
if not src:
|
if not src:
|
||||||
raise
|
raise
|
||||||
src.err.show_err(_("Error launching manager: %s") % str(e))
|
src.err.show_err(_("Error launching manager: %s") % str(e))
|
||||||
@ -901,7 +901,7 @@ class vmmEngine(vmmGObject):
|
|||||||
def _do_show_create(self, src, uri):
|
def _do_show_create(self, src, uri):
|
||||||
try:
|
try:
|
||||||
self._get_create_dialog().show(src.topwin, uri)
|
self._get_create_dialog().show(src.topwin, uri)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching manager: %s") % str(e))
|
src.err.show_err(_("Error launching manager: %s") % str(e))
|
||||||
|
|
||||||
def _do_show_migrate(self, src, uri, connkey):
|
def _do_show_migrate(self, src, uri, connkey):
|
||||||
@ -913,7 +913,7 @@ class vmmEngine(vmmGObject):
|
|||||||
self.windowMigrate = vmmMigrateDialog(self)
|
self.windowMigrate = vmmMigrateDialog(self)
|
||||||
|
|
||||||
self.windowMigrate.show(src.topwin, vm)
|
self.windowMigrate.show(src.topwin, vm)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching migrate dialog: %s") % str(e))
|
src.err.show_err(_("Error launching migrate dialog: %s") % str(e))
|
||||||
|
|
||||||
def _do_show_clone(self, src, uri, connkey):
|
def _do_show_clone(self, src, uri, connkey):
|
||||||
@ -929,7 +929,7 @@ class vmmEngine(vmmGObject):
|
|||||||
clone_window.set_orig_vm(orig_vm)
|
clone_window.set_orig_vm(orig_vm)
|
||||||
|
|
||||||
clone_window.show(src.topwin)
|
clone_window.show(src.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error setting clone parameters: %s") % str(e))
|
src.err.show_err(_("Error setting clone parameters: %s") % str(e))
|
||||||
|
|
||||||
def _do_refresh_inspection(self, src_ignore, uri, connkey):
|
def _do_refresh_inspection(self, src_ignore, uri, connkey):
|
||||||
@ -1109,7 +1109,7 @@ class vmmEngine(vmmGObject):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
vm.abort_job()
|
vm.abort_job()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Error cancelling save job")
|
logging.exception("Error cancelling save job")
|
||||||
asyncjob.show_warning(_("Error cancelling save job: %s") % str(e))
|
asyncjob.show_warning(_("Error cancelling save job: %s") % str(e))
|
||||||
return
|
return
|
||||||
@ -1182,7 +1182,7 @@ class vmmEngine(vmmGObject):
|
|||||||
try:
|
try:
|
||||||
vm.remove_saved_image()
|
vm.remove_saved_image()
|
||||||
self._do_run_domain(src, uri, connkey)
|
self._do_run_domain(src, uri, connkey)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error removing domain state: %s")
|
src.err.show_err(_("Error removing domain state: %s")
|
||||||
% str(e))
|
% str(e))
|
||||||
|
|
||||||
@ -1250,5 +1250,5 @@ class vmmEngine(vmmGObject):
|
|||||||
if not self.delete_dialog:
|
if not self.delete_dialog:
|
||||||
self.delete_dialog = vmmDeleteDialog()
|
self.delete_dialog = vmmDeleteDialog()
|
||||||
self.delete_dialog.show(vm, src.topwin)
|
self.delete_dialog.show(vm, src.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
src.err.show_err(_("Error launching delete dialog: %s") % str(e))
|
src.err.show_err(_("Error launching delete dialog: %s") % str(e))
|
||||||
|
@ -321,7 +321,7 @@ class vmmFSDetails(vmmGObjectUI):
|
|||||||
self._dev.format = fsformat
|
self._dev.format = fsformat
|
||||||
if wrpolicy:
|
if wrpolicy:
|
||||||
self._dev.wrpolicy = wrpolicy
|
self._dev.wrpolicy = wrpolicy
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Filesystem parameter error"), e)
|
return self.err.val_err(_("Filesystem parameter error"), e)
|
||||||
|
|
||||||
def _browse_file(self, textent, isdir=False):
|
def _browse_file(self, textent, isdir=False):
|
||||||
|
@ -407,7 +407,7 @@ class vmmHost(vmmGObjectUI):
|
|||||||
if self.addnet is None:
|
if self.addnet is None:
|
||||||
self.addnet = vmmCreateNetwork(self.conn)
|
self.addnet = vmmCreateNetwork(self.conn)
|
||||||
self.addnet.show(self.topwin)
|
self.addnet.show(self.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error launching network wizard: %s") % str(e))
|
self.err.show_err(_("Error launching network wizard: %s") % str(e))
|
||||||
|
|
||||||
def net_apply(self):
|
def net_apply(self):
|
||||||
@ -450,7 +450,7 @@ class vmmHost(vmmGObjectUI):
|
|||||||
dialog_type=Gtk.MessageType.INFO)
|
dialog_type=Gtk.MessageType.INFO)
|
||||||
|
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error changing network settings: %s") % str(e))
|
self.err.show_err(_("Error changing network settings: %s") % str(e))
|
||||||
return
|
return
|
||||||
finally:
|
finally:
|
||||||
@ -518,7 +518,7 @@ class vmmHost(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
net = self.conn.get_net(connkey)
|
net = self.conn.get_net(connkey)
|
||||||
self.populate_net_state(net)
|
self.populate_net_state(net)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
self.set_net_error_page(_("Error selecting network: %s") % e)
|
self.set_net_error_page(_("Error selecting network: %s") % e)
|
||||||
finally:
|
finally:
|
||||||
@ -754,7 +754,7 @@ class vmmHost(vmmGObjectUI):
|
|||||||
if self.addinterface is None:
|
if self.addinterface is None:
|
||||||
self.addinterface = vmmCreateInterface(self.conn)
|
self.addinterface = vmmCreateInterface(self.conn)
|
||||||
self.addinterface.show(self.topwin)
|
self.addinterface.show(self.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error launching interface wizard: %s") %
|
self.err.show_err(_("Error launching interface wizard: %s") %
|
||||||
str(e))
|
str(e))
|
||||||
|
|
||||||
@ -781,7 +781,7 @@ class vmmHost(vmmGObjectUI):
|
|||||||
interface.get_name())
|
interface.get_name())
|
||||||
try:
|
try:
|
||||||
interface.set_startmode(newmode)
|
interface.set_startmode(newmode)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error setting interface startmode: %s") %
|
self.err.show_err(_("Error setting interface startmode: %s") %
|
||||||
str(e))
|
str(e))
|
||||||
return
|
return
|
||||||
@ -807,7 +807,7 @@ class vmmHost(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.populate_interface_state(connkey)
|
self.populate_interface_state(connkey)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
self.set_interface_error_page(_("Error selecting interface: %s") %
|
self.set_interface_error_page(_("Error selecting interface: %s") %
|
||||||
e)
|
e)
|
||||||
@ -859,7 +859,7 @@ class vmmHost(vmmGObjectUI):
|
|||||||
used_by = None
|
used_by = None
|
||||||
try:
|
try:
|
||||||
used_by = vmmCreateInterface.iface_in_use_by(self.conn, name)
|
used_by = vmmCreateInterface.iface_in_use_by(self.conn, name)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error looking up iface usage: %s", e)
|
logging.debug("Error looking up iface usage: %s", e)
|
||||||
self.widget("interface-inuseby").set_text(used_by or "-")
|
self.widget("interface-inuseby").set_text(used_by or "-")
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ class vmmLibvirtObject(vmmGObject):
|
|||||||
# status = None forces a signal to be emitted
|
# status = None forces a signal to be emitted
|
||||||
self.__status = None
|
self.__status = None
|
||||||
self._refresh_status()
|
self._refresh_status()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# If we hit an exception here, it's often that the object
|
# If we hit an exception here, it's often that the object
|
||||||
# disappeared, so request the poll loop to be updated
|
# disappeared, so request the poll loop to be updated
|
||||||
logging.debug("Error refreshing %s from events: %s", self, e)
|
logging.debug("Error refreshing %s from events: %s", self, e)
|
||||||
|
@ -744,7 +744,7 @@ class vmmManager(vmmGObjectUI):
|
|||||||
|
|
||||||
desc = vm.get_description()
|
desc = vm.get_description()
|
||||||
row[ROW_HINT] = util.xml_escape(desc)
|
row[ROW_HINT] = util.xml_escape(desc)
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
if util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||||
return
|
return
|
||||||
raise
|
raise
|
||||||
|
@ -376,7 +376,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
|||||||
uri = self.widget("migrate-tunnel-uri").get_text()
|
uri = self.widget("migrate-tunnel-uri").get_text()
|
||||||
else:
|
else:
|
||||||
uri = self._build_regular_migrate_uri()
|
uri = self._build_regular_migrate_uri()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
details = "".join(traceback.format_exc())
|
details = "".join(traceback.format_exc())
|
||||||
self.err.show_err((_("Uncaught error validating input: %s") %
|
self.err.show_err((_("Uncaught error validating input: %s") %
|
||||||
str(e)),
|
str(e)),
|
||||||
@ -409,7 +409,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
vm.abort_job()
|
vm.abort_job()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Error cancelling migrate job")
|
logging.exception("Error cancelling migrate job")
|
||||||
asyncjob.show_warning(_("Error cancelling migrate job: %s") % e)
|
asyncjob.show_warning(_("Error cancelling migrate job: %s") % e)
|
||||||
return
|
return
|
||||||
|
@ -363,7 +363,7 @@ class vmmNetworkList(vmmGObjectUI):
|
|||||||
try:
|
try:
|
||||||
netobj.start()
|
netobj.start()
|
||||||
logging.info("Started network '%s'", devname)
|
logging.info("Started network '%s'", devname)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.show_err(_("Could not start virtual network "
|
return self.err.show_err(_("Could not start virtual network "
|
||||||
"'%s': %s") % (devname, str(e)))
|
"'%s': %s") % (devname, str(e)))
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ class vmmNetworkList(vmmGObjectUI):
|
|||||||
net.virtualport.typeid = vport_typeid or None
|
net.virtualport.typeid = vport_typeid or None
|
||||||
net.virtualport.typeidversion = vport_idver or None
|
net.virtualport.typeidversion = vport_idver or None
|
||||||
net.virtualport.instanceid = vport_instid or None
|
net.virtualport.instanceid = vport_instid or None
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Error with network parameters."), e)
|
return self.err.val_err(_("Error with network parameters."), e)
|
||||||
|
|
||||||
# Make sure there is no mac address collision
|
# Make sure there is no mac address collision
|
||||||
|
@ -61,7 +61,7 @@ def check_packagekit(parent, errbox, packages):
|
|||||||
packagekit_install(parent, packages)
|
packagekit_install(parent, packages)
|
||||||
else:
|
else:
|
||||||
logging.debug("Nothing to install")
|
logging.debug("Nothing to install")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# PackageKit frontend should report an error for us, so just log
|
# PackageKit frontend should report an error for us, so just log
|
||||||
# the actual error
|
# the actual error
|
||||||
logging.debug("Error talking to PackageKit: %s", str(e), exc_info=True)
|
logging.debug("Error talking to PackageKit: %s", str(e), exc_info=True)
|
||||||
|
@ -411,7 +411,7 @@ class vmmSerialConsole(vmmGObject):
|
|||||||
self.console.open(self.lookup_dev(), self.terminal)
|
self.console.open(self.lookup_dev(), self.terminal)
|
||||||
self.box.set_current_page(0)
|
self.box.set_current_page(0)
|
||||||
return True
|
return True
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Error opening serial console")
|
logging.exception("Error opening serial console")
|
||||||
self.show_error(_("Error connecting to text console: %s") % e)
|
self.show_error(_("Error connecting to text console: %s") % e)
|
||||||
try:
|
try:
|
||||||
|
@ -222,7 +222,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
snapshots = self.vm.list_snapshots()
|
snapshots = self.vm.list_snapshots()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
self._set_error_page(_("Error refreshing snapshot list: %s") %
|
self._set_error_page(_("Error refreshing snapshot list: %s") %
|
||||||
str(e))
|
str(e))
|
||||||
@ -480,7 +480,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||||||
newsnap.validate()
|
newsnap.validate()
|
||||||
newsnap.get_xml_config()
|
newsnap.get_xml_config()
|
||||||
return newsnap
|
return newsnap
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
return self.err.val_err(_("Error validating snapshot: %s") % e)
|
return self.err.val_err(_("Error validating snapshot: %s") % e)
|
||||||
|
|
||||||
def _get_screenshot_data_for_save(self):
|
def _get_screenshot_data_for_save(self):
|
||||||
@ -663,6 +663,6 @@ class vmmSnapshotPage(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._set_snapshot_state(snap[0])
|
self._set_snapshot_state(snap[0])
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
self._set_error_page(_("Error selecting snapshot: %s") % str(e))
|
self._set_error_page(_("Error selecting snapshot: %s") % str(e))
|
||||||
|
@ -509,7 +509,7 @@ class vmmStorageList(vmmGObjectUI):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._populate_pool_state(connkey)
|
self._populate_pool_state(connkey)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception(e)
|
logging.exception(e)
|
||||||
self._set_storage_error_page(_("Error selecting pool: %s") % e)
|
self._set_storage_error_page(_("Error selecting pool: %s") % e)
|
||||||
self._disable_pool_apply()
|
self._disable_pool_apply()
|
||||||
@ -616,7 +616,7 @@ class vmmStorageList(vmmGObjectUI):
|
|||||||
self._addpool = vmmCreatePool(self.conn)
|
self._addpool = vmmCreatePool(self.conn)
|
||||||
self._addpool.connect("pool-created", self._pool_created)
|
self._addpool.connect("pool-created", self._pool_created)
|
||||||
self._addpool.show(self.topwin)
|
self._addpool.show(self.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error launching pool wizard: %s") % str(e))
|
self.err.show_err(_("Error launching pool wizard: %s") % str(e))
|
||||||
|
|
||||||
def _pool_delete(self, src):
|
def _pool_delete(self, src):
|
||||||
@ -660,7 +660,7 @@ class vmmStorageList(vmmGObjectUI):
|
|||||||
if EDIT_POOL_NAME in self._active_edits:
|
if EDIT_POOL_NAME in self._active_edits:
|
||||||
pool.define_name(self.widget("pool-name-entry").get_text())
|
pool.define_name(self.widget("pool-name-entry").get_text())
|
||||||
self.idle_add(self._populate_pools)
|
self.idle_add(self._populate_pools)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error changing pool settings: %s") % str(e))
|
self.err.show_err(_("Error changing pool settings: %s") % str(e))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -699,7 +699,7 @@ class vmmStorageList(vmmGObjectUI):
|
|||||||
self._addvol.set_modal(self.topwin.get_modal())
|
self._addvol.set_modal(self.topwin.get_modal())
|
||||||
self._addvol.set_name_hint(self._name_hint)
|
self._addvol.set_name_hint(self._name_hint)
|
||||||
self._addvol.show(self.topwin)
|
self._addvol.show(self.topwin)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.err.show_err(_("Error launching volume wizard: %s") % str(e))
|
self.err.show_err(_("Error launching volume wizard: %s") % str(e))
|
||||||
|
|
||||||
def _vol_delete(self, src_ignore):
|
def _vol_delete(self, src_ignore):
|
||||||
|
@ -47,7 +47,7 @@ class vmmStorageVolume(vmmLibvirtObject):
|
|||||||
def _XMLDesc(self, flags):
|
def _XMLDesc(self, flags):
|
||||||
try:
|
try:
|
||||||
return self._backend.XMLDesc(flags)
|
return self._backend.XMLDesc(flags)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("XMLDesc for vol=%s failed: %s",
|
logging.debug("XMLDesc for vol=%s failed: %s",
|
||||||
self._backend.key(), e)
|
self._backend.key(), e)
|
||||||
raise
|
raise
|
||||||
|
@ -419,7 +419,7 @@ class VNCViewer(Viewer):
|
|||||||
|
|
||||||
seq = GtkVnc.GrabSequence.new(keys)
|
seq = GtkVnc.GrabSequence.new(keys)
|
||||||
self._display.set_grab_keys(seq)
|
self._display.set_grab_keys(seq)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error when getting the grab keys combination: %s",
|
logging.debug("Error when getting the grab keys combination: %s",
|
||||||
str(e))
|
str(e))
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ class VNCViewer(Viewer):
|
|||||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||||
sock.connect(self._ginfo.gsocket)
|
sock.connect(self._ginfo.gsocket)
|
||||||
self._sockfd = sock
|
self._sockfd = sock
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise RuntimeError(_("Error opening socket path '%s': %s") %
|
raise RuntimeError(_("Error opening socket path '%s': %s") %
|
||||||
(self._ginfo.gsocket, e))
|
(self._ginfo.gsocket, e))
|
||||||
|
|
||||||
@ -685,7 +685,7 @@ class SpiceViewer(Viewer):
|
|||||||
|
|
||||||
seq = SpiceClientGtk.GrabSequence.new(keys)
|
seq = SpiceClientGtk.GrabSequence.new(keys)
|
||||||
self._display.set_grab_keys(seq)
|
self._display.set_grab_keys(seq)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error when getting the grab keys combination: %s",
|
logging.debug("Error when getting the grab keys combination: %s",
|
||||||
str(e))
|
str(e))
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ class ovf_parser(parser_class):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return _xml_parse_wrapper(xml, parse_cb)
|
return _xml_parse_wrapper(xml, parse_cb)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error parsing OVF XML: %s", str(e))
|
logging.debug("Error parsing OVF XML: %s", str(e))
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -83,7 +83,7 @@ class _VMXFile(object):
|
|||||||
try:
|
try:
|
||||||
lineobj = _VMXLine(line)
|
lineobj = _VMXLine(line)
|
||||||
self.lines.append(lineobj)
|
self.lines.append(lineobj)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise Exception(_("Syntax error at line %d: %s\n%s") %
|
raise Exception(_("Syntax error at line %d: %s\n%s") %
|
||||||
(len(self.lines) + 1, line.strip(), e))
|
(len(self.lines) + 1, line.strip(), e))
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
os.makedirs(vi_dir, 0751)
|
os.makedirs(vi_dir, 0751)
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
raise RuntimeError("Could not create directory %s: %s" %
|
raise RuntimeError("Could not create directory %s: %s" %
|
||||||
(vi_dir, e))
|
(vi_dir, e))
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
|
|||||||
os.path.exists(logfile) and
|
os.path.exists(logfile) and
|
||||||
not os.access(logfile, os.W_OK)):
|
not os.access(logfile, os.W_OK)):
|
||||||
raise RuntimeError("No write access to logfile %s" % logfile)
|
raise RuntimeError("No write access to logfile %s" % logfile)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.warning("Error setting up logfile: %s", e)
|
logging.warning("Error setting up logfile: %s", e)
|
||||||
logfile = None
|
logfile = None
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ def connect_console(guest, consolecb, wait):
|
|||||||
# If we connected the console, wait for it to finish
|
# If we connected the console, wait for it to finish
|
||||||
try:
|
try:
|
||||||
os.waitpid(child, 0)
|
os.waitpid(child, 0)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
logging.debug("waitpid: %s: %s", e.errno, e.message)
|
logging.debug("waitpid: %s: %s", e.errno, e.message)
|
||||||
|
|
||||||
|
|
||||||
@ -1207,7 +1207,7 @@ class VirtCLIParser(object):
|
|||||||
self.guest.add_child(obj)
|
self.guest.add_child(obj)
|
||||||
|
|
||||||
ret += util.listify(objs)
|
ret += util.listify(objs)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Exception parsing inst=%s optstr=%s",
|
logging.debug("Exception parsing inst=%s optstr=%s",
|
||||||
inst, self.optstr, exc_info=True)
|
inst, self.optstr, exc_info=True)
|
||||||
fail(_("Error: --%(cli_arg_name)s %(options)s: %(err)s") %
|
fail(_("Error: --%(cli_arg_name)s %(options)s: %(err)s") %
|
||||||
@ -1238,7 +1238,7 @@ class VirtCLIParser(object):
|
|||||||
if valid:
|
if valid:
|
||||||
ret.append(inst)
|
ret.append(inst)
|
||||||
self._check_leftover_opts(optdict)
|
self._check_leftover_opts(optdict)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Exception parsing inst=%s optstr=%s",
|
logging.debug("Exception parsing inst=%s optstr=%s",
|
||||||
inst, self.optstr, exc_info=True)
|
inst, self.optstr, exc_info=True)
|
||||||
fail(_("Error: --%(cli_arg_name)s %(options)s: %(err)s") %
|
fail(_("Error: --%(cli_arg_name)s %(options)s: %(err)s") %
|
||||||
@ -1943,7 +1943,7 @@ class ParserDisk(VirtCLIParser):
|
|||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return float(val)
|
return float(val)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
fail(_("Improper value for 'size': %s") % str(e))
|
fail(_("Improper value for 'size': %s") % str(e))
|
||||||
|
|
||||||
def convert_perms(val):
|
def convert_perms(val):
|
||||||
|
@ -105,7 +105,7 @@ class Cloner(object):
|
|||||||
Guest.validate_name(self.conn, name,
|
Guest.validate_name(self.conn, name,
|
||||||
check_collision=not self.replace,
|
check_collision=not self.replace,
|
||||||
validate=False)
|
validate=False)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
raise ValueError(_("Invalid name for new guest: %s") % e)
|
raise ValueError(_("Invalid name for new guest: %s") % e)
|
||||||
|
|
||||||
self._clone_name = name
|
self._clone_name = name
|
||||||
@ -115,7 +115,7 @@ class Cloner(object):
|
|||||||
def set_clone_uuid(self, uuid):
|
def set_clone_uuid(self, uuid):
|
||||||
try:
|
try:
|
||||||
util.validate_uuid(uuid)
|
util.validate_uuid(uuid)
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
raise ValueError(_("Invalid uuid for new guest: %s") % e)
|
raise ValueError(_("Invalid uuid for new guest: %s") % e)
|
||||||
|
|
||||||
if util.vm_uuid_collision(self.conn, uuid):
|
if util.vm_uuid_collision(self.conn, uuid):
|
||||||
@ -147,7 +147,7 @@ class Cloner(object):
|
|||||||
disk.set_vol_install(vol_install)
|
disk.set_vol_install(vol_install)
|
||||||
disk.validate()
|
disk.validate()
|
||||||
disklist.append(disk)
|
disklist.append(disk)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error setting clone path.", exc_info=True)
|
logging.debug("Error setting clone path.", exc_info=True)
|
||||||
raise ValueError(_("Could not use path '%s' for cloning: %s") %
|
raise ValueError(_("Could not use path '%s' for cloning: %s") %
|
||||||
(path, str(e)))
|
(path, str(e)))
|
||||||
@ -486,7 +486,7 @@ class Cloner(object):
|
|||||||
dst_dev.setup(meter=meter)
|
dst_dev.setup(meter=meter)
|
||||||
if self._nvram_disk:
|
if self._nvram_disk:
|
||||||
self._nvram_disk.setup(meter=meter)
|
self._nvram_disk.setup(meter=meter)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Duplicate failed: %s", str(e))
|
logging.debug("Duplicate failed: %s", str(e))
|
||||||
if dom:
|
if dom:
|
||||||
dom.undefine()
|
dom.undefine()
|
||||||
@ -580,7 +580,7 @@ class Cloner(object):
|
|||||||
if newd.wants_storage_creation():
|
if newd.wants_storage_creation():
|
||||||
raise ValueError(_("Disk path '%s' does not exist.") %
|
raise ValueError(_("Disk path '%s' does not exist.") %
|
||||||
newd.path)
|
newd.path)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Exception creating clone disk objects",
|
logging.debug("Exception creating clone disk objects",
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
raise ValueError(_("Could not determine original disk "
|
raise ValueError(_("Could not determine original disk "
|
||||||
|
@ -238,7 +238,7 @@ class VirtualConnection(object):
|
|||||||
try:
|
try:
|
||||||
xml = vol.XMLDesc(0)
|
xml = vol.XMLDesc(0)
|
||||||
ret.append(StorageVolume(weakref.ref(self), parsexml=xml))
|
ret.append(StorageVolume(weakref.ref(self), parsexml=xml))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Fetching volume XML failed: %s", e)
|
logging.debug("Fetching volume XML failed: %s", e)
|
||||||
|
|
||||||
if self.cache_object_fetch:
|
if self.cache_object_fetch:
|
||||||
|
@ -212,7 +212,7 @@ class VirtualDisk(VirtualDevice):
|
|||||||
try:
|
try:
|
||||||
# Get UID for string name
|
# Get UID for string name
|
||||||
uid = pwd.getpwnam(username)[2]
|
uid = pwd.getpwnam(username)[2]
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error looking up username: %s", str(e))
|
logging.debug("Error looking up username: %s", str(e))
|
||||||
return []
|
return []
|
||||||
|
|
||||||
@ -316,7 +316,7 @@ class VirtualDisk(VirtualDevice):
|
|||||||
|
|
||||||
logging.debug("setfacl failed, trying old fashioned way")
|
logging.debug("setfacl failed, trying old fashioned way")
|
||||||
fix_perms(dirname, useacl)
|
fix_perms(dirname, useacl)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errdict[dirname] = str(e)
|
errdict[dirname] = str(e)
|
||||||
|
|
||||||
return errdict
|
return errdict
|
||||||
@ -785,7 +785,7 @@ class VirtualDisk(VirtualDevice):
|
|||||||
parent_pool = conn.storagePoolLookupByName(self.source_pool)
|
parent_pool = conn.storagePoolLookupByName(self.source_pool)
|
||||||
vol_object = parent_pool.storageVolLookupByName(
|
vol_object = parent_pool.storageVolLookupByName(
|
||||||
self.source_volume)
|
self.source_volume)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self._source_volume_err = str(e)
|
self._source_volume_err = str(e)
|
||||||
logging.debug("Error fetching source pool=%s vol=%s",
|
logging.debug("Error fetching source pool=%s vol=%s",
|
||||||
self.source_pool, self.source_volume, exc_info=True)
|
self.source_pool, self.source_volume, exc_info=True)
|
||||||
|
@ -55,7 +55,7 @@ def _lookup_vol_by_path(conn, path):
|
|||||||
vol = conn.storageVolLookupByPath(path)
|
vol = conn.storageVolLookupByPath(path)
|
||||||
vol.info()
|
vol.info()
|
||||||
return vol, None
|
return vol, None
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if (hasattr(libvirt, "VIR_ERR_NO_STORAGE_VOL") and
|
if (hasattr(libvirt, "VIR_ERR_NO_STORAGE_VOL") and
|
||||||
e.get_error_code() != libvirt.VIR_ERR_NO_STORAGE_VOL):
|
e.get_error_code() != libvirt.VIR_ERR_NO_STORAGE_VOL):
|
||||||
raise
|
raise
|
||||||
@ -123,7 +123,7 @@ def check_if_path_managed(conn, path):
|
|||||||
vol = _lookup_vol_by_basename(pool, path)
|
vol = _lookup_vol_by_basename(pool, path)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
vol = None
|
vol = None
|
||||||
pool = None
|
pool = None
|
||||||
verr = str(e)
|
verr = str(e)
|
||||||
@ -475,7 +475,7 @@ class CloneStorageCreator(_StorageCreator):
|
|||||||
i += s
|
i += s
|
||||||
if i < size_bytes:
|
if i < size_bytes:
|
||||||
meter.update(i)
|
meter.update(i)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
raise RuntimeError(_("Error cloning diskimage %s to %s: %s") %
|
raise RuntimeError(_("Error cloning diskimage %s to %s: %s") %
|
||||||
(self._input_path, self._output_path, str(e)))
|
(self._input_path, self._output_path, str(e)))
|
||||||
finally:
|
finally:
|
||||||
|
@ -187,7 +187,7 @@ class DistroInstaller(Installer):
|
|||||||
dev.validate()
|
dev.validate()
|
||||||
|
|
||||||
val = dev.path
|
val = dev.path
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error validating install location", exc_info=True)
|
logging.debug("Error validating install location", exc_info=True)
|
||||||
raise ValueError(_("Validating install media '%s' failed: %s") %
|
raise ValueError(_("Validating install media '%s' failed: %s") %
|
||||||
(str(val), e))
|
(str(val), e))
|
||||||
@ -209,7 +209,7 @@ class DistroInstaller(Installer):
|
|||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
fetcher.prepareLocation()
|
fetcher.prepareLocation()
|
||||||
except ValueError, e:
|
except ValueError as e:
|
||||||
logging.debug("Error preparing install location",
|
logging.debug("Error preparing install location",
|
||||||
exc_info=True)
|
exc_info=True)
|
||||||
raise ValueError(_("Invalid install location: ") + str(e))
|
raise ValueError(_("Invalid install location: ") + str(e))
|
||||||
|
@ -85,7 +85,7 @@ class Guest(XMLBuilder):
|
|||||||
|
|
||||||
logging.info("Undefining guest '%s'", name)
|
logging.info("Undefining guest '%s'", name)
|
||||||
vm.undefine()
|
vm.undefine()
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
raise RuntimeError(_("Could not remove old vm '%s': %s") %
|
raise RuntimeError(_("Could not remove old vm '%s': %s") %
|
||||||
(str(e)))
|
(str(e)))
|
||||||
|
|
||||||
@ -438,7 +438,7 @@ class Guest(XMLBuilder):
|
|||||||
try:
|
try:
|
||||||
logging.debug("XML fetched from libvirt object:\n%s",
|
logging.debug("XML fetched from libvirt object:\n%s",
|
||||||
self.domain.XMLDesc(0))
|
self.domain.XMLDesc(0))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error fetching XML from libvirt object: %s", e)
|
logging.debug("Error fetching XML from libvirt object: %s", e)
|
||||||
|
|
||||||
|
|
||||||
@ -451,7 +451,7 @@ class Guest(XMLBuilder):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.domain.setAutostart(True)
|
self.domain.setAutostart(True)
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if util.is_error_nosupport(e):
|
if util.is_error_nosupport(e):
|
||||||
logging.warn("Could not set autostart flag: libvirt "
|
logging.warn("Could not set autostart flag: libvirt "
|
||||||
"connection does not support autostart.")
|
"connection does not support autostart.")
|
||||||
@ -527,7 +527,7 @@ class Guest(XMLBuilder):
|
|||||||
os.unlink(disk.path)
|
os.unlink(disk.path)
|
||||||
|
|
||||||
meter.end(0)
|
meter.end(0)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Failed to remove disk '%s'",
|
logging.debug("Failed to remove disk '%s'",
|
||||||
name, exc_info=True)
|
name, exc_info=True)
|
||||||
logging.error("Failed to remove disk '%s': %s", name, e)
|
logging.error("Failed to remove disk '%s': %s", name, e)
|
||||||
|
@ -117,7 +117,7 @@ def _default_keymap():
|
|||||||
logging.debug("Found keymap=%s in %s", kt, path)
|
logging.debug("Found keymap=%s in %s", kt, path)
|
||||||
break
|
break
|
||||||
logging.debug("Didn't find keymap in '%s'", path)
|
logging.debug("Didn't find keymap in '%s'", path)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error parsing '%s': %s", path, str(e))
|
logging.debug("Error parsing '%s': %s", path, str(e))
|
||||||
|
|
||||||
if kt is None:
|
if kt is None:
|
||||||
|
@ -254,21 +254,21 @@ class Interface(XMLBuilder):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
iface = self.conn.interfaceDefineXML(xml, 0)
|
iface = self.conn.interfaceDefineXML(xml, 0)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise RuntimeError(_("Could not define interface: %s") % str(e))
|
raise RuntimeError(_("Could not define interface: %s") % str(e))
|
||||||
|
|
||||||
errmsg = None
|
errmsg = None
|
||||||
if create and not errmsg:
|
if create and not errmsg:
|
||||||
try:
|
try:
|
||||||
iface.create(0)
|
iface.create(0)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = _("Could not create interface: %s") % str(e)
|
errmsg = _("Could not create interface: %s") % str(e)
|
||||||
|
|
||||||
if errmsg:
|
if errmsg:
|
||||||
# Try and clean up the leftover pool
|
# Try and clean up the leftover pool
|
||||||
try:
|
try:
|
||||||
iface.undefine()
|
iface.undefine()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error cleaning up interface after failure: " +
|
logging.debug("Error cleaning up interface after failure: " +
|
||||||
"%s" % str(e))
|
"%s" % str(e))
|
||||||
raise RuntimeError(errmsg)
|
raise RuntimeError(errmsg)
|
||||||
|
@ -35,7 +35,7 @@ def _new_poll_helper(origmap, typename, listfunc, buildfunc):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
objs = listfunc()
|
objs = listfunc()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Unable to list all %ss: %s", typename, e)
|
logging.debug("Unable to list all %ss: %s", typename, e)
|
||||||
|
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
@ -75,11 +75,11 @@ def _old_poll_helper(origmap, typename,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
newActiveNames = active_list()
|
newActiveNames = active_list()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Unable to list active %ss: %s", typename, e)
|
logging.debug("Unable to list active %ss: %s", typename, e)
|
||||||
try:
|
try:
|
||||||
newInactiveNames = inactive_list()
|
newInactiveNames = inactive_list()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Unable to list inactive %ss: %s", typename, e)
|
logging.debug("Unable to list inactive %ss: %s", typename, e)
|
||||||
|
|
||||||
def check_obj(name):
|
def check_obj(name):
|
||||||
@ -89,7 +89,7 @@ def _old_poll_helper(origmap, typename,
|
|||||||
if connkey not in origmap:
|
if connkey not in origmap:
|
||||||
try:
|
try:
|
||||||
obj = lookup_func(name)
|
obj = lookup_func(name)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Could not fetch %s '%s': %s",
|
logging.debug("Could not fetch %s '%s': %s",
|
||||||
typename, connkey, e)
|
typename, connkey, e)
|
||||||
return
|
return
|
||||||
@ -217,12 +217,12 @@ def _old_fetch_vms(backend, origmap, build_func):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
newActiveIDs = backend.listDomainsID()
|
newActiveIDs = backend.listDomainsID()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Unable to list active domains: %s", e)
|
logging.debug("Unable to list active domains: %s", e)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
newInactiveNames = backend.listDefinedDomains()
|
newInactiveNames = backend.listDefinedDomains()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.exception("Unable to list inactive domains: %s", e)
|
logging.exception("Unable to list inactive domains: %s", e)
|
||||||
|
|
||||||
def add_vm(vm):
|
def add_vm(vm):
|
||||||
|
@ -160,7 +160,7 @@ class StoragePool(_StorageObject):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
xml = conn.findStoragePoolSources(pool_type, source_xml, 0)
|
xml = conn.findStoragePoolSources(pool_type, source_xml, 0)
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if util.is_error_nosupport(e):
|
if util.is_error_nosupport(e):
|
||||||
return []
|
return []
|
||||||
raise
|
raise
|
||||||
@ -228,7 +228,7 @@ class StoragePool(_StorageObject):
|
|||||||
defpool.install(build=True, create=True, autostart=True)
|
defpool.install(build=True, create=True, autostart=True)
|
||||||
conn.clear_cache(pools=True)
|
conn.clear_cache(pools=True)
|
||||||
return defpool
|
return defpool
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
_("Couldn't create default storage pool '%s': %s") %
|
_("Couldn't create default storage pool '%s': %s") %
|
||||||
(path, str(e)))
|
(path, str(e)))
|
||||||
@ -529,33 +529,33 @@ class StoragePool(_StorageObject):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
pool = self.conn.storagePoolDefineXML(xml, 0)
|
pool = self.conn.storagePoolDefineXML(xml, 0)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise RuntimeError(_("Could not define storage pool: %s") % str(e))
|
raise RuntimeError(_("Could not define storage pool: %s") % str(e))
|
||||||
|
|
||||||
errmsg = None
|
errmsg = None
|
||||||
if build:
|
if build:
|
||||||
try:
|
try:
|
||||||
pool.build(libvirt.VIR_STORAGE_POOL_BUILD_NEW)
|
pool.build(libvirt.VIR_STORAGE_POOL_BUILD_NEW)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = _("Could not build storage pool: %s") % str(e)
|
errmsg = _("Could not build storage pool: %s") % str(e)
|
||||||
|
|
||||||
if create and not errmsg:
|
if create and not errmsg:
|
||||||
try:
|
try:
|
||||||
pool.create(0)
|
pool.create(0)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = _("Could not start storage pool: %s") % str(e)
|
errmsg = _("Could not start storage pool: %s") % str(e)
|
||||||
|
|
||||||
if autostart and not errmsg:
|
if autostart and not errmsg:
|
||||||
try:
|
try:
|
||||||
pool.setAutostart(True)
|
pool.setAutostart(True)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
errmsg = _("Could not set pool autostart flag: %s") % str(e)
|
errmsg = _("Could not set pool autostart flag: %s") % str(e)
|
||||||
|
|
||||||
if errmsg:
|
if errmsg:
|
||||||
# Try and clean up the leftover pool
|
# Try and clean up the leftover pool
|
||||||
try:
|
try:
|
||||||
pool.undefine()
|
pool.undefine()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error cleaning up pool after failure: " +
|
logging.debug("Error cleaning up pool after failure: " +
|
||||||
"%s" % str(e))
|
"%s" % str(e))
|
||||||
raise RuntimeError(errmsg)
|
raise RuntimeError(errmsg)
|
||||||
@ -846,7 +846,7 @@ class StorageVolume(_StorageObject):
|
|||||||
logging.debug("Storage volume '%s' install complete.",
|
logging.debug("Storage volume '%s' install complete.",
|
||||||
self.name)
|
self.name)
|
||||||
return vol
|
return vol
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("Error creating storage volume", exc_info=True)
|
logging.debug("Error creating storage volume", exc_info=True)
|
||||||
raise RuntimeError("Couldn't create storage volume "
|
raise RuntimeError("Couldn't create storage volume "
|
||||||
"'%s': '%s'" % (self.name, str(e)))
|
"'%s': '%s'" % (self.name, str(e)))
|
||||||
|
@ -56,13 +56,13 @@ def _get_flag(flag_name):
|
|||||||
def _try_command(func, run_args, check_all_error=False):
|
def _try_command(func, run_args, check_all_error=False):
|
||||||
try:
|
try:
|
||||||
func(*run_args)
|
func(*run_args)
|
||||||
except libvirt.libvirtError, e:
|
except libvirt.libvirtError as e:
|
||||||
if util.is_error_nosupport(e):
|
if util.is_error_nosupport(e):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if check_all_error:
|
if check_all_error:
|
||||||
return False
|
return False
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
# Other python exceptions likely mean the bindings are horked
|
# Other python exceptions likely mean the bindings are horked
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -83,7 +83,7 @@ class _URLFetcher(object):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
urlobj, size = self._grabber(url)
|
urlobj, size = self._grabber(url)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise ValueError(_("Couldn't acquire file %s: %s") %
|
raise ValueError(_("Couldn't acquire file %s: %s") %
|
||||||
(url, str(e)))
|
(url, str(e)))
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ class _HTTPURLFetcher(_URLFetcher):
|
|||||||
try:
|
try:
|
||||||
response = requests.head(url, allow_redirects=True)
|
response = requests.head(url, allow_redirects=True)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
logging.debug("HTTP hasFile request failed: %s", str(e))
|
logging.debug("HTTP hasFile request failed: %s", str(e))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@ -224,7 +224,7 @@ class _FTPURLFetcher(_URLFetcher):
|
|||||||
self._ftp = ftplib.FTP()
|
self._ftp = ftplib.FTP()
|
||||||
self._ftp.connect(parsed.hostname, parsed.port)
|
self._ftp.connect(parsed.hostname, parsed.port)
|
||||||
self._ftp.login()
|
self._ftp.login()
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
raise ValueError(_("Opening URL %s failed: %s.") %
|
raise ValueError(_("Opening URL %s failed: %s.") %
|
||||||
(self.location, str(e)))
|
(self.location, str(e)))
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ class _FTPURLFetcher(_URLFetcher):
|
|||||||
except ftplib.all_errors:
|
except ftplib.all_errors:
|
||||||
# If it's a dir
|
# If it's a dir
|
||||||
self._ftp.cwd(path)
|
self._ftp.cwd(path)
|
||||||
except ftplib.all_errors, e:
|
except ftplib.all_errors as e:
|
||||||
logging.debug("FTP hasFile: couldn't access %s: %s",
|
logging.debug("FTP hasFile: couldn't access %s: %s",
|
||||||
url, str(e))
|
url, str(e))
|
||||||
return False
|
return False
|
||||||
@ -707,14 +707,14 @@ class GenericDistro(Distro):
|
|||||||
self._getTreeinfoMedia("kernel"),
|
self._getTreeinfoMedia("kernel"),
|
||||||
self._getTreeinfoMedia("initrd"))
|
self._getTreeinfoMedia("initrd"))
|
||||||
except (ConfigParser.NoSectionError,
|
except (ConfigParser.NoSectionError,
|
||||||
ConfigParser.NoOptionError), e:
|
ConfigParser.NoOptionError) as e:
|
||||||
logging.debug(e)
|
logging.debug(e)
|
||||||
|
|
||||||
if self.treeinfo.has_section(isoSection):
|
if self.treeinfo.has_section(isoSection):
|
||||||
try:
|
try:
|
||||||
self._valid_iso_path = self.treeinfo.get(isoSection,
|
self._valid_iso_path = self.treeinfo.get(isoSection,
|
||||||
"boot.iso")
|
"boot.iso")
|
||||||
except ConfigParser.NoOptionError, e:
|
except ConfigParser.NoOptionError as e:
|
||||||
logging.debug(e)
|
logging.debug(e)
|
||||||
|
|
||||||
if self.type == "xen":
|
if self.type == "xen":
|
||||||
|
Loading…
Reference in New Issue
Block a user