avoid duplicate text in ISCSIError message

The ISCSIError class defines a class-level message attribute with
value: "Error starting iSCSI target". This attribute is further
processed in RESTError.__init__ method, the ISCSIError super-class, to
create an Exception message concatenating self.message with provided
details argument.  However, the ISCISError.__init__ method provides a
details attribute prefixed with the same text to the super(ISCSIError,
self).__init__ method.  As a result, the text appears twice:
"ISCSIError: Error starting iSCSI target: Error starting iSCSI target:
ISCSI daemon didn't initialize. Failed with exit code 107. stdout: .
stderr: tgtadm: failed to send request hdr to tgt daemon, Transport
endpoint is not connected"

The patch purpose is to remove the details prefix to avoid duplicate
text in the exception text while honouring ISCSIError.message.

Change-Id: I9e1434ae17da5112527a841ac069ed2285566cca
This commit is contained in:
dparalen 2015-10-20 14:59:16 +02:00
parent 1aeef4dc0d
commit e51ccbe7c3

@ -311,8 +311,7 @@ class ISCSIError(RESTError):
message = 'Error starting iSCSI target'
def __init__(self, error_msg, exit_code, stdout, stderr):
details = ('Error starting iSCSI target: {0}. Failed with exit code '
'{1}. stdout: {2}. stderr: {3}')
details = ('{0}. Failed with exit code {1}. stdout: {2}. stderr: {3}')
details = details.format(error_msg, exit_code, stdout, stderr)
super(ISCSIError, self).__init__(details)