def get_status_to_report(status, status_code, message, snapshot_info=None): global MyPatching, backup_logger, hutil, para_parser, total_used_size, size_calculation_failed blob_report_msg = None file_report_msg = None try: if total_used_size == -1: sizeCalculation = SizeCalculation.SizeCalculation( patching=MyPatching, logger=backup_logger, para_parser=para_parser) total_used_size, size_calculation_failed = sizeCalculation.get_total_used_size( ) number_of_blobs = len(para_parser.includeLunList) maximum_possible_size = number_of_blobs * 1099511627776 if (total_used_size > maximum_possible_size): total_used_size = maximum_possible_size backup_logger.log( "Assertion Check, total size : {0} ,maximum_possible_size : {1}" .format(total_used_size, maximum_possible_size), True) if (para_parser is not None): blob_report_msg, file_report_msg = hutil.do_status_report(operation='Enable',status=status,\ status_code=str(status_code),\ message=message,\ taskId=para_parser.taskId,\ commandStartTimeUTCTicks=para_parser.commandStartTimeUTCTicks,\ snapshot_info=snapshot_info,\ total_size = total_used_size,\ failure_flag = size_calculation_failed) except Exception as e: err_msg = 'cannot get status report parameters , Exception %s, stack trace: %s' % ( str(e), traceback.format_exc()) backup_logger.log(err_msg, True, 'Warning') return blob_report_msg, file_report_msg
def status_report(status, status_code, message, snapshot_info = None): global MyPatching,backup_logger,hutil,para_parser,total_used_size,size_calculation_failed trans_report_msg = None try: if total_used_size == -1 : sizeCalculation = SizeCalculation.SizeCalculation(patching = MyPatching , logger = backup_logger) total_used_size,size_calculation_failed = sizeCalculation.get_total_used_size() number_of_blobs = len(para_parser.blobs) maximum_possible_size = number_of_blobs * 1099511627776 if(total_used_size>maximum_possible_size): total_used_size = maximum_possible_size backup_logger.log("Assertion Check, total size : {0} ,maximum_possible_size : {1}".format(total_used_size,maximum_possible_size),True) if(para_parser is not None and para_parser.statusBlobUri is not None and para_parser.statusBlobUri != ""): trans_report_msg = hutil.do_status_report(operation='Enable',status=status,\ status_code=str(status_code),\ message=message,\ taskId=para_parser.taskId,\ commandStartTimeUTCTicks=para_parser.commandStartTimeUTCTicks,\ snapshot_info=snapshot_info,\ total_size = total_used_size,\ failure_flag = size_calculation_failed) except Exception as e: err_msg='cannot write status to the status file, Exception %s, stack trace: %s' % (str(e), traceback.format_exc()) backup_logger.log(err_msg, True, 'Warning') try: if(para_parser is not None and para_parser.statusBlobUri is not None and para_parser.statusBlobUri != ""): blobWriter = BlobWriter(hutil) if(trans_report_msg is not None): blobWriter.WriteBlob(trans_report_msg,para_parser.statusBlobUri) backup_logger.log("trans status report message:",True) backup_logger.log(trans_report_msg,True) else: backup_logger.log("trans_report_msg is none",True) except Exception as e: err_msg='cannot write status to the status blob' backup_logger.log(err_msg, True, 'Warning')