Esempio n. 1
0
def ev4_dataSharingGroupsOutput(ls, cmd_prefix):
    if isNull(cmd_prefix):
        return []
    dsgs = []
    cmd_prefix = string.replace(cmd_prefix, '.', '..')
    output = ls.evMvsCmd(_CMD_PREFIX_DISPLAY_GROUP % cmd_prefix)
    if output.isSuccess() and len(output.cmdResponseList) > 0:
        dsg = Dsg()
        # first get the data sharing group info ------------------------------------
        # first try version 9/10 format -------------------------------------------
        dsgInfo1 = output.getValuesFromLineList('s', output.cmdResponseList, 'DISPLAY OF GROUP\(', '\).+LEVEL\(', '\) MODE\(', '\)')
        if isNotNull(dsgInfo1) and len(dsgInfo1) > 0 and isNotNull(dsgInfo1[0]) and len(dsgInfo1[0]) == 5:
            if isNotNull(dsgInfo1[0][1]) and string.find(dsgInfo1[0][1], '.......') < 0:
                dsg.name = dsgInfo1[0][1]
                dsg.level = dsgInfo1[0][2]
                dsg.mode = dsgInfo1[0][3]
        else:
            # try version 8 format ---------------------------------------------
            dsgInfo2 = output.getValuesFromLineList('s', output.cmdResponseList, 'DISPLAY OF GROUP\(', '\) GROUP LEVEL\(', '\)')
            if isNotNull(dsgInfo2) and len(dsgInfo2) > 0 and isNotNull(dsgInfo2[0]) and len(dsgInfo2[0]) == 4:
                if isNotNull(dsgInfo2[0][1]) and dsgInfo2[0][1] != '.......':
                    dsg.name = dsgInfo2[0][1]
                    dsg.level = dsgInfo2[0][2]

        if isNull(dsg.name):
            logger.warn("No Data sharing group found")
        else:
            # next get more information about the DSG --------------------------
            dsgInfo3 = output.getValuesFromLineList('s', output.cmdResponseList, 'PROTOCOL LEVEL\(', '\)\s+GROUP ATTACH NAME\(', '\)')
            if isNotNull(dsgInfo3) and len(dsgInfo3) > 0 and isNotNull(dsgInfo3[0]) and len(dsgInfo3[0]) == 4:
                dsg.protocolLevel = dsgInfo3[0][1]
                dsg.attachName = dsgInfo3[0][2]

            # next get the DSG member info -------------------------------------
            headerColumns = ['MEMBER', 'ID', 'SUBSYS', 'CMDPREF', 'STATUS', 'LVL', 'NAME', 'SUBSYS', 'IRLMPROC']
            tableBeginPattern = 'DB2 SYSTEM'
            tableEndPattern = '----------------------------'
            firstColumnPaddingChar = ''
            includeRegexPattern = ''
            ignorePatterns = ['------']
            aliasTable = output.getTableValues(output.cmdResponseList, headerColumns, tableBeginPattern, tableEndPattern, firstColumnPaddingChar, includeRegexPattern, ignorePatterns)
            if isNotNull(aliasTable) and len(aliasTable) > 0:
                for i in range(1, len(aliasTable)):
                    if len(aliasTable[i]) == 9:
                        if isNotNull(aliasTable[i][0]) and string.find(aliasTable[i][0], '.......') < 0:
                            dsgMember = DsgMember()
                            dsgMember.db2Member = aliasTable[i][0]
                            dsgMember.id = aliasTable[i][1]
                            dsgMember.subsys = aliasTable[i][2]
                            dsgMember.cmdPref = aliasTable[i][3]
                            dsgMember.status = aliasTable[i][4]
                            dsgMember.db2Level = aliasTable[i][5]
                            dsgMember.systemName = aliasTable[i][6]
                            dsgMember.irlmSubsys = aliasTable[i][7]
                            dsgMember.irlmProc = aliasTable[i][8]
                            dsg.members.append(dsgMember)
        dsgs.append(dsg)
    return dsgs
Esempio n. 2
0
def DiscoveryMain(Framework):
    OSHVResult = ObjectStateHolderVector()

    # create LPAR node
    hostId = Framework.getDestinationAttribute(PARAM_HOST_ID)
    lparOsh = None
    if eview_lib.isNotNull(hostId):
        lparOsh = modeling.createOshByCmdbIdString('host_node', hostId)
    
    ls = eview_lib.EvShell(Framework)
    vector, regiondict, subsystemOSH = processCICS(ls, lparOsh)
    if isNull(subsystemOSH):
        logger.reportWarning('No CICS subsystems were found')
    else:
        Framework.sendObjects(vector)
        Framework.flushObjects()
        #OSHVResult.addAll(processPrograms(ls,lparOsh, regiondict, subsystemOSH, Framework)) 
        processPrograms(ls,lparOsh, regiondict, subsystemOSH, Framework)
        OSHVResult.addAll(processConnections(ls,lparOsh, regiondict, subsystemOSH, Framework))
    ls.closeClient()

    
    return OSHVResult
Esempio n. 3
0
def ev2_ddfOutput(ls, cmd_prefix):
    if isNull(cmd_prefix):
        return []
    ddfObjs = []
    cmd_prefix = string.replace(cmd_prefix, '.', '..')
    output = ls.evMvsCmd(_CMD_PREFIX_DISPLAY_DDF % cmd_prefix)
    if output.isSuccess() and len(output.cmdResponseList) > 0:
        ddfObj = Ddf()
        # status ---------------------------------------------------------------
        statusTemp = output.getValuesFromLineList('s', output.cmdResponseList, 'STATUS=')
        if isNotNull(statusTemp) and len(statusTemp) == 1 and isNotNull(statusTemp[0][1]):
            ddfObj.status = statusTemp[0][1]

        # remove first 9 characters from every line for processing table columns
        tableList = []
        for line in output.cmdResponseList:
            if isNotNull(line) and len(line) >= 9:
                tempLine = line[9:len(line)]
                if isNotNull(tempLine):
                    tableList.append(tempLine)

        # location info --------------------------------------------------------
        for i in range(len(output.cmdResponseList)):
            m = re.match('.*LOCATION\s+LUNAME\s+GENERICLU.*', output.cmdResponseList[i])
            if isNotNull(m):
                locationLine = output.cmdResponseList[i+1]
                locationLine = locationLine[9:len(locationLine)]
                location = output.getValuesFromLine('i', locationLine, '\s+', '\.', '\s+')
                if len(location) == 4:
                    ddfObj.locationName = location[0]
                    ddfObj.locationLuName = '%s.%s' % (location[1], location[2])
                    ddfObj.locationGenericLuName = location[3]
                    continue

        # Alias info -----------------------------------------------------------
        # first try for version 9 headers --------------------------------------
        headerColumns = ['ALIAS', 'PORT', 'SECPORT']
        tableBeginPattern = 'DOMAIN='
        tableEndPattern = 'MEMBER IPADDR'
        firstColumnPaddingChar = ''
        includeRegexPattern = ''
        ignorePatterns = []
        aliasTable = output.getTableValues(tableList, headerColumns, tableBeginPattern, tableEndPattern, firstColumnPaddingChar, includeRegexPattern, ignorePatterns)
        if isNotNull(aliasTable) and len(aliasTable) > 0:
            headerFound = 0
            for i in range(0, len(aliasTable)):
                if len(aliasTable[i]) == 3 and isNotNull(aliasTable[i][0]):
                    if aliasTable[i][0] != 'ALIAS' and not headerFound:
                        continue
                    if aliasTable[i][0] == 'ALIAS':
                        headerFound = 1
                        continue
                    if aliasTable[i][0][0:8] != 'DSNLTDDF':
                        ddfAliasObj = DdfAlias()
                        ddfAliasObj.aliasName = aliasTable[i][0]
                        ddfAliasObj.aliasPort = aliasTable[i][1]
                        ddfObj.ddfAlias.append(ddfAliasObj)
        # if return is empty look for version 8 headers ------------------------
        else:
            headerColumns = ['ALIAS', 'PORT']
            aliasTable = output.getTableValues(tableList, headerColumns, tableBeginPattern, tableEndPattern, firstColumnPaddingChar, includeRegexPattern, ignorePatterns)
            if isNotNull(aliasTable) and len(aliasTable) > 0:
                headerFound = 0
                for i in range(1, len(aliasTable)):
                    if len(aliasTable[i]) == 2 and isNotNull(aliasTable[i][0]):
                        if aliasTable[i][0] != 'ALIAS' and not headerFound:
                            continue
                        if aliasTable[i][0] == 'ALIAS':
                            headerFound = 1
                            continue
                        if aliasTable[i][0][0:8] != 'DSNLTDDF':
                            ddfAliasObj = DdfAlias()
                            ddfAliasObj.aliasName = aliasTable[i][0]
                            ddfAliasObj.aliasPort = aliasTable[i][1]
                            ddfObj.ddfAlias.append(ddfAliasObj)

        # IP info --------------------------------------------------------------
        # first try the DB2 version 8 format -----------------------------------
        for i in range(len(output.cmdResponseList)):
            m = re.match('.*IPADDR\s+TCPPORT\s+RESPORT.*', output.cmdResponseList[i])
            if isNotNull(m):
                ipLine = output.cmdResponseList[i+1]
                ipLine = ipLine[9:len(ipLine)]
                ips = output.getRegexedValues(ipLine, '(.*)\s+(\d+)\s+(\d+)')
                if isNotNull(ips) and len(ips) == 3:
                    ddfObj.ipAddress = ips[0]
                    ddfObj.tcpPort = ips[1]
                    continue
        if isNull(ddfObj.ipAddress):
            # try the DB2 version 9 format -------------------------------------
            ipAddrList = output.getValuesFromLineList('s', output.cmdResponseList, 'I IPADDR=')
            if isNotNull(ipAddrList) and len(ipAddrList) > 0 and isNotNull(ipAddrList[0][1]):
                ddfObj.ipAddress = ipAddrList[0][1]

        if isNull(ddfObj.tcpPort):
            # try the DB2 version 9 format -------------------------------------
            tcpList = output.getValuesFromLineList('s', output.cmdResponseList, 'TCPPORT=', 'SECPORT=')
            if isNotNull(tcpList) and len(tcpList) > 0 and isNotNull(tcpList[0][1]):
                ddfObj.tcpPort = tcpList[0][1]

        # SQL Domain -----------------------------------------------------------
        sqlDomainList = output.getValuesFromLineList('s', output.cmdResponseList, 'SQL', 'DOMAIN=')
        if isNotNull(sqlDomainList) and len(sqlDomainList) > 0 and isNotNull(sqlDomainList[0]) and len(sqlDomainList[0]) >=2:
            ddfObj.sqlDomain = sqlDomainList[0][2]
        ddfObjs.append(ddfObj)
    return ddfObjs
Esempio n. 4
0
def processEviewConfFiles(Framework, localshell):
    _vector = ObjectStateHolderVector()
    fileMonitor = file_mon_utils.FileMonitor(Framework, localshell, ObjectStateHolderVector(), None, None)
    folder = Framework.getParameter('EViewInstallationFolder')
    if isNull(folder):
        logger.reportError('Job parameter - EViewInstallationFolder is empty. Set the path to the EView client installation root and rerun job.')
        return _vector

    appPath = fileMonitor.rebuildPath(folder) + "\\bin\\ev390hostcmd.exe"
    confFolder = fileMonitor.rebuildPath(folder) + "\\conf\\"
    confFiles = None
    try:
        confFiles = fileMonitor.listFilesWindows(confFolder, EViewConfFileNameFilter())
    except:
        logger.reportError('Unable to get EView configuration files from folder: %s' % confFolder)
        return _vector

    # Create zOS & EView agent objects -----------------------------------------
    if isNull(confFiles):
        logger.reportError('Unable to get EView configuration files from folder: %s' % confFolder)
        return _vector
    elif len(confFiles) < 1:
        logger.reportError('Unable to get EView configuration files from folder: %s' % confFolder)
        return _vector
    else:
        for file in confFiles:

            nodeName = file[13:len(file)]   # The name of the configuration file is ev390_config_<NODE_NAME>
            if eview_lib.isNotNull(nodeName):

                #===================================================================
                # connect to each node with configuration and only
                # create EView CI for the ones that connect
                #===================================================================
                ls = eview_lib.EvShell(Framework, nodeName, appPath)
                # Get EView agent version ------------------------------------------
                task = Framework.getParameter('EViewStartedTask')
                if isNull(task):
                    task = 'VP390'
                eviewVersion = ev1_getEviewVersion(ls, task)
                if eview_lib.isNotNull(eviewVersion):
                    logger.debug('Successfully executed command against EView agent on node: ', nodeName)

                    # Get IPL info -------------------------------------------------
                    (zOsRelease, ieasymList, ieasysList, machineBootDate) = ev2_getIplInfoOutput(ls)
                    
                    # Spencer: Get memory info -------------------------------------
                    memory = ev6_getMemoryOutput(ls)

                    # Get the default IP of the LPAR -------------------------------
                    defaultIp = ev_getDefaultIpOfLpar(ls)

                    if isNull(defaultIp):
                        logger.reportWarning('Unable to get IP Address of LPAR: %s. Continuing with next LPAR.' % nodeName)
                        continue
                    else:
                        # Get Symbols --------------------------------------------------
                        symbolsMap = ev5_getSymlistOutput(ls)   # {symbolName:symbolValue}
                        
                        # CPU List Command ---------------------------------------------------------
                        (cpuLists, cpcSi, cpcId, cpcName) = ev7_getCpulistOutput(ls)
                        
                        # Create zOS OSH ---------------------------------
                        zOsOsh = osh_createZOsOsh(defaultIp, zOsRelease, ieasymList, ieasysList, machineBootDate, symbolsMap, memory, cpcSi)
                        _vector.add(zOsOsh)

                        if isNotNull(zOsOsh):
                            # Create IP OSH and link it to zOS OSH -------------------------
                            _vector.addAll(osh_createIpOsh(zOsOsh, defaultIp))

                            # Create EView Agent OSH and link it to the zOS OSH ------------
                            eviewOSH = osh_createEviewOsh(localshell, zOsOsh, appPath, confFolder, file, nodeName, eviewVersion, defaultIp)
                            _vector.add(eviewOSH)
                else:
                    warnMsg = 'Unable to connect to: %s' % nodeName
                    logger.warn(warnMsg)
                    warnObj = errorobject.createError(errorcodes.CONNECTION_FAILED, None, warnMsg)
                    logger.reportWarningObject(warnObj)

    return _vector
Esempio n. 5
0
def getCICSPrograms(ls,  regiondict , subsystemOSH, excluderestricted, Framework):

## Sample output:
#    
# LIST:DFH$IVPL
# LIST:DFHLIST
# LIST:XYZLIST
# LIST:ZORPHEN
# GROUP:CEE:DFH$IVPL:DFHLIST:XYZLIST
# GROUP:CICSLOGS:XYZLIST
# GROUP:DFHCBTS:DFH$IVPL:DFHLIST:XYZLIST
# GROUP:DFHDCTG:DFH$IVPL:DFHLIST:XYZLIST
# GROUP:DFHIPECI:DFH$IVPL:DFHLIST:XYZLIST
# GROUP:EVOGRP:XYZLIST
# GROUP:SOCKETS:XYZLIST
# GROUP:USERCONS:XYZLIST
# PGM:CALLOPC:   :ASSEMBLER:NO:NO:ENABLED:EVOGRP
# PGM:CALLOPCR:   :   :NO:NO:ENABLED:EVOGRP
# PGM:CEECBLDY:   :   :NO:NO:ENABLED:CEE
# PGM:CEECCICS:   :   :NO:NO:ENABLED:CEE
# PGM:CEECRHP:   :   :NO:NO:ENABLED:CEE
# PGM:CEECZST:   :   :NO:NO:ENABLED:CEE  
# TRN:CIEP:ECI OVER TCP/IP INTERFACE STARTED BY SO DOMAIN:DFHIEP:DFHCICST:ENABLED:NO::DFHTCL00:NO:NO:DFHIPECI
# TRN:EZAP:DISABLE SOCKETS INTERFACE:EZACIC22:DFHCICST:ENABLED:YES::DFHTCL00:NO:NO:SOCKETS
  
#######################################################
    
    # Query the mainframe for CICS Programs and Transactions
    str_name = 'name'
    if UCMDB_VERSION < 9:
        str_name = 'data_name'
    for region in regiondict.keys():
        cicslistdict = {}
        cicsgroupdict = {}
        cicspgmdict = {}
        vector = ObjectStateHolderVector() 
             
        regionwithoption  =  concatenate(region,'-',excluderestricted)
        # check if ev390cicstrans.pl script exists
        output = None
        scriptAbsolutePath = '%sev390cicstrans.pl' % ls.ar
        if ls.evFileExists(scriptAbsolutePath):
            output = ls.evGetCicsTran(regionwithoption)
        else:
            output = ls.evSysInfoCmd(regionwithoption, '12', 'EVOCICST' )
        if not isNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0:         
            for line in  output.cmdResponseList:
                # Skip the CICS systems that are not up
                m = re.search('IEE341I', line)
                if (m):               
                    break               
                splitline = line.split(':')             
                # Look for all the CICS Lists and build OSHs for them
                if splitline[0] == 'LIST':
                    cicsListOSH = ObjectStateHolder('cics_list') 
                    cicsListOSH.setAttribute(str_name, splitline[1] )  
                    cicsListOSH.setContainer(regiondict[region])
                    vector.add (cicsListOSH)                  
                    if not(cicslistdict.has_key(splitline[1])): 
                        cicslistdict[splitline[1]] = cicsListOSH
                # Look for the CICS Groups and build OSHs for them
                elif splitline[0] == 'GROUP':
                    cicsGroupOSH = ObjectStateHolder('cics_group')                    
                    cicsGroupOSH.setAttribute(str_name, splitline[1] )
                    cicsGroupOSH.setContainer(regiondict[region])
                    vector.add (cicsGroupOSH)
                    i = 2 
                    while i < len(splitline):                   
                        cicsListOSH = ObjectStateHolder('cics_list') 
                        cicsListOSH.setAttribute(str_name, splitline[i] )  
                        cicsListOSH.setContainer(regiondict[region])
                        vector.add (cicsListOSH)                        
                        if not(cicslistdict.has_key(splitline[i])):  
                            cicslistdict[splitline[i]] = cicsListOSH
                        vector.add (modeling.createLinkOSH('containment', cicslistdict[splitline[i]], cicsGroupOSH))
                        i = i + 1
                # Look for the CICS Programs 
                elif splitline[0] == 'PGM':
                    cicsProgramOSH = ObjectStateHolder('cics_program')
                    cicsProgramOSH.setAttribute(str_name, splitline[1]) 
                    cicsProgramOSH.setAttribute('description', splitline[2])      
                    cicsProgramOSH.setAttribute('pgm_language', splitline[3]) 
                    cicsProgramOSH.setAttribute('pgm_reload', splitline[4])  
                    cicsProgramOSH.setAttribute('pgm_resident', splitline[5])  
                    cicsProgramOSH.setAttribute('pgm_status', splitline[6])             
                    cicsProgramOSH.setContainer(regiondict[region]) 
                    vector.add (cicsProgramOSH )
                    if not(cicspgmdict.has_key(splitline[1])):  
                            cicspgmdict[splitline[1]] = cicsProgramOSH 
                    i = 7 
                    while i < len(splitline):                   
                        cicsGroupOSH = ObjectStateHolder('cics_group') 
                        cicsGroupOSH.setAttribute(str_name, splitline[i] )  
                        cicsGroupOSH.setContainer(regiondict[region])
                        vector.add (cicsGroupOSH)                     
                        if not(cicsgroupdict.has_key(splitline[i])):  
                            cicsgroupdict[splitline[i]] = cicsGroupOSH
                        vector.add (modeling.createLinkOSH('containment', cicsgroupdict[splitline[i]],  cicsProgramOSH))
                        i = i + 1
                # Look for the CICS Transactions
                elif splitline[0] == 'TRN':
                    cicsTransactionOSH = ObjectStateHolder('cics_transaction')                  
                    cicsTransactionOSH.setAttribute(str_name, splitline[1]) 
                    cicsTransactionOSH.setAttribute('description', splitline[2])      
                    cicsTransactionOSH.setAttribute('trans_status', splitline[5]) 
                    cicsTransactionOSH.setAttribute('trans_protected', splitline[6])  
                    cicsTransactionOSH.setAttribute('trans_class', splitline[8])  
                    cicsTransactionOSH.setAttribute('resource_security', splitline[9]) 
                    cicsTransactionOSH.setAttribute('command_security', splitline[10])             
                    cicsTransactionOSH.setContainer(regiondict[region]) 
                    vector.add (cicsTransactionOSH)
                    i = 11 
                    while i < len(splitline):                   
                        cicsGroupOSH = ObjectStateHolder('cics_group') 
                        cicsGroupOSH.setAttribute(str_name, splitline[i] )  
                        cicsGroupOSH.setContainer(regiondict[region])
                        vector.add (cicsGroupOSH)                     
                        if not(cicsgroupdict.has_key(splitline[i])):  
                            cicsgroupdict[splitline[i]] = cicsGroupOSH
                        vector.add (modeling.createLinkOSH('containment', cicsgroupdict[splitline[i]],  cicsTransactionOSH))
                        i = i + 1
                    if cicspgmdict.has_key(splitline[3]):   
                        vector.add (modeling.createLinkOSH('usage',  cicsTransactionOSH, cicspgmdict[splitline[3]]))
        Framework.sendObjects(vector)
        Framework.flushObjects()
        vector.clear()
        vector = None

    return
Esempio n. 6
0
def ev4_dataSharingGroupsOutput(ls, cmd_prefix):
    if isNull(cmd_prefix):
        return []
    dsgs = []
    cmd_prefix = string.replace(cmd_prefix, '.', '..')
    output = ls.evMvsCmd(_CMD_PREFIX_DISPLAY_GROUP % cmd_prefix)
    if output.isSuccess() and len(output.cmdResponseList) > 0:
        dsg = Dsg()
        # first get the data sharing group info ------------------------------------
        # first try version 9/10 format -------------------------------------------
        dsgInfo1 = output.getValuesFromLineList('s', output.cmdResponseList,
                                                'DISPLAY OF GROUP\(',
                                                '\).+LEVEL\(', '\) MODE\(',
                                                '\)')
        if isNotNull(dsgInfo1) and len(dsgInfo1) > 0 and isNotNull(
                dsgInfo1[0]) and len(dsgInfo1[0]) == 5:
            if isNotNull(dsgInfo1[0][1]) and string.find(
                    dsgInfo1[0][1], '.......') < 0:
                dsg.name = dsgInfo1[0][1]
                dsg.level = dsgInfo1[0][2]
                dsg.mode = dsgInfo1[0][3]
        else:
            # try version 8 format ---------------------------------------------
            dsgInfo2 = output.getValuesFromLineList('s',
                                                    output.cmdResponseList,
                                                    'DISPLAY OF GROUP\(',
                                                    '\) GROUP LEVEL\(', '\)')
            if isNotNull(dsgInfo2) and len(dsgInfo2) > 0 and isNotNull(
                    dsgInfo2[0]) and len(dsgInfo2[0]) == 4:
                if isNotNull(dsgInfo2[0][1]) and dsgInfo2[0][1] != '.......':
                    dsg.name = dsgInfo2[0][1]
                    dsg.level = dsgInfo2[0][2]

        if isNull(dsg.name):
            logger.warn("No Data sharing group found")
        else:
            # next get more information about the DSG --------------------------
            dsgInfo3 = output.getValuesFromLineList(
                's', output.cmdResponseList, 'PROTOCOL LEVEL\(',
                '\)\s+GROUP ATTACH NAME\(', '\)')
            if isNotNull(dsgInfo3) and len(dsgInfo3) > 0 and isNotNull(
                    dsgInfo3[0]) and len(dsgInfo3[0]) == 4:
                dsg.protocolLevel = dsgInfo3[0][1]
                dsg.attachName = dsgInfo3[0][2]

            # next get the DSG member info -------------------------------------
            headerColumns = [
                'MEMBER', 'ID', 'SUBSYS', 'CMDPREF', 'STATUS', 'LVL', 'NAME',
                'SUBSYS', 'IRLMPROC'
            ]
            tableBeginPattern = 'DB2 SYSTEM'
            tableEndPattern = '----------------------------'
            firstColumnPaddingChar = ''
            includeRegexPattern = ''
            ignorePatterns = ['------']
            aliasTable = output.getTableValues(
                output.cmdResponseList, headerColumns, tableBeginPattern,
                tableEndPattern, firstColumnPaddingChar, includeRegexPattern,
                ignorePatterns)
            if isNotNull(aliasTable) and len(aliasTable) > 0:
                for i in range(1, len(aliasTable)):
                    if len(aliasTable[i]) == 9:
                        if isNotNull(aliasTable[i][0]) and string.find(
                                aliasTable[i][0], '.......') < 0:
                            dsgMember = DsgMember()
                            dsgMember.db2Member = aliasTable[i][0]
                            dsgMember.id = aliasTable[i][1]
                            dsgMember.subsys = aliasTable[i][2]
                            dsgMember.cmdPref = aliasTable[i][3]
                            dsgMember.status = aliasTable[i][4]
                            dsgMember.db2Level = aliasTable[i][5]
                            dsgMember.systemName = aliasTable[i][6]
                            dsgMember.irlmSubsys = aliasTable[i][7]
                            dsgMember.irlmProc = aliasTable[i][8]
                            dsg.members.append(dsgMember)
        dsgs.append(dsg)
    return dsgs
Esempio n. 7
0
def ev2_ddfOutput(ls, cmd_prefix):
    if isNull(cmd_prefix):
        return []
    ddfObjs = []
    cmd_prefix = string.replace(cmd_prefix, '.', '..')
    output = ls.evMvsCmd(_CMD_PREFIX_DISPLAY_DDF % cmd_prefix)
    if output.isSuccess() and len(output.cmdResponseList) > 0:
        ddfObj = Ddf()
        # status ---------------------------------------------------------------
        statusTemp = output.getValuesFromLineList('s', output.cmdResponseList,
                                                  'STATUS=')
        if isNotNull(statusTemp) and len(statusTemp) == 1 and isNotNull(
                statusTemp[0][1]):
            ddfObj.status = statusTemp[0][1]

        # remove first 9 characters from every line for processing table columns
        tableList = []
        for line in output.cmdResponseList:
            if isNotNull(line) and len(line) >= 9:
                tempLine = line[9:len(line)]
                if isNotNull(tempLine):
                    tableList.append(tempLine)

        # location info --------------------------------------------------------
        for i in range(len(output.cmdResponseList)):
            m = re.match('.*LOCATION\s+LUNAME\s+GENERICLU.*',
                         output.cmdResponseList[i])
            if isNotNull(m):
                locationLine = output.cmdResponseList[i + 1]
                locationLine = locationLine[9:len(locationLine)]
                location = output.getValuesFromLine('i', locationLine, '\s+',
                                                    '\.', '\s+')
                if len(location) == 4:
                    ddfObj.locationName = location[0]
                    ddfObj.locationLuName = '%s.%s' % (location[1],
                                                       location[2])
                    ddfObj.locationGenericLuName = location[3]
                    continue

        # Alias info -----------------------------------------------------------
        # first try for version 9 headers --------------------------------------
        headerColumns = ['ALIAS', 'PORT', 'SECPORT']
        tableBeginPattern = 'DOMAIN='
        tableEndPattern = 'MEMBER IPADDR'
        firstColumnPaddingChar = ''
        includeRegexPattern = ''
        ignorePatterns = []
        aliasTable = output.getTableValues(tableList, headerColumns,
                                           tableBeginPattern, tableEndPattern,
                                           firstColumnPaddingChar,
                                           includeRegexPattern, ignorePatterns)
        if isNotNull(aliasTable) and len(aliasTable) > 0:
            headerFound = 0
            for i in range(0, len(aliasTable)):
                if len(aliasTable[i]) == 3 and isNotNull(aliasTable[i][0]):
                    if aliasTable[i][0] != 'ALIAS' and not headerFound:
                        continue
                    if aliasTable[i][0] == 'ALIAS':
                        headerFound = 1
                        continue
                    if aliasTable[i][0][0:8] != 'DSNLTDDF':
                        ddfAliasObj = DdfAlias()
                        ddfAliasObj.aliasName = aliasTable[i][0]
                        ddfAliasObj.aliasPort = aliasTable[i][1]
                        ddfObj.ddfAlias.append(ddfAliasObj)
        # if return is empty look for version 8 headers ------------------------
        else:
            headerColumns = ['ALIAS', 'PORT']
            aliasTable = output.getTableValues(
                tableList, headerColumns, tableBeginPattern, tableEndPattern,
                firstColumnPaddingChar, includeRegexPattern, ignorePatterns)
            if isNotNull(aliasTable) and len(aliasTable) > 0:
                headerFound = 0
                for i in range(1, len(aliasTable)):
                    if len(aliasTable[i]) == 2 and isNotNull(aliasTable[i][0]):
                        if aliasTable[i][0] != 'ALIAS' and not headerFound:
                            continue
                        if aliasTable[i][0] == 'ALIAS':
                            headerFound = 1
                            continue
                        if aliasTable[i][0][0:8] != 'DSNLTDDF':
                            ddfAliasObj = DdfAlias()
                            ddfAliasObj.aliasName = aliasTable[i][0]
                            ddfAliasObj.aliasPort = aliasTable[i][1]
                            ddfObj.ddfAlias.append(ddfAliasObj)

        # IP info --------------------------------------------------------------
        # first try the DB2 version 8 format -----------------------------------
        for i in range(len(output.cmdResponseList)):
            m = re.match('.*IPADDR\s+TCPPORT\s+RESPORT.*',
                         output.cmdResponseList[i])
            if isNotNull(m):
                ipLine = output.cmdResponseList[i + 1]
                ipLine = ipLine[9:len(ipLine)]
                ips = output.getRegexedValues(ipLine, '(.*)\s+(\d+)\s+(\d+)')
                if isNotNull(ips) and len(ips) == 3:
                    ddfObj.ipAddress = ips[0]
                    ddfObj.tcpPort = ips[1]
                    continue
        if isNull(ddfObj.ipAddress):
            # try the DB2 version 9 format -------------------------------------
            ipAddrList = output.getValuesFromLineList('s',
                                                      output.cmdResponseList,
                                                      'I IPADDR=')
            if isNotNull(ipAddrList) and len(ipAddrList) > 0 and isNotNull(
                    ipAddrList[0][1]):
                ddfObj.ipAddress = ipAddrList[0][1]

        if isNull(ddfObj.tcpPort):
            # try the DB2 version 9 format -------------------------------------
            tcpList = output.getValuesFromLineList('s', output.cmdResponseList,
                                                   'TCPPORT=', 'SECPORT=')
            if isNotNull(tcpList) and len(tcpList) > 0 and isNotNull(
                    tcpList[0][1]):
                ddfObj.tcpPort = tcpList[0][1]

        # SQL Domain -----------------------------------------------------------
        sqlDomainList = output.getValuesFromLineList('s',
                                                     output.cmdResponseList,
                                                     'SQL', 'DOMAIN=')
        if isNotNull(sqlDomainList) and len(sqlDomainList) > 0 and isNotNull(
                sqlDomainList[0]) and len(sqlDomainList[0]) >= 2:
            ddfObj.sqlDomain = sqlDomainList[0][2]
        ddfObjs.append(ddfObj)
    return ddfObjs