Ejemplo n.º 1
0
def updateAlphas():
    oldTargetRules = copyTargets(Globals.TARGETRULES)      
    oldInstallRules = copyTargets(Globals.INSTALLEDRULES) 

    newAlphas = Alphas.getAlphas(Globals.ALPHAFILE)
    Globals.log.info("NEW ALPHAS " + str(newAlphas))
    Globals.log.info("OLD ALPHAS" + str(Globals.ALPHAS))
    (oldTargetList, newTargetList) = Bins.determineTargets(oldTargetRules, Globals.ALPHAS, oldInstallRules)
    (oldTargetList, newTargetList) = Bins.redistributeTargets(oldTargetRules, Globals.ALPHAS, newAlphas, oldTargetList, newTargetList)
#    Bins.printTargetList(newTargetList)
    totalAssignments = len(newTargetList)
    Globals.log.info("Total Assigns: " + str(totalAssignments))

    newAlphas = Alphas.distributeAlphas(newAlphas, Globals.ALPHAS, totalAssignments)
    Globals.log.info("DISTRIBUTE NEW ALPHAS " + str(newAlphas))
    newAlphas = Alphas.distributeEven(newAlphas, totalAssignments)
#    newAlphas = Alphas.distributeOld(newAlphas, Globals.ALPHAS, totalAssignments)
    Globals.log.info("DISTRIBUTE OLD ALPHAS " + str(newAlphas))
    newAlphas = Alphas.distributeRemaining(newAlphas, totalAssignments)
    Globals.log.info("REMAINING NEW ALPHAS " + str(newAlphas))
    Alphas.updateAlphas(newAlphas, oldTargetList)

    newTargetList = IPRules.assignReplicas(newAlphas, newTargetList)
    Bins.printTargetList(newTargetList)

    newRuleList = IPRules.getNewRules(Globals.TARGETRULES, newTargetList)
    IPRules.printRules(newRuleList)

#    (oldRules, newRules) = IPRules.redistributeRules(Globals.TARGETRULES, Globals.ALPHAS, newAlphas)
#    newRuleList.extend(newRules)

#    IPRules.updateAssigns(newRuleList, oldRules)
    IPRules.updateAssigns(newRuleList)
    Alphas.printAlphas(Globals.ALPHAS)

    return newRuleList