class OsXenApiException(Exception): """Base OsXenapi Exception To correctly use this class, inherit from it and define a 'msg_fmt' property. That msg_fmt will get printf'd with the keyword arguments provided to the constructor. """ msg_fmt = _("An unknown exception occurred.") code = 500 def __init__(self, message=None, **kwargs): self.kwargs = kwargs if 'code' not in self.kwargs: try: self.kwargs['code'] = self.code except AttributeError: pass if not message: message = self.msg_fmt % kwargs self.message = message super(OsXenApiException, self).__init__(message) def format_message(self): # NOTE(mrodden): use the first argument to the python Exception object # which should be our full NovaException message, (see __init__) return self.args[0]
def _login_with_password(self, user, pw, session): login_exception = XenAPI.Failure( _("Unable to log in to XenAPI " "(is the Dom0 disk full?)")) with timeout.Timeout(self.timeout, login_exception): session.login_with_password(user, pw, self.PLUGIN_REQUIRED_VERSION, self.originator)
def _verify_plugin_version(self): requested_version = self.PLUGIN_REQUIRED_VERSION current_version = self.call_plugin_serialized( 'dom0_plugin_version.py', 'get_version') if not versionutils.is_compatible(requested_version, current_version): raise XenAPI.Failure( _("Plugin version mismatch (Expected %(exp)s, got %(got)s)") % {'exp': requested_version, 'got': current_version})
class SshExecCmdFailure(OsXenApiException): msg_fmt = _("Failed to execute: %(command)s\n" "stdout: %(stdout)s\n" "stderr: %(stderr)s")
class GetInterfaceOnHIMNMacError(OsXenApiException): msg_fmt = _("Cannot find eth matches mac: mac=(%(mac)s)")
class ExecuteCommandFailed(OsXenApiException): msg_fmt = _("Execute command failed: cmd=(%(cmd)s)")
class NoNetworkInterfaceInSameSegment(OsXenApiException): msg_fmt = _("Can't find network interface in the same network as \ ip=(%(ip)s)")
class VhdDiskTypeNotSupported(OsXenApiException): msg_fmt = _("Not supported VHD disk type: type=(%(disk_type)s)")
class VdiImportFailure(OsXenApiException): msg_fmt = _("Failed importing VDI from VHD stream: vdi_ref=(%(vdi_ref)s)")
class NotFound(OsXenApiException): msg_fmt = _("Not found error: %s")
class HostConnectionFailure(OsXenApiException): msg_fmt = _("Failed connecting to host %(host_netloc)s")
class InvalidImage(OsXenApiException): msg_fmt = _("Image is invalid: details is - (%(details)s)")
class SessionLoginTimeout(OsXenApiException): msg_fmt = _("Unable to log in to XenAPI (is the Dom0 disk full?)")
class PluginImageNotFound(OsXenApiException): msg_fmt = _("Image (%(image_id)s) not found.")
class PluginRetriesExceeded(OsXenApiException): msg_fmt = _("Number of retries to plugin (%(num_retries)d) exceeded.")
class fake_client_exception(exception.OsXenApiException): msg_fmt = _("Failed to connect to server")