Пример #1
0
 def register_timeout():
     this = self_weakref()
     logger.info(
         "{stage_name}({op_name}): returning timeout error".format(
             stage_name=this.name, op_name=op.name))
     initial_register_op.complete(error=(exceptions.ServiceError(
         "Operation timed out before provisioning service could respond for {op_type} operation"
         .format(op_type=constant.REGISTER))))
Пример #2
0
 def query_timeout():
     this = self_weakref()
     logger.info(
         "{stage_name}({op_name}): returning timeout error".format(
             stage_name=this.name, op_name=op.name))
     query_status_op.complete(error=(exceptions.ServiceError(
         "Operation timed out before provisioning service could respond for {op_type} operation"
         .format(op_type=constant.QUERY))))
Пример #3
0
 def _process_unknown_registration_status(registration_status,
                                          original_provisioning_op,
                                          request_response_op):
     error = exceptions.ServiceError(
         "Query Status Operation encountered an invalid registration status {status} with a status code of {status_code}"
         .format(status=registration_status,
                 status_code=request_response_op.status_code))
     original_provisioning_op.complete(error=error)
def map_http_error(error, http_op):
    if error:
        return error
    elif http_op.status_code >= 300:
        translated_error = http_map_error.translate_error(http_op.status_code, http_op.reason)
        return exceptions.ServiceError(
            "HTTP operation returned: {} {}".format(http_op.status_code, translated_error)
        )
Пример #5
0
 def map_twin_error(error, twin_op):
     if error:
         return error
     elif twin_op.status_code >= 300:
         # TODO map error codes to correct exceptions
         logger.error("Error {} received from twin operation".format(twin_op.status_code))
         logger.error("response body: {}".format(twin_op.response_body))
         return exceptions.ServiceError(
             "twin operation returned status {}".format(twin_op.status_code)
         )
Пример #6
0
 def _process_failed_and_assigned_registration_status(
     error,
     operation_id,
     decoded_response,
     registration_status,
     original_provisioning_op,
     request_response_op,
 ):
     complete_registration_result = CommonProvisioningStage._form_complete_result(
         operation_id=operation_id,
         decoded_response=decoded_response,
         status=registration_status)
     original_provisioning_op.registration_result = complete_registration_result
     if registration_status == "failed":
         error = exceptions.ServiceError(
             "Query Status operation returned a failed registration status with a status code of {status_code}"
             .format(status_code=request_response_op.status_code))
     original_provisioning_op.complete(error=error)
Пример #7
0
 def _process_service_error_status_code(self, original_provisioning_op,
                                        request_response_op):
     logger.error(
         "{stage_name}({op_name}): Received error with status code {status_code} for {prov_op_name} request operation"
         .format(
             stage_name=self.name,
             op_name=request_response_op.name,
             prov_op_name=request_response_op.request_type,
             status_code=request_response_op.status_code,
         ))
     logger.error("{stage_name}({op_name}): Response body: {body}".format(
         stage_name=self.name,
         op_name=request_response_op.name,
         body=request_response_op.response_body,
     ))
     original_provisioning_op.complete(error=exceptions.ServiceError(
         "{prov_op_name} request returned a service error status code {status_code}"
         .format(
             prov_op_name=request_response_op.request_type,
             status_code=request_response_op.status_code,
         )))