2014-04-07 16:43:39 -04:00
|
|
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
|
|
|
|
|
|
# Copyright 2014 IBM Corporation
|
2015-11-20 17:05:36 -05:00
|
|
|
# Copyright 2015 Lenovo
|
2014-04-07 16:43:39 -04:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
2014-04-18 15:52:29 -04:00
|
|
|
|
2015-11-20 17:05:36 -05:00
|
|
|
import json
|
|
|
|
|
2014-04-18 15:52:29 -04:00
|
|
|
|
2013-11-02 17:32:48 -04:00
|
|
|
class ConfluentException(Exception):
|
2015-11-20 17:05:36 -05:00
|
|
|
apierrorcode = 500
|
|
|
|
apierrorstr = 'Unexpected Error'
|
|
|
|
|
|
|
|
def get_error_body(self):
|
|
|
|
return self.apierrorstr
|
2013-11-02 17:32:48 -04:00
|
|
|
|
2014-04-18 15:52:29 -04:00
|
|
|
|
2013-11-02 17:32:48 -04:00
|
|
|
class NotFoundException(ConfluentException):
|
2014-02-01 19:28:31 -05:00
|
|
|
# Something that could be construed as a name was not found
|
|
|
|
# basically, picture an http error code 404
|
2013-11-02 17:32:48 -04:00
|
|
|
pass
|
2013-11-03 09:52:43 -05:00
|
|
|
|
2014-04-18 15:52:29 -04:00
|
|
|
|
2013-11-03 09:52:43 -05:00
|
|
|
class InvalidArgumentException(ConfluentException):
|
2014-02-01 19:28:31 -05:00
|
|
|
# Something from the remote client wasn't correct
|
|
|
|
# like http code 400
|
|
|
|
pass
|
|
|
|
|
2014-04-18 15:52:29 -04:00
|
|
|
|
2014-04-01 16:32:56 -04:00
|
|
|
class TargetEndpointUnreachable(ConfluentException):
|
2014-02-01 19:28:31 -05:00
|
|
|
# A target system was unavailable. For example, a BMC
|
|
|
|
# was unreachable. http code 504
|
2013-11-03 09:52:43 -05:00
|
|
|
pass
|
2014-04-18 10:36:51 -04:00
|
|
|
|
2014-11-25 13:57:31 -05:00
|
|
|
|
2014-04-23 14:04:26 -04:00
|
|
|
class TargetEndpointBadCredentials(ConfluentException):
|
|
|
|
# target was reachable, but authentication/authorization
|
|
|
|
# failed
|
|
|
|
pass
|
|
|
|
|
2015-11-20 17:05:36 -05:00
|
|
|
|
2015-07-08 16:47:58 -04:00
|
|
|
class LockedCredentials(ConfluentException):
|
|
|
|
# A request was performed that required a credential, but the credential
|
|
|
|
# store is locked
|
|
|
|
pass
|
|
|
|
|
2014-04-18 15:52:29 -04:00
|
|
|
|
2014-04-18 10:36:51 -04:00
|
|
|
class ForbiddenRequest(ConfluentException):
|
|
|
|
# The client request is not allowed by authorization engine
|
|
|
|
pass
|
2014-11-25 13:57:31 -05:00
|
|
|
|
|
|
|
|
|
|
|
class NotImplementedException(ConfluentException):
|
|
|
|
# The current configuration/plugin is unable to perform
|
|
|
|
# the requested task. http code 501
|
2015-09-17 03:06:17 -04:00
|
|
|
pass
|
|
|
|
|
2015-11-20 17:05:36 -05:00
|
|
|
|
2015-09-17 03:06:17 -04:00
|
|
|
class GlobalConfigError(ConfluentException):
|
|
|
|
# The configuration in the global config file is not right
|
|
|
|
pass
|
2015-11-20 17:05:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
class PubkeyInvalid(ConfluentException):
|
|
|
|
apierrorcode = 502
|
|
|
|
apierrorstr = '502 - Invalid certificate or key on target'
|
|
|
|
|
|
|
|
def __init__(self, text, fingerprint, attribname):
|
|
|
|
super(PubkeyInvalid, self).__init__(self, text)
|
|
|
|
self.fingerprint = fingerprint
|
|
|
|
self.errorbody = json.dumps({attribname: fingerprint})
|
|
|
|
|
|
|
|
def get_error_body(self):
|
|
|
|
return self.errorbody
|