Exemple #1
0
   def getChildrenAreaIds(parentAreaIds):
      """Get children area Ids via parent area Ids
      """
      childAreaIds = []
      logger.debug("Get child area ids from parent area %s" % parentAreaIds)
      for parentAreaId in parentAreaIds:
         retObjs = queryCatInfo('area', {'parent': parentAreaId})
         for retObj in retObjs:
            if not getValue(retObj, 'visible'):
               logger.debug("Child area %s is not visable ,skip" % getId(retObj))
               continue
            childAreaIds.append(getId(retObj))

      return childAreaIds
Exemple #2
0
 def getMachineId(hostName):
     retObjs = queryCatInfo('machine', {'hostname': hostName},
                            apiVersion='v3.0')
     if not retObjs:
         raise Exception("No machine named as %s" % hostName)
     else:
         return getId(retObjs[0])
 def getBugId(bugzillaId):
    retObjs = queryCatInfo('bugzilla', {'number': bugzillaId})
    if not retObjs:
       logger.error("Bug PR %s hasn't added into CAT database yet", bugzillaId)
       return None
    else:
       return getId(retObjs[0])
   def queryTestrunsByObjs(testrunObjs, skipRunning=True, skipPass=False,
                           parserLog=True):
      """Return a list of testrun instances by testrun obj
      """
      trDatas = []

      for testrunObj in testrunObjs:
         trId = getId(testrunObj, 'id')
         trData = Testrun(trId, testrunObj)
         trData.initCatRawInfo()
         if skipRunning and trData.getResult() == KW_STILL_RUNNING:
            logger.warn("Skip query testrun %s info since it still running",
                        trId)
            continue
         elif skipPass and trData.getResult() == RESULT_PASS:
            logger.warn("Skip query testrun %s info since its result is PASS",
                        trId)
            continue
         elif trData.isValid():
            trDatas.append(trData)
         else:
            logger.warn('Skip %s because its RestAPI information is not entire',
                        str(trData))

      logger.info("Initializing %d testruns shared information...",
                  len(trDatas))
      Testrun.initSubDataMap()

      logger.info("Initializing %d testruns detailed information, "
                  "this operation could take some time...", len(trDatas))
      for trData in trDatas:
         trData.initReadableInfo(parserLog)

      logger.debug("Total found %d testruns" % len(trDatas))
      return trDatas
Exemple #5
0
    def getDeliverablesByBuild(buildId):
        retObjs = queryCatInfo('deliverable', {'build': buildId})

        if not retObjs:
            raise Exception("No CAT deliverable generated by CAT build %d" %
                            buildId)
        else:
            deliverableIds = [getId(retObj, 'id') for retObj in retObjs]
            return Deliverable.getFullyInitializedCatObjectList(deliverableIds)
Exemple #6
0
 def getBranchIds(branchNames):
     """Get branch Ids via branch name @branchName
   """
     branchIds = []
     for branchName in branchNames:
         retObjs = queryCatInfo('branch', {'name': branchName})
         if not retObjs:
             raise Exception("No branch named as %s" % branchName)
         else:
             for retObj in retObjs:
                 branchIds.append(getId(retObj))
     return branchIds
 def QueryEnabledWorkunitInArea(areaId):
    workunitObjs = []
    search_obj = {'enabled':'true', 'area':areaId}
    workunitDatas = queryCatInfo('workunit', search_obj, apiVersion='v3.0')
    if not workunitDatas:
       raise Exception("Cannot find any workunit in area %s" % areaId)
    for workunitData in workunitDatas:
       wuId = getId(workunitData, "id")
       workunit = Workunit(wuId)
       workunit.initCatRawInfo()
       workunitObjs.append(workunit)
    return workunitObjs
Exemple #8
0
    def getDeliverablesByBuilder(builderId, limitDay=1):
        retObjs = queryCatInfo('deliverable', {'builder': builderId},
                               orderBy='-endtime',
                               limitDay=7)

        if not retObjs:
            raise Exception(
                "No CAT deliverable generated from builder %d "
                "in the last %d days", builderId, limitDay)
        else:
            deliverableIds = [getId(retObj, 'id') for retObj in retObjs]
            return Deliverable.getFullyInitializedCatObjectList(deliverableIds)
Exemple #9
0
    def initCatRawInfo(self):
        super(Deliverable, self).initCatRawInfo()

        self._location = self._catObj['location']['name']
        self._ready = self.getValueFromCatObj('ready')
        self._result = self.getValueFromCatObj('result')
        self._deleted = self.getValueFromCatObj('deleted')
        self._builderId = self.getIdFromCatObj('builder')

        self._buildObj = self._catObj['build']
        self._buildId = getId(self._buildObj)
        self._cln = getValue(self._buildObj, 'changeset')
    def getWorkloadIds(wlNames):
        """Get workload id via workload name @wlName
      """
        wlIds = []
        for wlName in wlNames:
            retObj = queryCatInfo('workload', {'name': wlName})

            if not retObj:
                raise Exception("No workload named as %s " % wlName)
            else:
                wlIds.append(getId(retObj[0]))

        return wlIds
Exemple #11
0
 def getAreaIds(areaNames):
    """Get area Ids via area name @areaName
    """
    areaIds = []
    for areaName in areaNames:
       retObjs = queryCatInfo('area', {'name': areaName})
       if not retObjs:
          raise Exception("No area named as %s " % areaName)
       else:
          for retObj in retObjs:
             areaIds.append(getId(retObj))
 
    return areaIds
 def getAreaownerIds(areaIds, branchIds):
     """Get areaowner ids via area ids and branch ids
   """
     areaowners = []
     for areaId in areaIds:
         for branchId in branchIds:
             tmpObjs = queryCatInfo('areaowner', {
                 'area': areaId,
                 'branch': branchId
             },
                                    apiVersion='v3.0')
             for tmpObj in tmpObjs:
                 areaowners.append(getId(tmpObj))
     return areaowners
Exemple #13
0
    def __init__(self, catObjId, catObj=None):
        assert (self._objType is not None)
        assert (self._leafNode is not None)
        assert (self._subDataMap is not None)

        self._id = catObjId
        self._catObj = catObj
        if self._catObj is None:
            catData = queryCatInfo(self._objType, {'id': self._id},
                                   apiVersion=self._api)
            if not catData:
                raise Exception("%s doesn't exist in CAT" % self)
            else:
                self._catObj = catData[0]
        else:
            # If defined catObj, treat as the baseline input
            self._id = getId(self._catObj)

        self._hyperlink = getCatHyperLink(self._objType, self._id)
        self._htmlId = genHyperLink(content=self._id,
                                    hyperlink=self._hyperlink)

        self._full_initialized = False
Exemple #14
0
 def getIdFromCatObj(self, attr, objType=None, version='v2.0'):
     return getId(self._catObj, attr, objType=objType, version=version)