mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 12:16:49 +00:00
fix: connection errors on VM actions name the host only to administrators
When a VM action failed because its host could not be reached (the
connection could not be opened, or it dropped during the call), the
error page showed libvirt's connection error to any user: it names the
host and how it is reached, e.g. "ssh: connect to host 10.x port 22".
The lists and the VM page already keep that to administrators.
- Opening a connection now fails with ConnectionFailed (a subclass of
OperationError). A dropped connection is recognized by its error
domain and code (RPC/remote/SSH layer with a transport code, measured:
a keepalive timeout is VIR_FROM_RPC/VIR_ERR_INTERNAL_ERROR); an
operation the daemon does not support (VIR_ERR_NO_SUPPORT) is not
treated as one.
- ExceptionMiddleware (pages and API) and the views that report the
error themselves (snapshot, revert, disk deletion, clone) show it to
superusers and view_instances users, and to everyone else "The host
of this virtual machine cannot be reached right now." Errors of the
operation itself ("domain is not running") are shown as before.
Checked on the test setup: powering on a VM of an unreachable compute
shows the owner the generic text and the administrator the error. The
tests fail on the previous code.
This commit is contained in:
parent
9c3a7cdbec
commit
802e90c79f
5 changed files with 133 additions and 7 deletions
|
|
@ -342,7 +342,7 @@ class wvmConnectionManager(object):
|
|||
return connection.connection
|
||||
else:
|
||||
# raise libvirt error
|
||||
raise util.OperationError(connection.last_error)
|
||||
raise util.ConnectionFailed(connection.last_error)
|
||||
|
||||
def host_is_up(self, conn_type, hostname, timeout=1):
|
||||
"""True if the libvirt endpoint of hostname accepts a TCP (or Unix
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ class OperationError(libvirt.libvirtError):
|
|||
self.err = None
|
||||
|
||||
|
||||
class ConnectionFailed(OperationError):
|
||||
"""The host could not be connected to; the message may name it and how it
|
||||
is reached."""
|
||||
|
||||
|
||||
def is_kvm_available(xml):
|
||||
kvm_domains = get_xml_path(xml, "//domain/@type='kvm'")
|
||||
return kvm_domains > 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue