omni/nova/virt/ec2/exception_handler.py
Pratik Shah 264939cfb5 Applied pep8 fixes
Closes-Bug: #1703514

Change-Id: I89c25bd9e678dc2f7cc27f952aa4833e26c90f4a
2017-07-24 16:25:25 +05:30

31 lines
1.3 KiB
Python

"""
Copyright (c) 2014 Thoughtworks.
Copyright (c) 2016 Platform9 Systems 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. 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 expressed or implied. See the
License for the specific language governing permissions and limitations
under the License.
"""
from nova import exception
class Ec2ExceptionHandler(object):
"""This is a class which can be used to create mapping between EC2
Exception messages to Nova based Exceptions. Also gives control on the
error message displayed to the user.
"""
@staticmethod
def get_processed_exception(ec2_response_error_exc):
if ec2_response_error_exc.error_code == "AuthFailure":
return exception.Forbidden("Please check AWS credentials")
if ec2_response_error_exc.error_code == "InvalidAMIID.NotFound":
return exception.ImageNotFoundEC2("Invalid Image")
return exception.NovaException(ec2_response_error_exc.message)