Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XenError dies if no XML file on the filesystem #158

Closed
matelakat opened this issue Jun 4, 2014 · 0 comments
Closed

XenError dies if no XML file on the filesystem #158

matelakat opened this issue Jun 4, 2014 · 0 comments

Comments

@matelakat
Copy link
Contributor

If the filesystem doesn't have the:
/opt/xensource/sm/XE_SR_ERRORCODES.xml
file, it fails in a very ugly way:

on xs64bit:

======================================================================
ERROR: test_mount (test_NFSSR.TestNFSSR)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage-manager/sm/tests/testlib.py", line 279, in decorated
    result = func(self, context, *args, **kwargs)
  File "/storage-manager/sm/tests/test_NFSSR.py", line 34, in test_mount
    sr = create_nfs_sr()
  File "/storage-manager/sm/tests/test_NFSSR.py", line 27, in create_nfs_sr
    sr = NFSSR.NFSSR(command, '0')
  File "/storage-manager/sm/drivers/SR.py", line 139, in __init__
    self.load(sr_uuid)
  File "/storage-manager/sm/drivers/NFSSR.py", line 75, in load
    raise xs_errors.XenError('ConfigServerMissing')
  File "/storage-manager/sm/drivers/xs_errors.py", line 32, in __init__
    raise Exception.__init__(self, '')
TypeError: TypeError: unbound method __init__() must be called with Exception instance as first argument (got XenError instance instead)

on trunk:

======================================================================
ERROR: test_mount (test_NFSSR.TestNFSSR)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage-manager/sm/tests/testlib.py", line 279, in decorated
    result = func(self, context, *args, **kwargs)
  File "/storage-manager/sm/tests/test_NFSSR.py", line 34, in test_mount
    sr = create_nfs_sr()
  File "/storage-manager/sm/tests/test_NFSSR.py", line 27, in create_nfs_sr
    sr = NFSSR.NFSSR(command, '0')
  File "/storage-manager/sm/drivers/SR.py", line 139, in __init__
    self.load(sr_uuid)
  File "/storage-manager/sm/drivers/NFSSR.py", line 75, in load
    raise xs_errors.XenError('ConfigServerMissing')
  File "/storage-manager/sm/drivers/xs_errors.py", line 32, in __init__
    raise Exception.__init__(self, '')
TypeError: TypeError: exceptions must be classes, instances, or strings (deprecated), not NoneType

So we should come up with a different fix, something like:

--- a/drivers/xs_errors.py
+++ b/drivers/xs_errors.py
@@ -28,8 +28,7 @@ class XenError(object):
     def __init__(self, key, opterr=None):
         # Check the XML definition file exists
         if not os.path.exists(XML_DEFS):
-            print "No XML def file found"
-            raise Exception.__init__(self, '')
+            raise Exception("No XML def file found")

         # Read the definition list
         self._fromxml('SM-errorcodes')

In this case you get the output:

======================================================================
ERROR: test_mount (test_NFSSR.TestNFSSR)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/storage-manager/sm/tests/testlib.py", line 279, in decorated
    result = func(self, context, *args, **kwargs)
  File "/storage-manager/sm/tests/test_NFSSR.py", line 34, in test_mount
    sr = create_nfs_sr()
  File "/storage-manager/sm/tests/test_NFSSR.py", line 27, in create_nfs_sr
    sr = NFSSR.NFSSR(command, '0')
  File "/storage-manager/sm/drivers/SR.py", line 139, in __init__
    self.load(sr_uuid)
  File "/storage-manager/sm/drivers/NFSSR.py", line 75, in load
    raise xs_errors.XenError('ConfigServerMissing')
  File "/storage-manager/sm/drivers/xs_errors.py", line 31, in __init__
    raise Exception("No XML def file found")
Exception: No XML def file found

Which now makes sense

chandrikas pushed a commit that referenced this issue Jun 4, 2014
If the XML error description does not exist in the filesystem, XenError
tried to call Exception.__init__(self, ''), which is invalid, as self is
not inheriting from Exception.

Github: fixes #158

Signed-off-by: Mate Lakat <mate.lakat@citrix.com>
andrey-podko pushed a commit to andrey-podko/sm that referenced this issue Aug 16, 2022
If the XML error description does not exist in the filesystem, XenError
tried to call Exception.__init__(self, ''), which is invalid, as self is
not inheriting from Exception.

Github: fixes xapi-project#158

(cherry picked from commit cb1e0df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant