| 100 | |
| 101 | |
| 102 | def validate_response(inquiry, response): |
| 103 | schema = inquiry.schema |
| 104 | |
| 105 | LOG.debug("Validating inquiry response: %s against schema: %s" % (response, schema)) |
| 106 | |
| 107 | try: |
| 108 | schema_utils.validate( |
| 109 | instance=response, |
| 110 | schema=schema, |
| 111 | cls=schema_utils.CustomValidator, |
| 112 | use_default=True, |
| 113 | allow_default_none=True, |
| 114 | ) |
| 115 | except Exception as e: |
| 116 | msg = 'Response for inquiry "%s" did not pass schema validation.' |
| 117 | LOG.exception(msg % str(inquiry.id)) |
| 118 | raise inquiry_exceptions.InvalidInquiryResponse( |
| 119 | str(inquiry.id), six.text_type(e) |
| 120 | ) |
| 121 | |
| 122 | |
| 123 | def respond(inquiry, response, requester=None): |