| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251 |
- # Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- #
- # Modifications made by Cloudera are:
- # Copyright (c) 2016 Cloudera, Inc. All rights reserved.
- #
- # Licensed under the Apache License, Version 2.0 (the "License"). You
- # may not use this file except in compliance with the License. A copy of
- # the License is located at
- #
- # http://aws.amazon.com/apache2.0/
- #
- # or in the "license" file accompanying this file. This file 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.
- class AltusCLIError(Exception):
- """
- The base exception class for Altus CLI exceptions.
- """
- fmt = 'An unspecified error occured'
- def __init__(self, **kwargs):
- msg = self.fmt.format(**kwargs)
- Exception.__init__(self, msg)
- self.kwargs = kwargs
- class ValidationError(AltusCLIError):
- """
- An exception occurred validating parameters.
- """
- fmt = "Invalid value ('{value}') for param {param} of type {type_name}"
- class ParamValidationError(AltusCLIError):
- fmt = 'Parameter validation failed:\n{report}'
- class DataNotFoundError(AltusCLIError):
- """
- The data associated with a particular path could not be loaded.
- """
- fmt = 'Unable to load data for: {data_path}'
- class ExecutableNotFoundError(AltusCLIError):
- """
- The executable was not found.
- """
- fmt = 'Could not find executable named: {executable_name}'
- class OperationNotPageableError(AltusCLIError):
- fmt = 'Operation cannot be paginated: {operation_name}'
- class ClientError(Exception):
- MSG_TEMPLATE = (
- 'An error occurred: {error_message} ('
- 'Status Code: {http_status_code}; '
- 'Error Code: {error_code}; '
- 'Service: {service_name}; '
- 'Operation: {operation_name}; '
- 'Request ID: {request_id};)')
- def __init__(self, error_response, operation_name, service_name,
- http_status_code, request_id):
- msg = self.MSG_TEMPLATE.format(
- error_code=error_response['error'].get('code', 'Unknown'),
- error_message=error_response['error'].get('message', 'Unknown'),
- operation_name=operation_name,
- service_name=service_name,
- http_status_code=http_status_code,
- request_id=request_id)
- super(ClientError, self).__init__(msg)
- self.response = error_response
- class UnseekableStreamError(AltusCLIError):
- """
- Need to seek a stream, but stream does not support seeking.
- """
- fmt = ('Need to rewind the stream {stream_object}, but stream '
- 'is not seekable.')
- class EndpointConnectionError(AltusCLIError):
- fmt = (
- 'Could not connect to the endpoint URL: "{endpoint_url}"')
- class IncompleteReadError(AltusCLIError):
- """
- HTTP response did not return expected number of bytes.
- """
- fmt = ('{actual_bytes} read, but total bytes '
- 'expected is {expected_bytes}.')
- class PaginationError(AltusCLIError):
- fmt = 'Error during pagination: {message}'
- class UnknownSignatureVersionError(AltusCLIError):
- """
- Requested Signature Version is not known.
- """
- fmt = 'Unknown Signature Version: {signature_version}.'
- class UnsupportedSignatureVersionError(AltusCLIError):
- """
- Error when trying to access a method on a client that does not exist.
- """
- fmt = 'Signature version is not supported: {signature_version}'
- class NoCredentialsError(AltusCLIError):
- """
- No credentials could be found
- """
- fmt = 'Unable to locate Altus credentials'
- class UnknownCredentialError(AltusCLIError):
- """
- Tried to insert before/after an unregistered credential type.
- """
- fmt = 'Credential named {name} not found.'
- class PartialCredentialsError(AltusCLIError):
- """
- Only partial credentials were found.
- """
- fmt = 'Partial credentials found in {provider}, missing: {cred_var}'
- class BaseEndpointResolverError(AltusCLIError):
- """
- Base error for endpoint resolving errors.
- Should never be raised directly, but clients can catch
- this exception if they want to generically handle any errors
- during the endpoint resolution process.
- """
- class NoRegionError(BaseEndpointResolverError):
- """
- No region was specified.
- """
- fmt = 'You must specify a region.'
- class ProfileNotFound(AltusCLIError):
- """
- The specified configuration profile was not found in the
- configuration file.
- """
- fmt = 'The config profile ({profile}) could not be found'
- class ConfigNotFound(AltusCLIError):
- """
- The specified configuration file could not be found.
- """
- fmt = 'The specified config file ({path}) could not be found.'
- class ConfigParseError(AltusCLIError):
- """
- The configuration file could not be parsed.
- """
- fmt = 'Unable to parse config file: {path}'
- class ClusterTerminatingError(AltusCLIError):
- """
- The cluster is terminating or has already terminated.
- """
- fmt = 'Cluster {cluster_name} is terminating.'
- class ClusterStartingError(AltusCLIError):
- """
- The cluster is starting.
- """
- fmt = 'Cluster {cluster_name} is starting.'
- class ClusterFailedError(AltusCLIError):
- """
- The cluster failed to start.
- """
- fmt = 'Cluster {cluster_name} failed to start.'
- class ClusterDoesNotExistError(AltusCLIError):
- """
- Cluster with the given name does not exist.
- """
- fmt = 'Cluster {cluster_name} does not exist.'
- class ClusterStatusNotFound(AltusCLIError):
- """
- Unable to find cluster status.
- """
- fmt = 'Unable to find {cluster_name}\'s status.'
- class ClusterEndpointNotFound(AltusCLIError):
- """
- Unable to find cluster's Cloudera Manager Endpoint.
- """
- fmt = 'Unable to find {cluster_name}\'s Cloudera Manager Endpoint.'
- class MultipleClustersExist(AltusCLIError):
- """
- Multiple clusters exist, expected single cluster.
- """
- fmt = 'Multiple clusters exist, expected single cluster.'
- class SSHNotFoundError(AltusCLIError):
- """
- SSH or Putty not available.
- """
- fmt = 'SSH or Putty not available.'
- class WrongPuttyKeyError(AltusCLIError):
- """
- A wrong key has been used with a compatible program.
- """
- fmt = 'Key file file format is incorrect. Putty expects a ppk file.'
|