Exemplo n.º 1
0
def _groupPfsIniByInstanceName(profiles):
    r''' Group profiles by instance to which they belong
    @types: list[tuple[str, str]] -> dict[str, InstancePfSet]
    @param profiles: list of tuples where first item is name and other is
            content of profile
    @return: dictionary of grouped profilesby instance name
    '''
    pfSetByInstName = {}
    iniParser = IniParser()
    for pfName, pfContent in profiles:
        instName = (StartProfileParser.parseInstanceNameFromPfName(pfName)
                    or InstanceProfileParser.parseInstanceNameFromPfName(pfName))
        if instName:
            iniDoc = iniParser.parseIniDoc(pfContent)
            pfSet = pfSetByInstName.get(instName, InstancePfSet(None, None))
            if StartProfileParser.isApplicable(pfName):
                pfSetByInstName[instName] = pfSet._replace(startPfIni=iniDoc)
            elif InstanceProfileParser.isApplicable(pfName):
                pfSetByInstName[instName] = pfSet._replace(instancePfIni=iniDoc)
        else:
            logger.warn("Failed to determine profile type: %s" % pfName)
    return pfSetByInstName
Exemplo n.º 2
0
def _discoverBasedOnProfilesUnsafe(sapUtils, oshPerInstance, system, systemOsh, discoverSapProfiles):
    '@types: SapUtils, dict[Instance, osh], System, osh, bool -> oshv'
    r = discoverTopologyBasedOnProfiles(sapUtils, system.getName(), systemOsh)
    pfNameToOsh, defaultPf, otherPfs = r

    pfSetByInstName = _groupPfsIniByInstanceName(otherPfs)

    instOshs = oshPerInstance.itervalues()

    vector = ObjectStateHolderVector()
    if discoverSapProfiles:
        vector.addAll(pfNameToOsh.values())
    vector.addAll(_reportInstPfLinks(instOshs, pfNameToOsh, system))

    defaultPfDoc = None
    if defaultPf:
        defaultPfDoc = IniParser.parseIniDoc(second(defaultPf))
        try:
            logger.info("Trying to discover ASCS")
            vector.addAll(_discoverAscsInPf(defaultPfDoc, system, systemOsh, oshPerInstance))
        except SapSystemInconsistentDataException, e:
            logger.debugException('')
            raise e
        except: