def installModel(appname, appver, entities, amfSession=None): notes = [] errors = [] # Commit these entities into the AMF if amfSession is None: amfSession = aspAmf.Session() #log.debug("Entities: %s" % entities) for e in entities: log.debug("%s" % e.name) try: amfSession.InstallApp(entities) except aspAmf.AmfError,e: notes.append(T("Error committing the configuration. Application may be partially deployed: $err",err=str(e)))
def installModel(appname, appver, entities, amfSession=None): notes = [] errors = [] # Commit these entities into the AMF if amfSession is None: amfSession = aspAmf.Session() #log.debug("Entities: %s" % entities) for e in entities: log.debug("%s" % e.name) try: amfSession.InstallApp(entities) except aspAmf.AmfError, e: notes.append( T("Error committing the configuration. Application may be partially deployed: $err", err=str(e)))
def createModel(fromdir,cfg,tgtblades,specifiedNodes): ci = clusterinfo.ci notes = [] errors = [] # Create the SAF AMF entities corresponding to this application for (appname,appcfg) in cfg.items(): integration = appcfg.get("GuiIntegration",None) if integration: install = integration.install exec install in globals(), {} basename = appcfg.get("deployPrefix",appname) # Deploy preferentially with the deployment prefix, but use the app name if there isn't one nameIndex = 0 for existingSg in ci.sgList: if basename + "SGi" in existingSg.name: i = int(existingSg.name.replace(basename + "SGi","")) if i >= nameIndex: nameIndex = i+1 if nameIndex: notes.append("Name %s exists, so appending the numeral %d." % (basename,nameIndex)) compNames = appcfg.programNames.values() nodes = [] ninst = 1 if appcfg.modifiers.has_key('instancesPerNode'): ninst = int(appcfg.modifiers.instancesPerNode) tgtblades = tgtblades * ninst if specifiedNodes: numNodes = len(tgtblades) # We deploy to where the user selected else: numNodes = min(appcfg.totalNodes*ninst,len(tgtblades)) # If no blades chosen, we just deploy the recommended instance(s) if appcfg.redundancyModel in ["2N", "2n", "2"]: log.info("%s uses 2N redundancy model" % basename) appcfg.rModel = "2N" appcfg.activePerSg = 1 appcfg.standbyPerSg = 1 nodesPerSg = 2 elif appcfg.redundancyModel.lower() == "custom": appcfg.rModel = "custom" nodesPerSg = appcfg.totalNodes appcfg.setdefault("activePerSg", nodesPerSg) appcfg.setdefault("standbyPerSg", 0) else: log.info("%s uses N+M redundancy model" % basename) regexp = r'\s*(?P<active>\d+)\s*\+\s*(?P<standby>\d+)\s*' m = re.match(regexp, appcfg.redundancyModel) d = m.groupdict() appcfg.rModel = "M+N" # This configures the SG exactly as suggested in the appcfg.xml # appcfg.activePerSg = int(d['active']) # appcfg.standbyPerSg = int(d['standby']) # nodesPerSg = appcfg.activePerSg + appcfg.standbyPerSg try: # If the # active is not a number then that's ok (see below) active = int(d['active']) except: active = None standby = int(d['standby']) if numNodes<3 and standby>0: # If there's 1 or 2 nodes, use 1+1 appcfg.activePerSg = 1 appcfg.standbyPerSg = 1 elif active is None: # (N+1) Keep the specified # of standby and let active grow. appcfg.standbyPerSg = standby appcfg.activePerSg = max(1,numNodes-standby) # But at least 1 active of course else: # (3+1) Make sure there's at least 1 standby, otherwise keep the ratio intact sbratio = float(standby)/(float(active)+float(standby)) nstandby = int(numNodes*sbratio) if nstandby < 1: nstandby = 1 appcfg.standbyPerSg = nstandby appcfg.activePerSg = max(1,numNodes-standby) # But at least 1 active of course # Assign each node to an SG. if 0: # This logic generates multiple SGs if more nodes are passed than numNodes nodeCnt = 0 while nodeCnt < numNodes: sgNodes = [] for perSg in range(0,nodesPerSg): if nodeCnt >= numNodes: break sgNodes.append(tgtblades[nodeCnt]) nodeCnt +=1 nodes.append(sgNodes) # Make a list of sgs which is therefore a list of lists of nodes else: # Instead, I'm just going to create a bigger SG nodes.append(tgtblades[0:numNodes]) log.debug("Nodes: %s" % str([[x.name for x in y] for y in nodes])) entities = aspAmfCreate.CreateApp(compNames,nodes,appcfg,appcfg.get('work', None),basename, {},nameIndex) return (entities,(errors,notes))
def createModel(fromdir, cfg, tgtblades, specifiedNodes): ci = clusterinfo.ci notes = [] errors = [] # Create the SAF AMF entities corresponding to this application for (appname, appcfg) in cfg.items(): integration = appcfg.get("GuiIntegration", None) if integration: install = integration.install exec install in globals(), {} basename = appcfg.get( "deployPrefix", appname ) # Deploy preferentially with the deployment prefix, but use the app name if there isn't one nameIndex = 0 for existingSg in ci.sgList: if basename + "SGi" in existingSg.name: i = int(existingSg.name.replace(basename + "SGi", "")) if i >= nameIndex: nameIndex = i + 1 if nameIndex: notes.append("Name %s exists, so appending the numeral %d." % (basename, nameIndex)) compNames = appcfg.programNames.values() nodes = [] ninst = 1 if appcfg.modifiers.has_key('instancesPerNode'): ninst = int(appcfg.modifiers.instancesPerNode) tgtblades = tgtblades * ninst if specifiedNodes: numNodes = len(tgtblades) # We deploy to where the user selected else: numNodes = min( appcfg.totalNodes * ninst, len(tgtblades) ) # If no blades chosen, we just deploy the recommended instance(s) if appcfg.redundancyModel in ["2N", "2n", "2"]: log.info("%s uses 2N redundancy model" % basename) appcfg.rModel = "2N" appcfg.activePerSg = 1 appcfg.standbyPerSg = 1 nodesPerSg = 2 elif appcfg.redundancyModel.lower() == "custom": appcfg.rModel = "custom" nodesPerSg = appcfg.totalNodes appcfg.setdefault("activePerSg", nodesPerSg) appcfg.setdefault("standbyPerSg", 0) else: log.info("%s uses N+M redundancy model" % basename) regexp = r'\s*(?P<active>\d+)\s*\+\s*(?P<standby>\d+)\s*' m = re.match(regexp, appcfg.redundancyModel) d = m.groupdict() appcfg.rModel = "M+N" # This configures the SG exactly as suggested in the appcfg.xml # appcfg.activePerSg = int(d['active']) # appcfg.standbyPerSg = int(d['standby']) # nodesPerSg = appcfg.activePerSg + appcfg.standbyPerSg try: # If the # active is not a number then that's ok (see below) active = int(d['active']) except: active = None standby = int(d['standby']) if numNodes < 3 and standby > 0: # If there's 1 or 2 nodes, use 1+1 appcfg.activePerSg = 1 appcfg.standbyPerSg = 1 elif active is None: # (N+1) Keep the specified # of standby and let active grow. appcfg.standbyPerSg = standby appcfg.activePerSg = max( 1, numNodes - standby) # But at least 1 active of course else: # (3+1) Make sure there's at least 1 standby, otherwise keep the ratio intact sbratio = float(standby) / (float(active) + float(standby)) nstandby = int(numNodes * sbratio) if nstandby < 1: nstandby = 1 appcfg.standbyPerSg = nstandby appcfg.activePerSg = max( 1, numNodes - standby) # But at least 1 active of course # Assign each node to an SG. if 0: # This logic generates multiple SGs if more nodes are passed than numNodes nodeCnt = 0 while nodeCnt < numNodes: sgNodes = [] for perSg in range(0, nodesPerSg): if nodeCnt >= numNodes: break sgNodes.append(tgtblades[nodeCnt]) nodeCnt += 1 nodes.append( sgNodes ) # Make a list of sgs which is therefore a list of lists of nodes else: # Instead, I'm just going to create a bigger SG nodes.append(tgtblades[0:numNodes]) log.debug("Nodes: %s" % str([[x.name for x in y] for y in nodes])) entities = aspAmfCreate.CreateApp(compNames, nodes, appcfg, appcfg.get('work', None), basename, {}, nameIndex) return (entities, (errors, notes))