Exemple #1
0
 def not_found(error):
     """Creates a Not Found Error response"""
     redfish_error = RedfishError("GeneralError", error.description)
     error_str = redfish_error.serialize()
     return Response(response=error_str,
                     status=status.HTTP_404_NOT_FOUND,
                     mimetype='application/json')
Exemple #2
0
        def unauthorized_error(error):
            """Creates a Unauthorized Error response"""
            redfish_error = RedfishError("GeneralError", error.description)

            error_str = redfish_error.serialize()
            return Response(response=error_str,
                            status=status.HTTP_401_UNAUTHORIZED,
                            mimetype='application/json')
Exemple #3
0
    def not_implemented(error):
        """Creates a Not Implemented Error response"""
        redfish_error = RedfishError("ActionNotSupported", error.description)
        redfish_error.add_extended_info(message_id="ActionNotSupported",
                                        message_args=["action"])

        error_str = redfish_error.serialize()
        return Response(response=error_str,
                        status=status.HTTP_501_NOT_IMPLEMENTED,
                        mimetype='application/json')
Exemple #4
0
    def test_serialize(self):
        """Tests the serialize function result against known result"""

        redfish_error = RedfishError("GeneralError", "General Error")
        result = json.loads(redfish_error.serialize())

        with open('oneview_redfish_toolkit/mockups/errors/'
                  'RedfishErrorNoExtendedInfo.json') as f:
            redfish_error_mockup = json.load(f)
        self.assertEqual(redfish_error_mockup, result)
Exemple #5
0
        def internal_server_error(error):
            """General InternalServerError handler for the app"""

            redfish_error = RedfishError(
                "InternalError",
                "The request failed due to an internal service error.  "
                "The service is still operational.")
            redfish_error.add_extended_info("InternalError")
            error_str = redfish_error.serialize()
            return Response(response=error_str,
                            status=status.HTTP_500_INTERNAL_SERVER_ERROR,
                            mimetype="application/json")
Exemple #6
0
    def bad_request(error):
        """Creates a Bad Request Error response"""
        redfish_error = RedfishError("PropertyValueNotInList",
                                     error.description)

        redfish_error.add_extended_info(message_id="PropertyValueNotInList",
                                        message_args=["VALUE", "PROPERTY"],
                                        related_properties=["PROPERTY"])

        error_str = redfish_error.serialize()
        return Response(response=error_str,
                        status=status.HTTP_400_BAD_REQUEST,
                        mimetype='application/json')
Exemple #7
0
    def test_redfish_error_with_extended_info(self):
        """Tests the add_extended_info with two additional info"""

        with open('oneview_redfish_toolkit/mockups/errors/'
                  'RedfishErrorExtendedInfo.json') as f:
            redfish_error_mockup = json.load(f)

        try:
            redfish_error = RedfishError(
                "GeneralError",
                "A general error has occurred. See ExtendedInfo "
                "for more information.")
            redfish_error.add_extended_info(
                message_id="PropertyValueNotInList",
                message_args=["RED", "IndicatorLED"],
                related_properties=["#/IndicatorLED"])
            redfish_error.add_extended_info(message_id="PropertyNotWritable",
                                            message_args=["SKU"],
                                            related_properties=["#/SKU"])
        except errors.OneViewRedfishError as e:
            self.fail("Failled to add Extened info".format(e))

        result = json.loads(redfish_error.serialize())
        self.assertEqual(redfish_error_mockup, result)