def patchHelpTicketInCAT(ticketIdInCat, testrunID): helpnows = {} addValue(helpnows, 'testrun_ids', [str(testrunID)], convertToStr=False) return patchResultToCat('helpnow', ticketIdInCat, helpnows, apiVersion='v3.0')
def modifyWorkunitIteration(wuId, iteration): """Set workunit iteration as @iteration """ logger.info("Modify workunit %s iteration as %s" % (wuId, iteration)) wuObj = {} addValue(wuObj, 'run_every_nth_iteration', iteration, convertToStr=False) return patchResultToCat('workunit', wuId, wuObj, apiVersion='v3.0')
def modifyWorkunitParallelStatus(wuId, parallel): """@enable: True, parallel workunit. False, sequence it """ logger.info("Modify workunit %s parallel status as %s", wuId, parallel) wuObj = {} addValue(wuObj, 'parallel', parallel, convertToStr=False) return patchResultToCat('workunit', wuId, wuObj, apiVersion='v3.0')
def modifyWorkunitEnableStatus(wuId, enable): """@enable: True, enable workunit. False, disable it """ logger.info("Modify workunit %s enable status as %s", wuId, enable) wuObj = {} addValue(wuObj, 'enabled', enable, convertToStr=False) return patchResultToCat('workunit', wuId, wuObj, apiVersion='v3.0')
def triageBugIdToTestruns(testrunIds, bugId=None, bugIdInCat=None): if not bugId and not bugIdInCat: raise Exception("Please provide at least one argument from bugId, bugIdInCat") # TODO: use api v3.0 once it's more stable apiVersion = 'v2.0' testrunIds = [str(testrunId) for testrunId in testrunIds] if bugIdInCat: logger.info("Triaging bug %s (id in cat DB) to testruns %s...", bugIdInCat, testrunIds) bugObj = {} addValue(bugObj, 'testruns', testrunIds, convertToStr=False) return patchResultToCat('bugzilla', bugIdInCat, bugObj, apiVersion=apiVersion) else: logger.info("Triaging PR%s to testruns %s...", bugId, testrunIds) bugId_in_cat = Bug.getBugId(bugId) if bugId_in_cat: bugObj = {} addValue(bugObj, 'testruns', testrunIds, convertToStr=False) return patchResultToCat('bugzilla', bugId_in_cat, bugObj, apiVersion=apiVersion) else: bugObj = {} addValue(bugObj, 'testruns', testrunIds, convertToStr=False) addValue(bugObj, 'number', bugId, True) return postResultToCat('bugzilla', bugObj, apiVersion=apiVersion)
def addAreaowner(areaId, branchId, owners, manager): logger.info("Add areaowner with info: %s" % vars()) owners = '%s' % ','.join(owners) areaOwnerObj = {} addId(areaOwnerObj, 'area', areaId) addId(areaOwnerObj, 'branch', branchId) addValue(areaOwnerObj, 'owners', owners) addValue(areaOwnerObj, 'bug_shepherds', owners) addValue(areaOwnerObj, 'triage_owners', owners) addValue(areaOwnerObj, 'cost_center_manager', manager) return postResultToCat('areaowner', areaOwnerObj, 'v3.0')
def modifyAreaowner(areaownerId, owners=None, manager=None): logger.info("Modify areaowner with info: %s" % vars()) areaOwnerObj = {} if owners is not None: owners = '%s' % ','.join(owners) addValue(areaOwnerObj, 'owners', owners) addValue(areaOwnerObj, 'bug_shepherds', owners) addValue(areaOwnerObj, 'triage_owners', owners) if manager is not None: addValue(areaOwnerObj, 'cost_center_manager', manager) return patchResultToCat('areaowner', areaownerId, areaOwnerObj, 'v3.0')
def addWorkunit(testerId, builderId, areaId, wlId): """Add workunit into tester operation """ logger.debug("Add workunit with info: %s" % vars()) wuObj = {} addId(wuObj, 'tester', testerId) addId(wuObj, 'workload', wlId) addId(wuObj, 'area', areaId) addValue(wuObj, 'host_platform', 'visor') wuObj['builddefs'] = [] # Workunits can be associated with multiple builders if not isinstance(builderId, list): builderIds = [builderId] else: builderIds = builderId for builderId in builderIds: buildObj = {} addId(buildObj, 'builder', builderId) addValue(buildObj, 'deployment', '-') addValue(buildObj, 'recommended', None, convertToStr=False, ignoreEmpty=False) wuObj['builddefs'].append(buildObj) return postResultToCat('workunit', wuObj)
def modifyWorkload(wlId, name=None, executable=None, launchhost=None, timeout=None, needsreboot=None, skipboot=None): """Modify workload (workload id = @wlId) info """ logger.debug("Modifying workload: %s" % vars()) wlObj = {} if name: addValue(wlObj, 'name', name) if executable: addValue(wlObj, 'executable', executable) if launchhost: addValue(wlObj, 'launch_host', launchhost) if timeout: addValue(wlObj, 'timeout', timeout) if needsreboot: addValue(wlObj, 'needs_reboot', needsreboot, convertToStr=False) if skipboot: addValue(wlObj, 'skip_boot', skipboot, convertToStr=False) return patchResultToCat('workload', wlId, wlObj)
def addWorkload(name, executable, launchhost, timeout, needsreboot, skipboot): """Add workload into CAT """ logger.debug("Adding workload: %s" % vars()) wlObj = {} addValue(wlObj, 'name', name) addValue(wlObj, 'executable', executable) addValue(wlObj, 'launch_host', launchhost) addValue(wlObj, 'timeout', timeout) addValue(wlObj, 'needs_reboot', needsreboot, convertToStr=False) addValue(wlObj, 'skip_boot', skipboot, convertToStr=False) addId(wlObj, 'site', 1) return postResultToCat('workload', wlObj)