def takeSnapshotFromFirstHostThenGuest(self):

        run_result = CommonVariables.success
        run_status = 'success'

        all_failed = False
        is_inconsistent = False
        unable_to_sleep = False
        blob_snapshot_info_array = None
        snap_shotter = HostSnapshotter(self.logger, self.hostIp)
        pre_snapshot_statuscode = snap_shotter.pre_snapshot(
            self.para_parser, self.taskId)

        if (pre_snapshot_statuscode == 200 or pre_snapshot_statuscode == 201):
            run_result, run_status, blob_snapshot_info_array, all_failed, unable_to_sleep, is_inconsistent = self.takeSnapshotFromOnlyHost(
            )
        else:
            run_result, run_status, blob_snapshot_info_array, all_failed, all_snapshots_failed, unable_to_sleep, is_inconsistent = self.takeSnapshotFromGuest(
            )

            if all_snapshots_failed and run_result != CommonVariables.success:
                self.extensionErrorCode = ExtensionErrorCodeHelper.ExtensionErrorCodeEnum.FailedRetryableSnapshotFailedNoNetwork
            elif run_result != CommonVariables.success:
                self.extensionErrorCode = ExtensionErrorCodeHelper.ExtensionErrorCodeEnum.FailedRetryableSnapshotFailedRestrictedNetwork

        return run_result, run_status, blob_snapshot_info_array, all_failed, unable_to_sleep, is_inconsistent
    def takeSnapshotFromFirstHostThenGuest(self):

        run_result = CommonVariables.success
        run_status = 'success'

        all_failed = False
        is_inconsistent = False
        blob_snapshot_info_array = None
        snap_shotter = HostSnapshotter(self.logger, self.hostIp)
        pre_snapshot_statuscode = snap_shotter.pre_snapshot(
            self.para_parser, self.taskId)

        if (pre_snapshot_statuscode == 200 or pre_snapshot_statuscode == 201):
            run_result, run_status, blob_snapshot_info_array, all_failed = self.takeSnapshotFromOnlyHost(
            )
            if (all_failed and run_result != CommonVariables.success):
                run_result = CommonVariables.error
                run_status = 'error'
                error_msg = 'T:S Enable failed with error in transient error from xstore'
                self.logger.log(
                    "Marking retryble error when presnapshot succeeds but dosnapshot fails through host",
                    True, 'Warning')
        else:
            run_result, run_status, blob_snapshot_info_array, all_failed, all_snapshots_failed = self.takeSnapshotFromGuest(
            )

            if all_snapshots_failed and run_result != CommonVariables.success:
                self.extensionErrorCode = ExtensionErrorCodeHelper.ExtensionErrorCodeEnum.FailedRetryableSnapshotFailedNoNetwork
            elif run_result != CommonVariables.success:
                self.extensionErrorCode = ExtensionErrorCodeHelper.ExtensionErrorCodeEnum.FailedRetryableSnapshotFailedRestrictedNetwork

        return run_result, run_status, blob_snapshot_info_array, all_failed
Пример #3
0
    def is_command_timedout(self, para_parser):
        result = False
        dateTimeNow = datetime.datetime.utcnow()
        try:
            try:
                snap_shotter = HostSnapshotter(self.logger, self.hostIp)
                pre_snapshot_statuscode, responseBody = snap_shotter.pre_snapshot(
                    self.para_parser, self.taskId)

                if (int(pre_snapshot_statuscode) == 200
                        or int(pre_snapshot_statuscode) == 201) and (
                            responseBody != None and responseBody != ""):
                    resonse = json.loads(responseBody)
                    dateTimeNow = datetime.datetime(
                        resonse['responseTime']['year'],
                        resonse['responseTime']['month'],
                        resonse['responseTime']['day'],
                        resonse['responseTime']['hour'],
                        resonse['responseTime']['minute'],
                        resonse['responseTime']['second'])
                    self.logger.log(
                        'Date and time extracted from pre-snapshot request: ' +
                        str(dateTimeNow))
            except Exception as e:
                self.logger.log(
                    'Error in getting Host time falling back to using system time. Exception %s, stack trace: %s'
                    % (str(e), traceback.format_exc()))

            if (para_parser is not None
                    and para_parser.commandStartTimeUTCTicks is not None
                    and para_parser.commandStartTimeUTCTicks != ""):
                utcTicksLong = int(para_parser.commandStartTimeUTCTicks)
                self.logger.log('utcTicks in long format' + str(utcTicksLong))
                commandStartTime = self.convert_time(utcTicksLong)
                self.logger.log('command start time is ' +
                                str(commandStartTime) + " and utcNow is " +
                                str(dateTimeNow))
                timespan = dateTimeNow - commandStartTime
                MAX_TIMESPAN = 140 * 60  # in seconds
                total_span_in_seconds = self.timedelta_total_seconds(timespan)
                self.logger.log('timespan: ' + str(timespan) +
                                ', total_span_in_seconds: ' +
                                str(total_span_in_seconds) +
                                ', MAX_TIMESPAN: ' + str(MAX_TIMESPAN))

                if total_span_in_seconds > MAX_TIMESPAN:
                    self.logger.log(
                        'CRP timeout limit has reached, should abort.')
                    result = True
        except Exception as e:
            self.logger.log(
                'T:S is_command_timedout : Exception %s, stack trace: %s' %
                (str(e), traceback.format_exc()))

        return result
    def takeSnapshotFromFirstHostThenGuest(self):

        run_result = CommonVariables.success
        run_status = 'success'

        all_failed= False
        is_inconsistent =  False
        blob_snapshot_info_array = None
        snap_shotter = HostSnapshotter(self.logger, self.hostIp)
        pre_snapshot_statuscode = snap_shotter.pre_snapshot(self.para_parser, self.taskId)

        if(pre_snapshot_statuscode == 200 or pre_snapshot_statuscode == 201):
            run_result, run_status, blob_snapshot_info_array, all_failed = self.takeSnapshotFromOnlyHost()
        else:
            run_result, run_status, blob_snapshot_info_array, all_failed, all_snapshots_failed  = self.takeSnapshotFromGuest()

            if all_snapshots_failed and run_result != CommonVariables.success:
                self.extensionErrorCode = ExtensionErrorCodeHelper.ExtensionErrorCodeEnum.FailedRetryableSnapshotFailedNoNetwork
            elif run_result != CommonVariables.success :
                self.extensionErrorCode = ExtensionErrorCodeHelper.ExtensionErrorCodeEnum.FailedRetryableSnapshotFailedRestrictedNetwork

        return run_result, run_status, blob_snapshot_info_array, all_failed