ia64/xen-unstable

changeset 14936:1786112d2430

[XEND] Add more exceptions and error messages

signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
author Tom Wilkie <tom.wilkie@gmail.com>
date Wed Apr 25 16:11:20 2007 +0100 (2007-04-25)
parents 2fe1f293e52d
children 5d2e5d05e828
files tools/python/xen/xend/XendError.py tools/python/xen/xm/messages/en/xen-xm.po
line diff
     1.1 --- a/tools/python/xen/xend/XendError.py	Wed Apr 25 15:42:34 2007 +0100
     1.2 +++ b/tools/python/xen/xend/XendError.py	Wed Apr 25 16:11:20 2007 +0100
     1.3 @@ -48,10 +48,6 @@ class PIFIsPhysical(XendError):
     1.4      def __init__(self):
     1.5          XendError.__init__(self, 'PIF is physical')
     1.6  
     1.7 -class VLANTagInvalid(XendError):
     1.8 -    def __init__(self):
     1.9 -        XendError.__init__(self, 'VLAN tag invalid')
    1.10 -
    1.11  class VmError(XendError):
    1.12      """Vm construction error."""
    1.13      pass
    1.14 @@ -62,7 +58,111 @@ class HVMRequired(VmError):
    1.15                             'HVM guest support is unavailable: is VT/AMD-V '
    1.16                             'supported by your CPU and enabled in your BIOS?')
    1.17  
    1.18 +class XendAPIError(XendError):
    1.19 +    """Extend this class for all error thrown by
    1.20 +    autoplugged classes"""
    1.21 +    def __init__(self):
    1.22 +        XendError.__init__(self, 'XendAPI Error: You should never see this'
    1.23 +                           ' message; this class need to be overidden')
    1.24  
    1.25 +    def get_api_error(self):
    1.26 +        return ['INTERNAL_ERROR', 'You should never see this message; '
    1.27 +                'this method needs to be overidden']
    1.28 +
    1.29 +class CreateUnspecifiedAttributeError(XendAPIError):
    1.30 +    def __init__(self, attr_name, class_name):
    1.31 +        XendAPIError.__init__(self)
    1.32 +        self.attr_name = attr_name
    1.33 +        self.class_name = class_name
    1.34 +
    1.35 +    def get_api_error(self):
    1.36 +        return ['CREATE_UNSPECIFIED_ATTRIBUTE', self.attr_name,
    1.37 +                self.class_name]
    1.38 +
    1.39 +    def __str__(self):
    1.40 +        return "CREATE_UNSPECIFIED_ATTRIBUTE: %s, %s" % (self.attr_name,
    1.41 +                 self.class_name)
    1.42 +
    1.43 +class UnmanagedNetworkError(XendAPIError):
    1.44 +    def __init__(self, attr_name):
    1.45 +        XendAPIError.__init__(self)
    1.46 +        self.attr_name = attr_name
    1.47 +
    1.48 +    def get_api_error(self):
    1.49 +        return ['UNMANAGED_NETWORK_ERROR', self.attr_name]
    1.50 +
    1.51 +    def __str__(self):
    1.52 +        return "UNMANAGED_NETWORK_ERROR: %s" % self.attr_name
    1.53 +
    1.54 +class UniqueNameError(XendAPIError):
    1.55 +    def __init__(self, name, class_name):
    1.56 +        XendAPIError.__init__(self)
    1.57 +        self.name = name
    1.58 +        self.class_name = class_name
    1.59 +        
    1.60 +    def get_api_error(self):
    1.61 +        return ['UNIQUE_NAME_ERROR', self.name, self.class_name]        
    1.62 +
    1.63 +    def __str__(self):
    1.64 +        return 'UNIQUE_NAME_ERROR: %s, %s' % (self.name, self.class_name)
    1.65 +
    1.66 +class InvalidDeviceError(XendAPIError):
    1.67 +    def __init__(self, dev):
    1.68 +        XendAPIError.__init__(self)
    1.69 +        self.dev = dev
    1.70 +        
    1.71 +    def get_api_error(self):
    1.72 +        return ['INVALID_DEVICE_ERROR', self.dev]        
    1.73 +
    1.74 +    def __str__(self):
    1.75 +        return 'INVALID_DEVICE_ERROR: %s' % self.dev
    1.76 +    
    1.77 +class DeviceExistsError(XendAPIError):
    1.78 +    def __init__(self, dev):
    1.79 +        XendAPIError.__init__(self)
    1.80 +        self.dev = dev
    1.81 +        
    1.82 +    def get_api_error(self):
    1.83 +        return ['DEVICE_EXISTS_ERROR', self.dev]        
    1.84 +
    1.85 +    def __str__(self):
    1.86 +        return 'DEVICE_EXISTS_ERROR: %s' % self.dev
    1.87 +
    1.88 +class InvalidHandleError(XendAPIError):
    1.89 +    def __init__(self, klass, handle):
    1.90 +        XendAPIError.__init__(self)
    1.91 +        self.klass = klass
    1.92 +        self.handle = handle
    1.93 +        
    1.94 +    def get_api_error(self):
    1.95 +        return ['HANDLE_INVALID', self.klass, self.handle]        
    1.96 +
    1.97 +    def __str__(self):
    1.98 +        return 'HANDLE_INVALID: %s %s' % (self.klass, self.handle)
    1.99 +
   1.100 +class ImplementationError(XendAPIError):
   1.101 +    def __init__(self, klass, func):
   1.102 +        XendAPIError.__init__(self)
   1.103 +        self.klass = klass
   1.104 +        self.func = func
   1.105 +
   1.106 +    def get_api_error(self):
   1.107 +        return ['IMPLEMENTATION_ERROR', self.klass, self.func]        
   1.108 +
   1.109 +    def __str__(self):
   1.110 +        return 'IMPLEMENTATION_ERROR: %s %s' % (self.klass, self.func)
   1.111 +
   1.112 +class VLANTagInvalid(XendAPIError):
   1.113 +    def __init__(self, vlan):
   1.114 +        XendAPIError.__init__(self)
   1.115 +        self.vlan = vlan
   1.116 +
   1.117 +    def get_api_error(self):
   1.118 +        return ['VLAN_TAG_INVALID', self.vlan]
   1.119 +
   1.120 +    def __str__(self):
   1.121 +        return 'VLAN_TAG_INVALID: %s' % self.vlan
   1.122 +    
   1.123  XEND_ERROR_AUTHENTICATION_FAILED = ('ELUSER', 'Authentication Failed')
   1.124  XEND_ERROR_SESSION_INVALID       = ('EPERMDENIED', 'Session Invalid')
   1.125  XEND_ERROR_DOMAIN_INVALID        = ('EINVALIDDOMAIN', 'Domain Invalid')
     2.1 --- a/tools/python/xen/xm/messages/en/xen-xm.po	Wed Apr 25 15:42:34 2007 +0100
     2.2 +++ b/tools/python/xen/xm/messages/en/xen-xm.po	Wed Apr 25 16:11:20 2007 +0100
     2.3 @@ -67,3 +67,24 @@ msgstr "HVM guest support is unavailable
     2.4  
     2.5  msgid "SESSION_NOT_REGISTERED"
     2.6  msgstr "This session is not registered to receive events.  You must call event.register before event.next.  (Session handle is %(1)s.)"
     2.7 +
     2.8 +msgid "CREATE_UNSPECIFIED_ATTRIBUTE"
     2.9 +msgstr "You need to specify %s when creating a new %s"
    2.10 + 
    2.11 +msgid "UNMANAGED_NETWORK_ERROR"
    2.12 +msgstr "Cannot change %s on an unmanaged network"
    2.13 + 
    2.14 +msgid "UNIQUE_NAME_ERROR"
    2.15 +msgstr "Name %s for class %s is not unique"
    2.16 +
    2.17 +msgid "INVALID_DEVICE_ERROR"
    2.18 +msgstr "Invalid device %s"
    2.19 +
    2.20 +msgid "DEVICE_EXISTS_ERROR"
    2.21 +msgstr "Device already exists %s"
    2.22 +
    2.23 +msgid "IMPLEMENTATION_ERROR"
    2.24 +msgstr "Class %s does not implement %s"
    2.25 +
    2.26 +msgid "VLAN_TAG_INVALID"
    2.27 +msgstr "VLAN tag invalid %s"
    2.28 \ No newline at end of file