deb-sahara/sahara/plugins/cdh/exceptions.py
Ken Chen e5ea6f4483 Add CM API lib into CDH plugin codes
We open a directory named "client" and add codes in it to support
API callings from CDH plugin codes, so that we can remove the
dependency on third party package cm_api. Most codes in client are
copied from cm_api source codes. We just changed some import
relationships, removed unused codes, and regulated a little to
make it pass pep8 test.

implements bp: add-lib-subset-cm-api

Change-Id: I73a66520f27271d628d1997c84c62140acb4aa54
2015-03-02 09:12:47 +08:00

79 lines
2.3 KiB
Python

# Copyright (c) 2015 Intel Corporation.
#
# 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.
from sahara import exceptions as e
from sahara.i18n import _
class CMApiVersionError(e.SaharaException):
"""Exception indicating that CM API Version does not meet requirement.
A message indicating the reason for failure must be provided.
"""
base_message = _("CM API version not meet requirement: %s")
def __init__(self, message):
self.code = "CM_API_VERSION_ERROR"
self.message = self.base_message % message
super(CMApiVersionError, self).__init__()
class CMApiException(e.SaharaException):
"""Exception Type from CM API Errors.
Any error result from the CM API is converted into this exception type.
This handles errors from the HTTP level as well as the API level.
"""
base_message = _("CM API error: %s")
def __init__(self, message):
self.code = "CM_API_EXCEPTION"
self.message = self.base_message % message
super(CMApiException, self).__init__()
class CMApiAttributeError(e.SaharaException):
"""Exception indicating a CM API attribute error.
A message indicating the reason for failure must be provided.
"""
base_message = _("CM API attribute error: %s")
def __init__(self, message):
self.code = "CM_API_ATTRIBUTE_ERROR"
self.message = self.base_message % message
super(CMApiAttributeError, self).__init__()
class CMApiValueError(e.SaharaException):
"""Exception indicating a CM API value error.
A message indicating the reason for failure must be provided.
"""
base_message = _("CM API value error: %s")
def __init__(self, message):
self.code = "CM_API_VALUE_ERROR"
self.message = self.base_message % message
super(CMApiValueError, self).__init__()