Ejemplo n.º 1
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.º 2
0
def generateCommitMsgFileByPatchInfo(patchInfo,
                                     commitMsgFile,
                                     branch="HEAD",
                                     reposDir=None):
    reposHash = getGitRepoRevisionHash(branch, reposDir)[:8]
    with open(commitMsgFile, 'w') as output:
        topicLine = "Install: %s" % patchInfo.installName
        if patchInfo.multiBuildsList:
            topicLine = "Install: %s" % (", ".join(patchInfo.multiBuildsList))
        output.write("%s\n" % topicLine)
        output.write("\nPatch Subject: %s" % patchInfo.subject)
        output.write('\n')
        output.write("Description:\n\n" +
                     '\n'.join([str(x) for x in patchInfo.description]))
        output.write('\n')
        output.write('\n')
        output.write('Use default answers for KIDS load/install questions.\n')
        output.write('\n')
        if patchInfo.isMultiBuilds:  # special logic for multibuilds
            buildLink, otherLinks = getWebLinkForPatchSourceMultiBuilds(
                patchInfo, reposHash)
            output.write('Multi-Build: %s\n' % buildLink)
            for link in otherLinks:
                if link:
                    output.write('Patch-Files: %s\n' % link)
        else:
            packageLink = getWebLinkForPatchSourceByFile(
                patchInfo.kidsFilePath, reposHash)
            output.write('Patch-Files: %s\n' % packageLink)
Ejemplo n.º 3
0
def generateCommitMsgFileByPatchInfo(patchInfo, commitMsgFile,
                                     branch="HEAD", reposDir=None):
  reposHash = getGitRepoRevisionHash(branch, reposDir)[:8]
  with open(commitMsgFile, 'w') as output:
    topicLine = "Install: %s" % patchInfo.installName
    if patchInfo.multiBuildsList:
      topicLine = "Install: %s" % (", ".join(patchInfo.multiBuildsList))
    output.write("%s\n" % topicLine)
    output.write("\nPatch Subject: %s" % patchInfo.subject)
    output.write('\n')
    output.write("Description:\n\n" + '\n'.join([str(x) for x in patchInfo.description]))
    output.write('\n')
    output.write('\n')
    output.write('Use default answers for KIDS load/install questions.\n')
    output.write('\n')
    if patchInfo.isMultiBuilds: # special logic for multibuilds
      buildLink, otherLinks = getWebLinkForPatchSourceMultiBuilds(patchInfo,
                                                                  reposHash)
      output.write('Multi-Build: %s\n' % buildLink)
      for link in otherLinks:
        if link:
          output.write('Patch-Files: %s\n' % link)
    else:
      packageLink = getWebLinkForPatchSourceByFile(patchInfo.kidsFilePath,
                                                   reposHash)
      output.write('Patch-Files: %s\n' % packageLink)
Ejemplo n.º 4
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