Merge pull request #28054 from iotcg/starlingx

pybind: add verbose error message

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2019-07-24 09:46:44 +08:00 committed by GitHub
commit 0869d95000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 131 additions and 38 deletions

View File

@ -182,10 +182,14 @@ get_name_list() {
orig="$*"
# extract list of monitors, mdss, osds, mgrs defined in startup.conf
allconf="$local "`$CCONF -c $conf -l mon | egrep -v '^mon$' || true ; \
$CCONF -c $conf -l mds | egrep -v '^mds$' || true ; \
$CCONF -c $conf -l mgr | egrep -v '^mgr$' || true ; \
$CCONF -c $conf -l osd | egrep -v '^osd$' || true`
allconf=$(for entity in \
$local \
`$CCONF -c $conf -l mon | egrep -v '^mon$' || true` \
`$CCONF -c $conf -l mds | egrep -v '^mds$' || true` \
`$CCONF -c $conf -l mgr | egrep -v '^mgr$' || true` \
`$CCONF -c $conf -l osd | egrep -v '^osd$' || true`; do
echo $entity
done | sort -u)
if [ -z "$orig" ]; then
what="$allconf"

View File

@ -351,7 +351,10 @@ class Error(Exception):
return (self.__class__, (self.message, self.errno))
class InvalidArgumentError(Error):
pass
def __init__(self, message, errno=None):
super(InvalidArgumentError, self).__init__(
"RADOS invalid argument (%s)" % message, errno)
class OSError(Error):
""" `OSError` class, derived from `Error` """
@ -359,72 +362,114 @@ class OSError(Error):
class InterruptedOrTimeoutError(OSError):
""" `InterruptedOrTimeoutError` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(InterruptedOrTimeoutError, self).__init__(
"RADOS interrupted or timeout (%s)" % message, errno)
class PermissionError(OSError):
""" `PermissionError` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(PermissionError, self).__init__(
"RADOS permission error (%s)" % message, errno)
class PermissionDeniedError(OSError):
""" deal with EACCES related. """
pass
def __init__(self, message, errno=None):
super(PermissionDeniedError, self).__init__(
"RADOS permission denied (%s)" % message, errno)
class ObjectNotFound(OSError):
""" `ObjectNotFound` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(ObjectNotFound, self).__init__(
"RADOS object not found (%s)" % message, errno)
class NoData(OSError):
""" `NoData` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(NoData, self).__init__(
"RADOS no data (%s)" % message, errno)
class ObjectExists(OSError):
""" `ObjectExists` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(ObjectExists, self).__init__(
"RADOS object exists (%s)" % message, errno)
class ObjectBusy(OSError):
""" `ObjectBusy` class, derived from `IOError` """
pass
def __init__(self, message, errno=None):
super(ObjectBusy, self).__init__(
"RADOS object busy (%s)" % message, errno)
class IOError(OSError):
""" `ObjectBusy` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(IOError, self).__init__(
"RADOS I/O error (%s)" % message, errno)
class NoSpace(OSError):
""" `NoSpace` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(NoSpace, self).__init__(
"RADOS no space (%s)" % message, errno)
class RadosStateError(Error):
""" `RadosStateError` class, derived from `Error` """
pass
def __init__(self, message, errno=None):
super(RadosStateError, self).__init__(
"RADOS rados state (%s)" % message, errno)
class IoctxStateError(Error):
""" `IoctxStateError` class, derived from `Error` """
pass
def __init__(self, message, errno=None):
super(IoctxStateError, self).__init__(
"RADOS Ioctx state error (%s)" % message, errno)
class ObjectStateError(Error):
""" `ObjectStateError` class, derived from `Error` """
pass
def __init__(self, message, errno=None):
super(ObjectStateError, self).__init__(
"RADOS object state error (%s)" % message, errno)
class LogicError(Error):
""" `` class, derived from `Error` """
pass
def __init__(self, message, errno=None):
super(LogicError, self).__init__(
"RADOS logic error (%s)" % message, errno)
class TimedOut(OSError):
""" `TimedOut` class, derived from `OSError` """
pass
def __init__(self, message, errno=None):
super(TimedOut, self).__init__(
"RADOS timed out (%s)" % message, errno)
class InProgress(Error):
""" `InProgress` class, derived from `Error` """
def __init__(self, message, errno=None):
super(InProgress, self).__init__(
"RADOS in progress error (%s)" % message, errno)
class IsConnected(Error):
""" `IsConnected` class, derived from `Error` """
def __init__(self, message, errno=None):
super(IsConnected, self).__init__(
"RADOS is connected error (%s)" % message, errno)
IF UNAME_SYSNAME == "FreeBSD":
@ -439,6 +484,8 @@ IF UNAME_SYSNAME == "FreeBSD":
errno.EINTR : InterruptedOrTimeoutError,
errno.ETIMEDOUT : TimedOut,
errno.EACCES : PermissionDeniedError,
errno.EINPROGRESS : InProgress,
errno.EISCONN : IsConnected,
errno.EINVAL : InvalidArgumentError,
}
ELSE:
@ -453,6 +500,8 @@ ELSE:
errno.EINTR : InterruptedOrTimeoutError,
errno.ETIMEDOUT : TimedOut,
errno.EACCES : PermissionDeniedError,
errno.EINPROGRESS : InProgress,
errno.EISCONN : IsConnected,
errno.EINVAL : InvalidArgumentError,
}

View File

@ -700,71 +700,111 @@ class OSError(Error):
return (self.__class__, (self.message, self.errno))
class PermissionError(OSError):
pass
def __init__(self, message, errno=None):
super(PermissionError, self).__init__(
"RBD permission error (%s)" % message, errno)
class ImageNotFound(OSError):
pass
def __init__(self, message, errno=None):
super(ImageNotFound, self).__init__(
"RBD image not found (%s)" % message, errno)
class ObjectNotFound(OSError):
pass
def __init__(self, message, errno=None):
super(ObjectNotFound, self).__init__(
"RBD object not found (%s)" % message, errno)
class ImageExists(OSError):
pass
def __init__(self, message, errno=None):
super(ImageExists, self).__init__(
"RBD image already exists (%s)" % message, errno)
class ObjectExists(OSError):
pass
def __init__(self, message, errno=None):
super(ObjectExists, self).__init__(
"RBD object already exists (%s)" % message, errno)
class IOError(OSError):
pass
def __init__(self, message, errno=None):
super(IOError, self).__init__(
"RBD I/O error (%s)" % message, errno)
class NoSpace(OSError):
pass
def __init__(self, message, errno=None):
super(NoSpace, self).__init__(
"RBD insufficient space available (%s)" % message, errno)
class IncompleteWriteError(OSError):
pass
def __init__(self, message, errno=None):
super(IncompleteWriteError, self).__init__(
"RBD incomplete write (%s)" % message, errno)
class InvalidArgument(OSError):
pass
def __init__(self, message, errno=None):
super(InvalidArgument, self).__init__(
"RBD invalid argument (%s)" % message, errno)
class LogicError(Error):
pass
class LogicError(OSError):
def __init__(self, message, errno=None):
super(LogicError, self).__init__(
"RBD logic error (%s)" % message, errno)
class ReadOnlyImage(OSError):
pass
def __init__(self, message, errno=None):
super(ReadOnlyImage, self).__init__(
"RBD read-only image (%s)" % message, errno)
class ImageBusy(OSError):
pass
def __init__(self, message, errno=None):
super(ImageBusy, self).__init__(
"RBD image is busy (%s)" % message, errno)
class ImageHasSnapshots(OSError):
pass
def __init__(self, message, errno=None):
super(ImageHasSnapshots, self).__init__(
"RBD image has snapshots (%s)" % message, errno)
class FunctionNotSupported(OSError):
pass
def __init__(self, message, errno=None):
super(FunctionNotSupported, self).__init__(
"RBD function not supported (%s)" % message, errno)
class ArgumentOutOfRange(OSError):
pass
def __init__(self, message, errno=None):
super(ArgumentOutOfRange, self).__init__(
"RBD arguments out of range (%s)" % message, errno)
class ConnectionShutdown(OSError):
pass
def __init__(self, message, errno=None):
super(ConnectionShutdown, self).__init__(
"RBD connection was shutdown (%s)" % message, errno)
class Timeout(OSError):
pass
def __init__(self, message, errno=None):
super(Timeout, self).__init__(
"RBD operation timeout (%s)" % message, errno)
class DiskQuotaExceeded(OSError):
pass
def __init__(self, message, errno=None):
super(DiskQuotaExceeded, self).__init__(
"RBD disk quota exceeded (%s)" % message, errno)
cdef errno_to_exception = {