Ejemplo n.º 1
0
 def __handleReqiredBuild__(self, lines, kidsBuild):
   line1, line2 = lines
   fields = line2.split('^')
   if len(fields) > 0:
     kidsBuild.addDependencyBuild(fields)
   else:
     logger.warn("no require build information for [%s]" % lines)
Ejemplo n.º 2
0
 def installCompleted(self, connection, **kargs):
     extraInfo = connection.before
     logger.debug(extraInfo)
     if re.search("No link to PACKAGE file", extraInfo):
         self._updatePackageLink = True
         logger.warn("You might have to update KIDS build %s to link"
                     " to Package file" % (self._kidsInstallName))
Ejemplo n.º 3
0
 def parseAssociatedPart(self, infoString, patchInfo):
     pos = infoString.find("<<= must be installed BEFORE")
     if pos >= 0:
         installName = convertToInstallName(infoString[3:pos].strip())
         patchInfo.depKIDSBuild.add(installName)
     else:
         logger.warn(infoString)
Ejemplo n.º 4
0
 def parseKIDSBuild(self, kidsPatch):
   assert os.path.exists(kidsPatch)
   logger.info("Parsing KIDS file %s" % kidsPatch)
   lines = None
   with open(kidsPatch, 'r') as input:
     curLine = input.readline()
     lineNum = 0
     while len(curLine) > 0:
       lineNum += 1
       """ read one more line """
       lines = (curLine.rstrip('\r\n'), input.readline().rstrip('\r\n'))
       if lineNum == 1:
         self.__parseKIDSHeader__(lines)
       else:
         section, parser = self.__isSectionLine__(curLine)
         if section == None: # could not find a valid section
           logger.warn("Can not parse %s" % lines[0])
           self.__resetCurrentSection__(section, parser, lines)
         else: # find a section
           if section != self._curSection:
             self.__resetCurrentSection__(section, parser, lines)
           elif self._curParser:
             self._curParser.parseLines(section, lines,
                                        kidsBuild=self._curKidsBuild)
       # goto the next line #
       lineNum += 1
       curLine = input.readline()
     else: # at end of file
       self.__resetCurrentSection__(None, None, lines)
 def __parseAllKIDSInfoFilesList__(self):
   kidsParser = KIDSPatchInfoParser()
   for kidsInfoFile in self._kidsInfoFileList:
     patchInfo = kidsParser.parseKIDSInfoFile(kidsInfoFile)
     if not patchInfo:
       logger.warn("invalid kids info file %s" % kidsInfoFile)
       self._invalidInfoFileSet.add(kidsInfoFile)
       continue
     """ only add to list for info that is related to a KIDS patch"""
     installName = patchInfo.installName
     if installName not in self._kidsInstallNameDict:
       logger.warn("no KIDS file related to %s" % patchInfo)
       if installName in self._missKidsBuildDict:
         logger.warn("duplicated kids install name")
         if kidsInfoFile != self._missKidsBuildDict[installName].kidsInfoPath:
           logger.warn("duplicated kids info file name %s" % kidsInfoFile)
         continue
       self._missKidsBuildDict[installName] = patchInfo
       continue
     patchInfo.kidsFilePath = self._kidsInstallNameDict[installName]
     assert patchInfo.kidsFilePath
     """ update PatchInfo kidsSha1 and kidsSha1Path """
     if installName in self._kidsInstallNameSha1Dict:
       sha1Path = self._kidsInstallNameSha1Dict[installName]
       patchInfo.kidsSha1Path = sha1Path
       patchInfo.kidsSha1 = readSha1SumFromSha1File(sha1Path)
     if installName in self._patchInfoDict:
       logger.warn("duplicated installName %s, %s, %s" %
                    (installName, self._patchInfoDict[installName],
                    kidsInfoFile))
     self._patchInfoDict[installName] = patchInfo
Ejemplo n.º 6
0
def backupCacheDataByGitHash(instanceName, origDataPath, backupDir,
                             gitReposDir, gitReposBranch, useSudo=False):
  if not os.path.exists(origDataPath):
    logger.error("%s does not exist" % origDataPath)
    return False
  if not os.path.exists(gitReposDir):
    logger.error("%s does not exist" % gitReposDir)
    return False
  if not os.path.exists(backupDir):
    logger.error("%s does not exists"  % backupDir)
    return False
  if isInstanceRunning(instanceName):
    logger.info("stop Cache instance %s" % instanceName)
    if not stopCache(instanceName, useSudo=useSudo):
      logger.info("force down Cache instance %s" % instanceName)
      forceDownCache(instanceName, useSudo=useSudo)
  if isInstanceRunning(instanceName):
    logger.error("Can not stop cache instance %s" % instanceName)
    return False
  from GitUtils import getGitRepoRevisionHash
  backupHash = getGitRepoRevisionHash(gitReposBranch, gitReposDir)
  destFile = os.path.join(backupDir, getCacheBackupNameByHash(backupHash))
  if not os.path.exists(destFile):
    logger.info("Creating tar file for %s" % origDataPath)
    createBZIP2Tarball(origDataPath, destFile)
  else:
    logger.warn("%s already exists" % destFile)
  return True
Ejemplo n.º 7
0
 def parseKIDSBuild(self, kidsBuild):
     assert os.path.exists(kidsBuild)
     logger.info("Parsing KIDS file %s" % kidsBuild)
     lines = None
     with open(kidsBuild, 'r') as input:
         curLine = input.readline()
         lineNum = 0
         while len(curLine) > 0:
             lineNum += 1
             """ read one more line """
             lines = (curLine.rstrip('\r\n'),
                      input.readline().rstrip('\r\n'))
             if lineNum == 1:
                 self.__parseKIDSHeader__(lines)
             elif self._end:  # should not be any more lines after end section
                 pass
             else:
                 section, parser = self.__isSectionLine__(curLine)
                 if section == None:  # could not find a valid section
                     logger.warn("Cannot parse %s" % lines[0])
                     self.__resetCurrentSection__(section, parser, lines)
                 else:  # find a section
                     if section != self._curSection:
                         self.__resetCurrentSection__(
                             section, parser, lines)
                     elif self._curParser:
                         self._curParser.parseLines(
                             section, lines, kidsBuild=self._curKidsBuild)
             # goto the next line #
             lineNum += 1
             curLine = input.readline()
         else:  # at end of file
             self.__resetCurrentSection__(None, None, lines)
Ejemplo n.º 8
0
 def __handleReqiredBuild__(self, lines, kidsBuild):
     line1, line2 = lines
     fields = line2.split('^')
     if len(fields) > 0:
         kidsBuild.addDependencyBuild(fields)
     else:
         logger.warn("no require build information for [%s]" % lines)
Ejemplo n.º 9
0
def backupCacheDataByGitHash(instanceName,
                             origDataPath,
                             backupDir,
                             gitReposDir,
                             gitReposBranch,
                             useSudo=False):
    if not os.path.exists(origDataPath):
        logger.error("%s does not exist" % origDataPath)
        return False
    if not os.path.exists(gitReposDir):
        logger.error("%s does not exist" % gitReposDir)
        return False
    if not os.path.exists(backupDir):
        logger.error("%s does not exists" % backupDir)
        return False
    if isInstanceRunning(instanceName):
        logger.info("stop Cache instance %s" % instanceName)
        if not stopCache(instanceName, useSudo=useSudo):
            logger.info("force down Cache instance %s" % instanceName)
            forceDownCache(instanceName, useSudo=useSudo)
    if isInstanceRunning(instanceName):
        logger.error("Can not stop cache instance %s" % instanceName)
        return False
    from GitUtils import getGitRepoRevisionHash
    if gitReposBranch is None:
        gitReposBranch = "HEAD"
    backupHash = getGitRepoRevisionHash(gitReposBranch, gitReposDir)
    destFile = os.path.join(backupDir, getCacheBackupNameByHash(backupHash))
    if not os.path.exists(destFile):
        logger.info("Creating tar file for %s" % origDataPath)
        createBZIP2Tarball(origDataPath, destFile)
    else:
        logger.warn("%s already exists" % destFile)
    return True
Ejemplo n.º 10
0
 def parseAssociatedPart(self, infoString, patchInfo):
   pos = infoString.find("<<= must be installed BEFORE")
   if pos >=0:
     installName = convertToInstallName(infoString[3:pos].strip())
     patchInfo.depKIDSBuild.add(installName)
   else:
     logger.warn(infoString)
Ejemplo n.º 11
0
 def __isPatchReadyToInstall__(self, patchInfo, patchList = None):
   packageName = patchInfo.package
   ver = patchInfo.version
   patchHist = self._vistaPatchInfo.getPackagePatchHistByName(packageName, ver)
   if not patchHist or not patchHist.hasPatchHistory():
     logger.info("no patch hist for %s, ver: %s" % (packageName, ver))
     return True # if no such an package or hist info, just return True
   """ check patch sequence no to see if it is out of order """
   if patchInfo.seqNo:
     seqNo = patchHist.getLatestSeqNo()
     if patchInfo.seqNo < seqNo:
       logger.error("SeqNo out of order, %s less than latest one %s" %
                     (patchInfo.seqNo), seqNo)
       return False
   # check all the dependencies
   for item in patchInfo.depKIDSPatch:
     if patchList and item in self._patchSet: # we are going to install the dep patch
       logger.info("We are going to install the patch %s" % item)
       """ make sure installation is in the right order """
       itemIndex = self.indexInPatchList(item, patchList)
       patchIndex = self.indexInPatchList(patchInfo.installName, patchList)
       if itemIndex >= patchIndex:
         logger.warn("%s is out of order with %s" % (item, patchInfo))
         return False
       else:
         continue
     (namespace,ver,patch) = extractInfoFromInstallName(item)
     if self._vistaPatchInfo.hasPatchInstalled(item, namespace, ver, patch):
       logger.debug("%s is arelady installed" % item)
       continue
     else:
       logger.error("dep %s is not installed for %s %s" %
                   (item, patchInfo.installName, patchInfo.kidsFilePath))
       return False
   return True
Ejemplo n.º 12
0
  def __parseAllKIDSBuildFilesList__(self):
    kidsParser = KIDSPatchInfoParser()
    for basename in self._kidsBuildFileDict.iterkeys():
      kidsFile, sha1Path = self._kidsBuildFileDict[basename]
      if kidsFile == None:
        logger.error("No KIDS file available for name %s" % basename)
      installNameList,seqNo = kidsParser.getKIDSBuildInstallNameSeqNo(kidsFile)
      if len(installNameList) > 1:
        if not self._multiBuildDict.get(kidsFile):
          self._multiBuildDict[kidsFile] = installNameList
        else:
          assert self._multiBuildDict[kidsFile] == installNameList
      elif seqNo:
        if installNameList[0] not in self._installNameSeqMap:
          self._installNameSeqMap[installNameList[0]] = seqNo
        else:
          logger.error("Duplicated KIDS build file %s" % kidsFile)
      for installName in installNameList:
        if installName in self._kidsInstallNameDict:
          logger.warn("%s is already in the dict %s" % (installName, kidsFile))
        logger.debug("Added installName %s, file %s" % (installName, kidsFile))
        self._kidsInstallNameDict[installName] = os.path.normpath(kidsFile)
        """ handle KIDS sha1 file Path """
        if sha1Path:
          if installName in self._kidsInstallNameSha1Dict:
            logger.warn("%s is already in the dict %s" % (installName, sha1Path))
          self._kidsInstallNameSha1Dict[installName] = sha1Path

    logger.debug("%s" % sorted(self._kidsInstallNameDict.keys()))
    logger.info("Total # of install name %d" % len(self._kidsInstallNameDict))
Ejemplo n.º 13
0
 def installCompleted(self, connection, **kargs):
   extraInfo = connection.before
   logger.debug(extraInfo)
   if re.search("No link to PACKAGE file", extraInfo):
     self._updatePackageLink = True
     logger.warn("You might have to update KIDS build %s to link"
                 " to Package file" %
                 (self._kidsInstallName))
Ejemplo n.º 14
0
 def extraFixWork(self, vistATestClient):
   # use KIDS entry point to manually create package link for install
   if self._updatePackageLink:
     logger.warn("Attempting to manually creating the package link for: %s" %
           (self._kidsInstallName))
     connection = vistATestClient.getConnection()
     # Luckily, the command just takes the patch information in order, ie "SD", "5.3", "701"
     if "*" in self._kidsInstallName:
       connection.write("W $$PKGPAT^XPDIP($$FIND1^DIC(9.4,,\"QXM\",\"%s\"),%s,\"%s^\"_$$NOW^XLFDT_\"^1\")" % tuple(self._kidsInstallName.split("*")))
       connection.expect(vistATestClient._prompt, 30)
Ejemplo n.º 15
0
 def __isPatchReadyToInstall__(self, patchInfo, patchList=None):
     packageName = patchInfo.package
     ver = patchInfo.version
     patchHist = self._vistaPatchInfo.getPackagePatchHistByName(
         packageName, ver)
     if not patchHist or not patchHist.hasPatchHistory():
         logger.info("no patch hist for %s, ver: %s" % (packageName, ver))
         return True  # if no such an package or hist info, just return True
     """ check patch sequence no to see if it is out of order """
     if patchInfo.seqNo:
         seqNo = patchHist.getLatestSeqNo()
         if patchInfo.seqNo < seqNo:
             logger.error(
                 "SeqNo out of order, %s less than latest one %s" %
                 (patchInfo.seqNo), seqNo)
             return False
     # check all the dependencies
     for item in patchInfo.depKIDSBuild:
         if patchList and item in self._patchSet:  # we are going to install the dep patch
             logger.info("We are going to install the patch %s" % item)
             """ make sure installation is in the right order """
             itemIndex = self.indexInPatchList(item, patchList)
             patchIndex = self.indexInPatchList(patchInfo.installName,
                                                patchList)
             if itemIndex >= patchIndex:
                 logger.warn("%s is out of order with %s" %
                             (item, patchInfo))
                 return False
             else:
                 continue
         (namespace, ver, patch) = extractInfoFromInstallName(item)
         if self._vistaPatchInfo.hasPatchInstalled(item, namespace, ver,
                                                   patch):
             logger.debug("%s is arelady installed" % item)
             continue
         installStatus = self._vistaPatchInfo.getInstallationStatus(item)
         if self._vistaPatchInfo.isInstallCompleted(installStatus):
             continue
         elif item in patchInfo.optionalDepSet:
             logger.warn(
                 "Patch specified in KIDS info file %s is not installed for %s"
                 % (item, patchInfo.installName))
             continue
         else:
             logger.error(
                 "dep %s is not installed for %s %s" %
                 (item, patchInfo.installName, patchInfo.kidsFilePath))
             patchInfo.depKIDSBuild.remove(item)
             patchInfo.depKIDSBuild.add(item + " <---")
             return False
     return True
Ejemplo n.º 16
0
    def __buildPatchOrderDependencyByCSV__(self, orderCSV):
        patchOrderList = self._patchOrderCSVDict[orderCSV]
        if patchOrderList is None: return
        """ some sanity check """
        outOrderList = []
        for patchOrder in patchOrderList:
            installName = patchOrder[0]
            if installName not in self._patchInfoDict:
                if (installName not in self._informationalKidsSet
                        and installName not in self._kidsInstallNameDict):
                    logger.warn("No KIDS file found for %s" % str(patchOrder))
                continue
            patchInfo = self._patchInfoDict[installName]
            """ check the seq no """
            seqNo = patchOrder[1]
            if len(seqNo) > 0:
                """ check the seq no match the parsing result """
                if patchInfo.seqNo is not None:
                    if int(seqNo) != int(patchInfo.seqNo):
                        logger.error(
                            "SeqNo mismatch for %s, from csv: %s, info %s" %
                            (installName, seqNo, patchInfo.seqNo))
                else:
                    logger.info("Add seqNo %s for %s" % (seqNo, installName))
                    patchInfo.seqNo = seqNo
            """ handle the case with multibuilds kids file """
            if patchInfo.isMultiBuilds:
                installList = patchInfo.multiBuildsList
                index = installList.index(installName)
                if index > 0:
                    for idx in range(0, index):
                        prevInstallName = installList[idx]
                        prevPatchInfo = self._patchInfoDict[prevInstallName]
                        if prevInstallName in self._notInstalledKidsSet:
                            logger.error("%s is not installed by FOIA" %
                                         prevInstallName)
                        if prevInstallName not in outOrderList:
                            logger.debug("Adding %s as part of multibuilds" %
                                         prevInstallName)
                            outOrderList.append(prevInstallName)
                        else:
                            logger.debug("%s is already in the list" %
                                         prevInstallName)
            outOrderList.append(installName)

        for idx in range(len(outOrderList) - 1, 0, -1):
            installName = outOrderList[idx]
            prevInstallName = outOrderList[idx - 1]
            self._csvDepDict[installName] = prevInstallName
Ejemplo n.º 17
0
 def runInstallation(self, vistATestClient, vistATestClient2=None, reinst=False):
     connection = vistATestClient.getConnection()
     self.__setupLogFile__(connection)
     infoFetcher = VistAPackageInfoFetcher(vistATestClient)
     installStatus = infoFetcher.getInstallationStatus(self._kidsInstallName)
     """ select KIDS installation workflow based on install status """
     if infoFetcher.isInstallCompleted(installStatus):
         logger.warn("install %s is already completed!" % self._kidsInstallName)
         if not reinst:
             return True
     # run pre-installation preparation
     self.preInstallationWork(vistATestClient)
     if infoFetcher.isInstallStarted(installStatus):
         return self.restartInstallation(vistATestClient)
     return self.normalInstallation(vistATestClient, vistATestClient2, reinst)
Ejemplo n.º 18
0
 def runInstallation(self, vistATestClient, vistATestClient2=None, reinst=False):
   connection = vistATestClient.getConnection()
   self.__setupLogFile__(connection)
   infoFetcher = VistAPackageInfoFetcher(vistATestClient)
   installStatus = infoFetcher.getInstallationStatus(self._kidsInstallName)
   """ select KIDS installation workflow based on install status """
   if infoFetcher.isInstallCompleted(installStatus):
     logger.warn("install %s is already completed!" %
                  self._kidsInstallName)
     if not reinst:
       return True
   # run pre-installation preparation
   self.preInstallationWork(vistATestClient)
   if infoFetcher.isInstallStarted(installStatus):
     return self.restartInstallation(vistATestClient)
   return self.normalInstallation(vistATestClient,vistATestClient2, reinst)
Ejemplo n.º 19
0
  def __buildPatchOrderDependencyByCSV__(self, orderCSV):
    patchOrderList = self._patchOrderCSVDict[orderCSV]
    if patchOrderList is None: return
    """ some sanity check """
    outOrderList = []
    for patchOrder in patchOrderList:
      installName = patchOrder[0]
      if installName not in self._patchInfoDict:
        if (installName not in self._informationalKidsSet and
            installName not in self._kidsInstallNameDict):
          logger.warn("No KIDS file found for %s" % str(patchOrder))
        continue
      patchInfo = self._patchInfoDict[installName]
      """ check the seq no """
      seqNo = patchOrder[1]
      if len(seqNo) > 0:
        """ check the seq no match the parsing result """
        if patchInfo.seqNo is not None:
          if int(seqNo) != int(patchInfo.seqNo):
            logger.error("SeqNo mismatch for %s, from csv: %s, info %s" %
                         (installName, seqNo, patchInfo.seqNo))
        else:
          logger.info("Add seqNo %s for %s" % (seqNo, installName))
          patchInfo.seqNo = seqNo
      """ handle the case with multibuilds kids file """
      if patchInfo.isMultiBuilds:
        installList = patchInfo.multiBuildsList
        index = installList.index(installName)
        if index > 0:
          for idx in range(0, index):
            prevInstallName = installList[idx]
            prevPatchInfo = self._patchInfoDict[prevInstallName]
            if prevInstallName in self._notInstalledKidsSet:
              logger.error("%s is not installed by FOIA" % prevInstallName)
            if prevInstallName not in outOrderList:
              logger.debug("Adding %s as part of multibuilds" % prevInstallName)
              outOrderList.append(prevInstallName)
            else:
              logger.debug("%s is already in the list" % prevInstallName)
      outOrderList.append(installName)

    for idx in range(len(outOrderList)-1, 0, -1):
      installName = outOrderList[idx]
      prevInstallName = outOrderList[idx-1]
      self._csvDepDict[installName] = prevInstallName
Ejemplo n.º 20
0
 def __buildPatchOrderDependencyByCSV__(self, orderCSV):
     patchOrderList = self._patchOrderCSVDict[orderCSV]
     if patchOrderList is None: return
     """ some sanity check """
     outPatchList = []
     multiBuildSet = set()
     for patchOrder in patchOrderList:
         installName = patchOrder[0]
         if installName not in self._patchInfoDict:
             if (installName not in self._informationalKidsSet
                     and installName not in self._kidsInstallNameDict):
                 logger.warn("No KIDS file found for %s" % str(patchOrder))
             continue
         patchInfo = self._patchInfoDict[installName]
         patchInfo.verifiedDate = patchOrder[2]
         """ check the seq no """
         seqNo = patchOrder[1]
         if len(seqNo) > 0:
             """ check the seq no match the parsing result """
             if patchInfo.seqNo is not None:
                 if int(seqNo) != int(patchInfo.seqNo):
                     logger.error(
                         "SeqNo mismatch for %s, from csv: %s, info %s" %
                         (installName, seqNo, patchInfo.seqNo))
             else:
                 logger.info("Add seqNo %s for %s" % (seqNo, installName))
                 patchInfo.seqNo = seqNo
         """ handle the multi-build patch """
         if patchInfo.installName in multiBuildSet:
             logger.info("%s is already part of the multiBuild" %
                         installName)
             continue
         if patchInfo.isMultiBuilds:
             patchList = [
                 self._patchInfoDict[x] for x in patchInfo.multiBuildsList
             ]
             for patchInfo in patchList:
                 patchInfo.verifiedDate = patchOrder[2]
             outPatchList.extend(patchList)
             multiBuildSet.update(patchInfo.multiBuildsList)
         else:
             outPatchList.append(patchInfo)
     """ update the order list to include only patch info """
     self._patchOrderCSVDict[orderCSV] = outPatchList
Ejemplo n.º 21
0
 def generatePackageReadMes(self):
     self.__readFromPackageCsv__()
     for packageName in self._allPackageName:
         inputReadMePath = os.path.join(self._inputDir, "Packages",
                                        packageName, "README.rst")
         outputDir = os.path.join(self._outputDir, "Packages", packageName)
         if not os.path.exists(inputReadMePath):
             logger.warn("No README.rst for Package %s" % packageName)
             continue
         if not os.path.exists(outputDir):
             logger.warn("Package %s does not exist in M Repository" %
                         packageName)
             continue
         goldSection = self.__parseGoldSectionFromReadMe__(inputReadMePath)
         if goldSection:
             self._packageGoldDiskDict[packageName] = goldSection
         self.generatePackageReadMe(packageName)
     if self._outputFile:
         self._outputFile.close()
Ejemplo n.º 22
0
 def __parseAllKIDSInfoFilesList__(self):
     kidsParser = PatchInfoParser()
     for kidsInfoFile in self._kidsInfoFileList:
         patchInfo = kidsParser.parseKIDSInfoFile(kidsInfoFile)
         if not patchInfo:
             logger.debug("invalid kids info file %s" % kidsInfoFile)
             self._invalidInfoFileSet.add(kidsInfoFile)
             continue
         """ only add to list for info that is related to a Patch"""
         installName = patchInfo.installName
         if installName not in self._kidsInstallNameDict:
             logger.warn("no KIDS file related to %s (%s)" %
                         (installName, kidsInfoFile))
             if installName in self._missKidsBuildDict:
                 logger.warn("duplicated kids install name")
                 if kidsInfoFile != self._missKidsBuildDict[
                         installName].kidsInfoPath:
                     logger.warn("duplicated kids info file name %s" %
                                 kidsInfoFile)
                 continue
             self._missKidsBuildDict[installName] = patchInfo
             continue
         patchInfo.kidsFilePath = self._kidsInstallNameDict[installName]
         assert patchInfo.kidsFilePath
         """ update PatchInfo kidsSha1 and kidsSha1Path """
         if installName in self._kidsInstallNameSha1Dict:
             sha1Path = self._kidsInstallNameSha1Dict[installName]
             patchInfo.kidsSha1Path = sha1Path
             patchInfo.kidsSha1 = readSha1SumFromSha1File(sha1Path)
         if installName in self._patchInfoDict:
             logger.warn("duplicated installName %s, %s, %s" %
                         (installName, self._patchInfoDict[installName],
                          kidsInfoFile))
         """ merge the dependency if needed, also
       put extra dependency into optional set """
         if installName in self._kidsDepBuildDict:
             infoDepSet = set()
             kidsDepSet = set()
             if patchInfo.depKIDSBuild:
                 infoDepSet = patchInfo.depKIDSBuild
             if self._kidsDepBuildDict[installName]:
                 kidsDepSet = self._kidsDepBuildDict[installName]
             diffSet = kidsDepSet ^ infoDepSet
             if len(diffSet):
                 logger.info("Merging kids dependencies %s" % installName)
                 logger.debug("kids build set is %s" % kidsDepSet)
                 logger.debug("info build set is %s" % infoDepSet)
                 logger.warning("difference set: %s" % diffSet)
                 patchInfo.depKIDSBuild = infoDepSet | kidsDepSet
                 patchInfo.optionalDepSet = infoDepSet - kidsDepSet
             else:
                 patchInfo.depKIDSBuild = infoDepSet
         self._patchInfoDict[installName] = patchInfo
Ejemplo n.º 23
0
 def generatePackageReadMes(self):
   self.__readFromPackageCsv__()
   for packageName in self._allPackageName:
     inputReadMePath = os.path.join(self._inputDir, "Packages",
                               packageName, "README.rst")
     outputDir = os.path.join(self._outputDir, "Packages",
                               packageName)
     if not os.path.exists(inputReadMePath):
       logger.warn("No README.rst for Package %s" % packageName)
       continue
     if not os.path.exists(outputDir):
       logger.warn("Package %s does not exist in M Repository" % packageName)
       continue
     goldSection = self.__parseGoldSectionFromReadMe__(inputReadMePath)
     if goldSection:
       self._packageGoldDiskDict[packageName] = goldSection
     self.generatePackageReadMe(packageName)
   if self._outputFile:
     self._outputFile.close()
Ejemplo n.º 24
0
 def restartInstallation(self, vistATestClient):
     logger.warn("restart the previous installation for %s" % self._kidsInstallName)
     connection = vistATestClient.getConnection()
     self.__gotoKIDSMainMenu__(vistATestClient)
     self.__selectRestartInstallOption__(connection)
     index = connection.expect(["DEVICE: ", "Select INSTALL NAME: "])
     if index == 0:
         self.__installationCommon__(vistATestClient)
         return True
     else:
         logger.error("Restart install %s failed" % self._kidsInstallName)
         """ go back to KIDS main menu first """
         connection.send("\r")
         connection.expect("Select Installation ")
         connection.send("\r")
         """ try to unload a distribution first """
         result = self.unloadDistribution(vistATestClient, False)
         if not result:
             logger.error("Unload Distribution %s failed" % self._kidsInstallName)
         return self.normalInstallation(vistATestClient)
Ejemplo n.º 25
0
 def restartInstallation(self, vistATestClient):
   logger.warn("restart the previous installation for %s" %
               self._kidsInstallName)
   connection = vistATestClient.getConnection()
   self.__gotoKIDSMainMenu__(vistATestClient)
   self.__selectRestartInstallOption__(connection)
   index = connection.expect(["DEVICE: ", "Select INSTALL NAME: "])
   if index == 0:
     self.__installationCommon__(vistATestClient)
     return True
   else:
     logger.error("Restart install %s failed" % self._kidsInstallName)
     """ go back to KIDS main menu first """
     connection.send('\r')
     connection.expect("Select Installation ")
     connection.send('\r')
     """ try to unload a distribution first """
     result = self.unloadDistribution(vistATestClient, False)
     if not result:
       logger.error("Unload Distribution %s failed" % self._kidsInstallName)
     return self.normalInstallation(vistATestClient)
Ejemplo n.º 26
0
 def __parseAllKIDSInfoFilesList__(self):
   kidsParser = PatchInfoParser()
   for kidsInfoFile in self._kidsInfoFileList:
     patchInfo = kidsParser.parseKIDSInfoFile(kidsInfoFile)
     if not patchInfo:
       logger.debug("invalid kids info file %s" % kidsInfoFile)
       self._invalidInfoFileSet.add(kidsInfoFile)
       continue
     """ only add to list for info that is related to a Patch"""
     installName = patchInfo.installName
     if installName not in self._kidsInstallNameDict:
       logger.warn("no KIDS file related to %s (%s)" % (installName, kidsInfoFile))
       if installName in self._missKidsBuildDict:
         logger.warn("duplicated kids install name")
         if kidsInfoFile != self._missKidsBuildDict[installName].kidsInfoPath:
           logger.warn("duplicated kids info file name %s" % kidsInfoFile)
         continue
       self._missKidsBuildDict[installName] = patchInfo
       continue
     patchInfo.kidsFilePath = self._kidsInstallNameDict[installName]
     assert patchInfo.kidsFilePath
     """ update PatchInfo kidsSha1 and kidsSha1Path """
     if installName in self._kidsInstallNameSha1Dict:
       sha1Path = self._kidsInstallNameSha1Dict[installName]
       patchInfo.kidsSha1Path = sha1Path
       patchInfo.kidsSha1 = readSha1SumFromSha1File(sha1Path)
     if installName in self._patchInfoDict:
       logger.warn("duplicated installName %s, %s, %s" %
                    (installName, self._patchInfoDict[installName],
                    kidsInfoFile))
     """ merge the dependency if needed, also
         put extra dependency into optional set """
     if installName in self._kidsDepBuildDict:
       infoDepSet = set()
       kidsDepSet = set()
       if patchInfo.depKIDSBuild:
         infoDepSet = patchInfo.depKIDSBuild
       if self._kidsDepBuildDict[installName]:
         kidsDepSet = self._kidsDepBuildDict[installName]
       diffSet = kidsDepSet ^ infoDepSet
       if len(diffSet):
         logger.info("Merging kids dependencies %s" % installName)
         logger.debug("kids build set is %s" % kidsDepSet)
         logger.debug("info build set is %s" % infoDepSet)
         logger.warning("difference set: %s" % diffSet)
         patchInfo.depKIDSBuild = infoDepSet | kidsDepSet
         patchInfo.optionalDepSet = infoDepSet - kidsDepSet
       else:
         patchInfo.depKIDSBuild = infoDepSet
     self._patchInfoDict[installName] = patchInfo
Ejemplo n.º 27
0
 def __buildPatchOrderDependencyByCSV__(self, orderCSV):
   patchOrderList = self._patchOrderCSVDict[orderCSV]
   if patchOrderList is None: return
   """ some sanity check """
   outPatchList = []
   multiBuildSet = set()
   for patchOrder in patchOrderList:
     installName = patchOrder[0]
     if installName not in self._patchInfoDict:
       if (installName not in self._informationalKidsSet and
           installName not in self._kidsInstallNameDict):
         logger.warn("No KIDS file found for %s" % str(patchOrder))
       continue
     patchInfo = self._patchInfoDict[installName]
     patchInfo.verifiedDate = patchOrder[2]
     """ check the seq no """
     seqNo = patchOrder[1]
     if len(seqNo) > 0:
       """ check the seq no match the parsing result """
       if patchInfo.seqNo is not None:
         if int(seqNo) != int(patchInfo.seqNo):
           logger.error("SeqNo mismatch for %s, from csv: %s, info %s" %
                        (installName, seqNo, patchInfo.seqNo))
       else:
         logger.info("Add seqNo %s for %s" % (seqNo, installName))
         patchInfo.seqNo = seqNo
     """ handle the multi-build patch """
     if patchInfo.installName in multiBuildSet:
       logger.info("%s is already part of the multiBuild" % installName)
       continue
     if patchInfo.isMultiBuilds:
       patchList = [self._patchInfoDict[x] for x in patchInfo.multiBuildsList]
       for patchInfo in patchList:
         patchInfo.verifiedDate = patchOrder[2]
       outPatchList.extend(patchList)
       multiBuildSet.update(patchInfo.multiBuildsList)
     else:
       outPatchList.append(patchInfo)
   """ update the order list to include only patch info """
   self._patchOrderCSVDict[orderCSV] = outPatchList
Ejemplo n.º 28
0
  def __parseAllKIDSBuildFilesList__(self):
    for basename in self._kidsBuildFileDict.iterkeys():
      kidsFile, sha1Path = self._kidsBuildFileDict[basename]
      if kidsFile == None:
        logger.error("No KIDS file available for name %s" % basename)
        continue
      installNameList, seqNo, kidsBuilds = None, None, None
      if isValidKIDSBuildHeaderSuffix(kidsFile):
        from KIDSBuildParser import loadMetaDataFromJSON
        #continue
        installNameList, seqNo, kidsBuilds = loadMetaDataFromJSON(kidsFile)
      else:
        kidsParser = KIDSBuildParser(None)
        kidsParser.unregisterSectionHandler(KIDSBuildParser.ROUTINE_SECTION)
        kidsParser.parseKIDSBuild(kidsFile)
        installNameList = kidsParser.installNameList
        logger.debug("install name list is %s" % installNameList)
        seqNo = kidsParser.seqNo
        kidsBuilds = kidsParser.kidsBuilds
      if len(installNameList) > 1:
        if not self._multiBuildDict.get(kidsFile):
          self._multiBuildDict[kidsFile] = installNameList
        else:
          assert self._multiBuildDict[kidsFile] == installNameList
      elif seqNo:
        if installNameList[0] not in self._installNameSeqMap:
          self._installNameSeqMap[installNameList[0]] = seqNo
        else:
          logger.error("Duplicated KIDS build file %s" % kidsFile)
      for installName in installNameList:
        if installName in self._kidsInstallNameDict:
          logger.warn("%s is already in the dict %s" % (installName, kidsFile))
        logger.debug("Added installName %s, file %s" % (installName, kidsFile))
        self._kidsInstallNameDict[installName] = os.path.normpath(kidsFile)
        """ handle KIDS sha1 file Path """
        if sha1Path:
          if installName in self._kidsInstallNameSha1Dict:
            logger.warn("%s is already in the dict %s" % (installName, sha1Path))
          self._kidsInstallNameSha1Dict[installName] = sha1Path
        """ update kids dependency """
        if installName in self._kidsDepBuildDict:
          logger.warn("%s already has the dep map %s" %
                      (installName, self._kidsDepBuildDict[installName]))
        if kidsBuilds:
          for kidsBuild in kidsBuilds:
            if kidsBuild.installName == installName:
              depList = kidsBuild.dependencyList
              if depList:
                self._kidsDepBuildDict[installName] = set([x[0] for x in
                  depList])
                logger.info("%s: %s" % (installName,
                  self._kidsDepBuildDict[installName]))

    logger.debug("%s" % sorted(self._kidsInstallNameDict.keys()))
    logger.info("Total # of install name %d" % len(self._kidsInstallNameDict))
Ejemplo n.º 29
0
  def __parseAllKIDSBuildFilesList__(self):
    for basename in self._kidsBuildFileDict.iterkeys():
      kidsFile, sha1Path = self._kidsBuildFileDict[basename]
      if kidsFile == None:
        logger.error("No KIDS file available for name %s" % basename)
        continue
      installNameList, seqNo, kidsBuilds = None, None, None
      if isValidKIDSPatchHeaderSuffix(kidsFile):
        from KIDSPatchParser import loadMetaDataFromJSON
        #continue
        installNameList, seqNo, kidsBuilds = loadMetaDataFromJSON(kidsFile)
      else:
        kidsParser = KIDSPatchParser(None)
        kidsParser.unregisterSectionHandler(KIDSPatchParser.ROUTINE_SECTION)
        kidsParser.parseKIDSBuild(kidsFile)
        installNameList = kidsParser.installNameList
        logger.debug("install name list is %s" % installNameList)
        seqNo = kidsParser.seqNo
        kidsBuilds = kidsParser.kidsBuilds
      if len(installNameList) > 1:
        if not self._multiBuildDict.get(kidsFile):
          self._multiBuildDict[kidsFile] = installNameList
        else:
          assert self._multiBuildDict[kidsFile] == installNameList
      elif seqNo:
        if installNameList[0] not in self._installNameSeqMap:
          self._installNameSeqMap[installNameList[0]] = seqNo
        else:
          logger.error("Duplicated KIDS build file %s" % kidsFile)
      for installName in installNameList:
        if installName in self._kidsInstallNameDict:
          logger.warn("%s is already in the dict %s" % (installName, kidsFile))
        logger.debug("Added installName %s, file %s" % (installName, kidsFile))
        self._kidsInstallNameDict[installName] = os.path.normpath(kidsFile)
        """ handle KIDS sha1 file Path """
        if sha1Path:
          if installName in self._kidsInstallNameSha1Dict:
            logger.warn("%s is already in the dict %s" % (installName, sha1Path))
          self._kidsInstallNameSha1Dict[installName] = sha1Path
        """ update kids dependency """
        if installName in self._kidsDepBuildDict:
          logger.warn("%s is already has the dep map %s" %
                      (installName, self._kidsDepBuildDict[installName]))
        if kidsBuilds:
          for kidsBuild in kidsBuilds:
            if kidsBuild.installName == installName:
              depList = kidsBuild.dependencyList
              if depList:
                self._kidsDepBuildDict[installName] = set([x[0] for x in
                  depList])
                logger.info("%s: %s" % (installName,
                  self._kidsDepBuildDict[installName]))

    logger.debug("%s" % sorted(self._kidsInstallNameDict.keys()))
    logger.info("Total # of install name %d" % len(self._kidsInstallNameDict))