コード例 #1
0
 def do_status_report(self, operation, status, status_code, message):
     self.log("{0},{1},{2},{3}".format(operation, status, status_code,
                                       message))
     sub_stat = []
     stat_rept = []
     if self.get_public_settings(
     )[CommonVariables.
       vmType] == CommonVariables.VmTypeV2 and CommonVariables.isTerminalStatus(
           status):
         stat_rept = self.do_status_json(operation, status, sub_stat,
                                         status_code, message)
         time_delta = datetime.datetime.utcnow() - datetime.datetime(
             1970, 1, 1)
         time_span = self.timedelta_total_seconds(time_delta) * 1000
         date_place_holder = 'e2794170-c93d-4178-a8da-9bc7fd91ecc0'
         stat_rept[0]["timestampUTC"] = date_place_holder
         stat_rept = json.dumps(stat_rept)
         date_string = r'\/Date(' + str((int)(time_span)) + r')\/'
         stat_rept = stat_rept.replace(date_place_holder, date_string)
         status_code = '1'
         status = CommonVariables.status_success
         sub_stat = self.substat_new_entry(sub_stat, '0', stat_rept,
                                           'success', None)
     stat_rept = self.do_status_json(operation, status, sub_stat,
                                     status_code, message)
     stat_rept = json.dumps(stat_rept)
     # rename all other status files, or the WALA would report the wrong
     # status file.
     # because the wala choose the status file with the highest sequence
     # number to report.
     if self._context._status_file:
         with open(self._context._status_file, 'w+') as f:
             f.write(stat_rept)
コード例 #2
0
    def do_status_report(self,
                         operation,
                         status,
                         status_code,
                         message,
                         taskId=None,
                         commandStartTimeUTCTicks=None,
                         snapshot_info=None):
        self.log("{0},{1},{2},{3}".format(operation, status, status_code,
                                          message))
        sub_stat = []
        stat_rept = []
        self.add_telemetry_data()

        vm_health_obj = Status.VmHealthInfoObj(
            ExtensionErrorCodeHelper.ExtensionErrorCodeHelper.
            ExtensionErrorCodeDict[self.ExtErrorCode], int(status_code))
        stat_rept = self.do_status_json(operation, status, sub_stat,
                                        status_code, message,
                                        HandlerUtility.telemetry_data, taskId,
                                        commandStartTimeUTCTicks,
                                        snapshot_info, vm_health_obj)
        time_delta = datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)
        time_span = self.timedelta_total_seconds(time_delta) * 1000
        date_place_holder = 'e2794170-c93d-4178-a8da-9bc7fd91ecc0'
        stat_rept.timestampUTC = date_place_holder
        date_string = r'\/Date(' + str((int)(time_span)) + r')\/'
        stat_rept = "[" + json.dumps(stat_rept,
                                     cls=Status.ComplexEncoder) + "]"
        stat_rept = stat_rept.replace(date_place_holder, date_string)

        # Add Status as sub-status for Status to be written on Status-File
        sub_stat = self.substat_new_entry(sub_stat, '0', stat_rept, 'success',
                                          None)
        if self.get_public_settings(
        )[CommonVariables.
          vmType] == CommonVariables.VmTypeV2 and CommonVariables.isTerminalStatus(
              status):
            status = CommonVariables.status_success
        stat_rept_file = self.do_status_json(operation, status, sub_stat,
                                             status_code, message, None,
                                             taskId, commandStartTimeUTCTicks,
                                             None, None)
        stat_rept_file = "[" + json.dumps(stat_rept_file,
                                          cls=Status.ComplexEncoder) + "]"

        # rename all other status files, or the WALA would report the wrong
        # status file.
        # because the wala choose the status file with the highest sequence
        # number to report.
        if self._context._status_file:
            with open(self._context._status_file, 'w+') as f:
                f.write(stat_rept_file)

        return stat_rept
コード例 #3
0
    def do_status_report(self,
                         operation,
                         status,
                         status_code,
                         message,
                         taskId=None,
                         commandStartTimeUTCTicks=None,
                         snapshot_info=None,
                         total_size=0,
                         failure_flag=True):
        self.log("{0},{1},{2},{3}".format(operation, status, status_code,
                                          message))
        sub_stat = []
        stat_rept = []
        self.add_telemetry_data()
        snapshotTelemetry = ""

        if CommonVariables.snapshotCreator in HandlerUtility.telemetry_data.keys(
        ):
            snapshotTelemetry = "{0}{1}={2}, ".format(
                snapshotTelemetry, CommonVariables.snapshotCreator,
                HandlerUtility.telemetry_data[CommonVariables.snapshotCreator])
        if CommonVariables.hostStatusCodePreSnapshot in HandlerUtility.telemetry_data.keys(
        ):
            snapshotTelemetry = "{0}{1}={2}, ".format(
                snapshotTelemetry, CommonVariables.hostStatusCodePreSnapshot,
                HandlerUtility.telemetry_data[
                    CommonVariables.hostStatusCodePreSnapshot])
        if CommonVariables.hostStatusCodeDoSnapshot in HandlerUtility.telemetry_data.keys(
        ):
            snapshotTelemetry = "{0}{1}={2}, ".format(
                snapshotTelemetry, CommonVariables.hostStatusCodeDoSnapshot,
                HandlerUtility.telemetry_data[
                    CommonVariables.hostStatusCodeDoSnapshot])

        if CommonVariables.statusBlobUploadError in HandlerUtility.telemetry_data.keys(
        ):
            message = "{0} {1}={2}, ".format(
                message, CommonVariables.statusBlobUploadError,
                HandlerUtility.telemetry_data[
                    CommonVariables.statusBlobUploadError])
        message = message + snapshotTelemetry

        vm_health_obj = Utils.Status.VmHealthInfoObj(
            ExtensionErrorCodeHelper.ExtensionErrorCodeHelper.
            ExtensionErrorCodeDict[self.ExtErrorCode], int(self.ExtErrorCode))

        consistencyTypeStr = CommonVariables.consistency_crashConsistent
        if (self.SnapshotConsistency !=
                Utils.Status.SnapshotConsistencyType.crashConsistent):
            if (status_code == CommonVariables.success_appconsistent):
                self.SnapshotConsistency = Utils.Status.SnapshotConsistencyType.applicationConsistent
                consistencyTypeStr = CommonVariables.consistency_applicationConsistent
            elif (status_code == CommonVariables.success):
                self.SnapshotConsistency = Utils.Status.SnapshotConsistencyType.fileSystemConsistent
                consistencyTypeStr = CommonVariables.consistency_fileSystemConsistent
            else:
                self.SnapshotConsistency = Utils.Status.SnapshotConsistencyType.none
                consistencyTypeStr = CommonVariables.consistency_none
        HandlerUtility.add_to_telemetery_data("consistencyType",
                                              consistencyTypeStr)

        extensionResponseObj = Utils.Status.ExtensionResponse(
            message, self.SnapshotConsistency, "")
        message = str(json.dumps(extensionResponseObj, cls=ComplexEncoder))

        self.convert_telemetery_data_to_bcm_serializable_format()
        stat_rept = self.do_status_json(
            operation, status, sub_stat, status_code, message,
            HandlerUtility.serializable_telemetry_data, taskId,
            commandStartTimeUTCTicks, snapshot_info, vm_health_obj, total_size,
            failure_flag)
        time_delta = datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)
        time_span = self.timedelta_total_seconds(time_delta) * 1000
        date_place_holder = 'e2794170-c93d-4178-a8da-9bc7fd91ecc0'
        stat_rept.timestampUTC = date_place_holder
        date_string = r'\/Date(' + str((int)(time_span)) + r')\/'
        stat_rept = "[" + json.dumps(stat_rept, cls=ComplexEncoder) + "]"
        stat_rept = stat_rept.replace(date_place_holder, date_string)

        # Add Status as sub-status for Status to be written on Status-File
        sub_stat = self.substat_new_entry(sub_stat, '0', stat_rept, 'success',
                                          None)
        if self.get_public_settings()[CommonVariables.vmType].lower(
        ) == CommonVariables.VmTypeV2.lower(
        ) and CommonVariables.isTerminalStatus(status):
            status = CommonVariables.status_success
        stat_rept_file = self.do_status_json(operation, status, sub_stat,
                                             status_code, message, None,
                                             taskId, commandStartTimeUTCTicks,
                                             None, None, total_size,
                                             failure_flag)
        stat_rept_file = "[" + json.dumps(stat_rept_file,
                                          cls=ComplexEncoder) + "]"

        # rename all other status files, or the WALA would report the wrong
        # status file.
        # because the wala choose the status file with the highest sequence
        # number to report.
        return stat_rept, stat_rept_file
コード例 #4
0
    def do_status_report(self, operation, status, status_code, message, taskId = None, commandStartTimeUTCTicks = None, snapshot_info = None,total_size = 0,failure_flag = True ):
        self.log("{0},{1},{2},{3}".format(operation, status, status_code, message))
        sub_stat = []
        stat_rept = []
        self.add_telemetry_data()

        vm_health_obj = Utils.Status.VmHealthInfoObj(ExtensionErrorCodeHelper.ExtensionErrorCodeHelper.ExtensionErrorCodeDict[self.ExtErrorCode], int(self.ExtErrorCode))
        self.convert_telemetery_data_to_bcm_serializable_format()
        stat_rept = self.do_status_json(operation, status, sub_stat, status_code, message, HandlerUtility.serializable_telemetry_data, taskId, commandStartTimeUTCTicks, snapshot_info, vm_health_obj, total_size,failure_flag)
        time_delta = datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)
        time_span = self.timedelta_total_seconds(time_delta) * 1000
        date_place_holder = 'e2794170-c93d-4178-a8da-9bc7fd91ecc0'
        stat_rept.timestampUTC = date_place_holder
        date_string = r'\/Date(' + str((int)(time_span)) + r')\/'
        stat_rept = "[" + json.dumps(stat_rept, cls = ComplexEncoder) + "]"
        stat_rept = stat_rept.replace(date_place_holder,date_string)
        
        # Add Status as sub-status for Status to be written on Status-File
        sub_stat = self.substat_new_entry(sub_stat,'0',stat_rept,'success',None)
        if self.get_public_settings()[CommonVariables.vmType].lower() == CommonVariables.VmTypeV2.lower() and CommonVariables.isTerminalStatus(status) :
            status = CommonVariables.status_success
        stat_rept_file = self.do_status_json(operation, status, sub_stat, status_code, message, None, taskId, commandStartTimeUTCTicks, None, None,total_size,failure_flag)
        stat_rept_file =  "[" + json.dumps(stat_rept_file, cls = ComplexEncoder) + "]"

        # rename all other status files, or the WALA would report the wrong
        # status file.
        # because the wala choose the status file with the highest sequence
        # number to report.
        return stat_rept, stat_rept_file
コード例 #5
0
 def do_status_report(self, operation, status, status_code, message):
     self.log("{0},{1},{2},{3}".format(operation, status, status_code, message))
     sub_stat = []
     stat_rept = []
     if self.get_public_settings()[CommonVariables.vmType] == CommonVariables.VmTypeV2 and CommonVariables.isTerminalStatus(status) :
         stat_rept = self.do_status_json(operation, status, sub_stat, status_code, message)
         time_delta = datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)
         time_span = self.timedelta_total_seconds(time_delta) * 1000
         date_place_holder = 'e2794170-c93d-4178-a8da-9bc7fd91ecc0'
         stat_rept[0]["timestampUTC"] = date_place_holder
         stat_rept = json.dumps(stat_rept)
         date_string = r'\/Date(' + str((int)(time_span)) + r')\/'
         stat_rept = stat_rept.replace(date_place_holder,date_string)
         status_code = '1'
         status = CommonVariables.status_success
         sub_stat = self.substat_new_entry(sub_stat,'0',stat_rept,'success',None)
     stat_rept = self.do_status_json(operation, status, sub_stat, status_code, message)
     stat_rept = json.dumps(stat_rept)
     # rename all other status files, or the WALA would report the wrong
     # status file.
     # because the wala choose the status file with the highest sequence
     # number to report.
     if self._context._status_file:
         with open(self._context._status_file,'w+') as f:
             f.write(stat_rept)