예제 #1
0
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]
예제 #2
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)
예제 #3
0
    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})
예제 #4
0
class SshExecCmdFailure(OsXenApiException):
    msg_fmt = _("Failed to execute: %(command)s\n"
                "stdout: %(stdout)s\n"
                "stderr: %(stderr)s")
예제 #5
0
class GetInterfaceOnHIMNMacError(OsXenApiException):
    msg_fmt = _("Cannot find eth matches mac: mac=(%(mac)s)")
예제 #6
0
class ExecuteCommandFailed(OsXenApiException):
    msg_fmt = _("Execute command failed: cmd=(%(cmd)s)")
예제 #7
0
class NoNetworkInterfaceInSameSegment(OsXenApiException):
    msg_fmt = _("Can't find network interface in the same network as \
                ip=(%(ip)s)")
예제 #8
0
class VhdDiskTypeNotSupported(OsXenApiException):
    msg_fmt = _("Not supported VHD disk type: type=(%(disk_type)s)")
예제 #9
0
class VdiImportFailure(OsXenApiException):
    msg_fmt = _("Failed importing VDI from VHD stream: vdi_ref=(%(vdi_ref)s)")
예제 #10
0
class NotFound(OsXenApiException):
    msg_fmt = _("Not found error: %s")
예제 #11
0
class HostConnectionFailure(OsXenApiException):
    msg_fmt = _("Failed connecting to host %(host_netloc)s")
예제 #12
0
class InvalidImage(OsXenApiException):
    msg_fmt = _("Image is invalid: details is - (%(details)s)")
예제 #13
0
class SessionLoginTimeout(OsXenApiException):
    msg_fmt = _("Unable to log in to XenAPI (is the Dom0 disk full?)")
예제 #14
0
class PluginImageNotFound(OsXenApiException):
    msg_fmt = _("Image (%(image_id)s) not found.")
예제 #15
0
class PluginRetriesExceeded(OsXenApiException):
    msg_fmt = _("Number of retries to plugin (%(num_retries)d) exceeded.")
예제 #16
0
class fake_client_exception(exception.OsXenApiException):
    msg_fmt = _("Failed to connect to server")