def snapshotall()

in VMBackup/main/hostsnapshotter.py [0:0]


    def snapshotall(self, paras, freezer, g_fsfreeze_on, taskId):
        result = None
        blob_snapshot_info_array = []
        all_failed = True
        is_inconsistent = False
        unable_to_sleep = False
        meta_data = paras.backup_metadata
        if(self.snapshoturi is None):
            self.logger.log("Failed to do the snapshot because snapshoturi is none",False,'Error')
            all_failed = True
        try:
            snapshoturi_obj = urlparser.urlparse(self.snapshoturi)
            if(snapshoturi_obj is None or snapshoturi_obj.hostname is None):
                self.logger.log("Failed to parse the snapshoturi",False,'Error')
                all_failed = True
            else:
                diskIds = []
                body_content = ''
                headers = {}
                headers['Backup'] = 'true'
                headers['Content-type'] = 'application/json'
                settings = []
                if (paras.includeLunList != None and paras.includeLunList.count != 0):
                    diskIds = paras.includeLunList
                if(paras.wellKnownSettingFlags != None):
                    for flag in paras.wellKnownSettingFlags:
                        temp_dict = {}
                        temp_dict[CommonVariables.key] = flag
                        temp_dict[CommonVariables.value] = paras.wellKnownSettingFlags[flag]
                        settings.append(temp_dict)
                hostDoSnapshotRequestBodyObj = HostSnapshotObjects.HostDoSnapshotRequestBody(taskId, diskIds, settings, paras.snapshotTaskToken, meta_data)
                body_content = json.dumps(hostDoSnapshotRequestBodyObj, cls = HandlerUtil.ComplexEncoder)
                self.logger.log('Headers : ' + str(headers))
                self.logger.log('Host Request body : ' + str(body_content))
                http_util = HttpUtil(self.logger)
                self.logger.log("start calling the snapshot rest api")
                # initiate http call for blob-snapshot and get http response
                self.logger.log('****** 5. Snaphotting (Host) Started')
                result, httpResp, errMsg,responseBody = http_util.HttpCallGetResponse('POST', snapshoturi_obj, body_content, headers = headers, responseBodyRequired = True, isHostCall = True)
                self.logger.log('****** 6. Snaphotting (Host) Completed')
                self.logger.log("dosnapshot responseBody: " + responseBody)
                #performing thaw
                if g_fsfreeze_on :
                    time_before_thaw = datetime.datetime.now()
                    thaw_result, unable_to_sleep = freezer.thaw_safe()
                    time_after_thaw = datetime.datetime.now()
                    HandlerUtil.HandlerUtility.add_to_telemetery_data("ThawTime", str(time_after_thaw-time_before_thaw))
                    self.logger.log('T:S thaw result ' + str(thaw_result))
                    if(thaw_result is not None and len(thaw_result.errors) > 0):
                        is_inconsistent = True
                
                # Http response check(After thawing)
                if(httpResp != None):
                    HandlerUtil.HandlerUtility.add_to_telemetery_data(CommonVariables.hostStatusCodeDoSnapshot, str(httpResp.status))
                    if(int(httpResp.status) == 200 or int(httpResp.status) == 201) and (responseBody == None or responseBody == "") :
                        self.logger.log("DoSnapshot: responseBody is empty but http status code is success")
                        HandlerUtil.HandlerUtility.add_to_telemetery_data(CommonVariables.hostStatusCodeDoSnapshot, str(557))
                        all_failed = True
                    elif(int(httpResp.status) == 200 or int(httpResp.status) == 201):
                        blob_snapshot_info_array, all_failed = self.get_snapshot_info(responseBody)
                    if(httpResp.status == 500 and not responseBody.startswith("{ \"error\"")):
                        HandlerUtil.HandlerUtility.add_to_telemetery_data(CommonVariables.hostStatusCodeDoSnapshot, str(556))
                        all_failed = True
                else:
                    # HttpCall failed
                    HandlerUtil.HandlerUtility.add_to_telemetery_data(CommonVariables.hostStatusCodeDoSnapshot, str(555))
                    self.logger.log("presnapshot Hitting wrong WireServer IP")
        except Exception as e:
            errorMsg = "Failed to do the snapshot in host with error: %s, stack trace: %s" % (str(e), traceback.format_exc())
            self.logger.log(errorMsg, False, 'Error')
            HandlerUtil.HandlerUtility.add_to_telemetery_data(CommonVariables.hostStatusCodeDoSnapshot, str(558))
            all_failed = True
        return blob_snapshot_info_array, all_failed, is_inconsistent, unable_to_sleep