def osh_createDb2Tablespace(db2SubsystemOsh, tb): str_name = 'name' if UCMDB_VERSION < 9: str_name = 'data_name' if isNotNull(tb) and isNotNull(tb[0]): tbOsh = ObjectStateHolder('mainframe_db2_tablespace') tbOsh.setAttribute(str_name, tb[0]) tbOsh.setAttribute('dbtablespace_status', tb[1]) tbOsh.setAttribute('type', tb[2]) tbOsh.setAttribute('encoding_scheme', tb[3]) tbOsh.setAttribute('dbtablespace_initialextent', tb[4]) if isNotNull(tb[5]) and isnumeric(tb[5]): tbOsh.setIntegerAttribute('max_dataset_size', int(tb[5])) if isNotNull(tb[6]) and isnumeric(tb[6]): tbOsh.setIntegerAttribute('number_tables', int(tb[6])) if isNotNull(tb[7]) and isnumeric(tb[7]): tbOsh.setIntegerAttribute('number_partitions', int(tb[7])) try: if len(tb[8]) > 19: tb[8] = tb[8][0:18] created = modeling.getDateFromString(tb[8], 'yyyy-MM-dd-kk.mm.ss', None) tbOsh.setDateAttribute('create_date', created) except: logger.debug("Ignoring create_date. Unable to parse date string") tbOsh.setContainer(db2SubsystemOsh) return tbOsh return None
def osh_createEviewOsh(localshell, zOsOsh, appPath, confFolder, file, nodeName, eviewVersion, defaultIp): # Create EView agent OSH --------------------------------------------------- logger.debug('Creating EView object') eviewOSH = ObjectStateHolder('eview') if _CMDB_CLASS_MODEL.version() >= 9: eviewOSH.setAttribute('name', nodeName) eviewOSH.setAttribute('discovered_product_name', nodeName) eviewOSH.setAttribute('version', eviewVersion) else: eviewOSH.setAttribute('data_name', nodeName) eviewOSH.setAttribute('application_version', eviewVersion) eviewOSH.setAttribute('application_path', appPath) eviewOSH.setAttribute('application_ip', defaultIp) eviewOSH.setAttribute('vendor', 'EView Technology Inc.') eviewOSH.setAttribute('eview_agent_type', 'z/OS') fileContents = localshell.safecat('%s%s' % (confFolder, file)) address, port = eview_lib.getEviewAgentAddress(localshell, fileContents) if eview_lib.isNotNull(address): eviewOSH.setAttribute('application_ip', address) if eview_lib.isNotNull(port) and eview_lib.isnumeric(port): eviewOSH.setIntegerAttribute('application_port', int(port)) eviewOSH.setContainer(zOsOsh) return eviewOSH
def osh_createDdfOsh(db2SubsystemOsh, ddfObj): str_name = 'name' if UCMDB_VERSION < 9: str_name = 'data_name' _vector = ObjectStateHolderVector() if isNotNull(ddfObj.locationName): ddfOsh = ObjectStateHolder('db2_ddf') ddfOsh.setAttribute(str_name, ddfObj.locationName) ddfOsh.setAttribute('ddf_status', ddfObj.status) ddfOsh.setAttribute('ddf_luname', ddfObj.locationLuName) ddfOsh.setAttribute('ddf_generic_luname', ddfObj.locationGenericLuName) ddfOsh.setAttribute('ddf_ip_address', ddfObj.ipAddress) if isNotNull(ddfObj.ipAddress) and isnumeric(ddfObj.ipAddress): ddfOsh.setAttribute('ddf_tcp_port', int(ddfObj.tcpPort)) ddfOsh.setAttribute('ddf_sql_domain', ddfObj.sqlDomain) ddfOsh.setContainer(db2SubsystemOsh) _vector.add(ddfOsh) for alias in ddfObj.ddfAlias: ddfAliasOsh = ObjectStateHolder('db2_ddf_alias') ddfAliasOsh.setAttribute(str_name, alias.aliasName) if isNotNull(alias.aliasPort) and isnumeric(alias.aliasPort): ddfAliasOsh.setIntegerAttribute('ddf_alias_port', int(alias.aliasPort)) ddfAliasOsh.setContainer(ddfOsh) _vector.add(ddfAliasOsh) return _vector
def ev2_getIplInfoOutput(ls): # process IPL Info --------------------------------------------------------- zOsRelease = '' ieasymList = '' ieasysList = '' machineBootDate = '' try: output = ls.evMvsCmd(_CMD_D_IPLINFO) if isNotNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0: releaseList = output.getValuesFromLineList('s', output.cmdResponseList, 'RELEASE z/OS', 'LICENSE') if len(releaseList) > 0 and len(releaseList[0]) == 3: zOsRelease = releaseList[0][1] or '' ieasymList = output.getValuesFromLineList('s', output.cmdResponseList, 'IEASYM LIST =') if len(ieasymList) > 0 and len(ieasymList[0]) == 2: ieasymList = ieasymList[0][1] or '' ieasysList = output.getValuesFromLineList('s', output.cmdResponseList, 'IEASYS LIST =') if len(ieasymList) > 0 and len(ieasymList[0]) == 2: ieasysList = ieasysList[0][1] or '' bootList = output.getValuesFromLineList('s', output.cmdResponseList, 'SYSTEM IPLED AT', 'ON') if len(bootList) > 0 and len(bootList[0]) == 2: bootTime = bootList[0][1] or '' bootDate = bootList[0][2] or '' if eview_lib.isNotNull(bootDate) and eview_lib.isNotNull(bootTime): machineBootDate = modeling.getDateFromString('%s %s' % (bootDate, bootTime), 'MM/dd/yyyy kk.mm.ss') else: logger.reportWarning('Unable to get output for command - %s' % _CMD_D_IPLINFO) except: errMsg = 'Failure in method ev2_getIplInfoOutput()' logger.error(errMsg) logger.reportError(errMsg) return (zOsRelease, ieasymList, ieasysList, machineBootDate)
def addInfoOnRegions(ls, cicsRegionOSH): str_name = 'name' if UCMDB_VERSION < 9: str_name = 'data_name' name = cicsRegionOSH.getAttributeValue(str_name) if isNotNull(name): command = concatenate(_CMD_F_CEMT_I_SYSTEM % name) output = ls.evMvsCmd(command) if output.isSuccess() and len(output.cmdResponseList) > 0: dataList = output.getValuesFromLineList('s', output.cmdResponseList, '\(', '\)') for values in dataList: if isNotNull(values) and isNotNull(values[0]) and isNotNull(values[1]): values[0] = string.replace(values[0], '+', '') values[0] = string.lower(string.strip(values[0])) attributeName = 'cicsregion_%s' % values[0] attributeValue = string.strip(values[1]) strValue = 1 for att in __INT_ATTRIBUTES: if values[0].find(att) >= 0: strValue = 0 modeling.__setAttributeIfExists(cicsRegionOSH, attributeName, attributeValue, AppilogTypes.INTEGER_DEF) continue for att in __LONG_ATTRIBUTES: if values[0].find(att) >= 0: strValue = 0 modeling.__setAttributeIfExists(cicsRegionOSH, attributeName, attributeValue, AppilogTypes.LONG_DEF) continue if strValue: modeling.__setAttributeIfExists(cicsRegionOSH, attributeName, attributeValue) return
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
def ev6_tableSpacesByDsnRexxOutput(ls, db2SubsystemName): tbs = [] # [name, status, type, encoding, pgSize, dsSize, nTables, nPartitions, created] tbsDict = {} # {name:[name, status, type, encoding, pgSize, dsSize, nTables, nPartitions, created]} output = ls.evExecDb2Query(db2SubsystemName, _QRY_TABLESPACES) if output.isSuccess() and len(output.cmdResponseList) > 0: tbs = output.getDb2ValuesForColumns('NAME', 'STATUS', 'TYPE', 'ENCODING_SCHEME', 'PGSIZE', 'DSSIZE', 'NTABLES', 'PARTITIONS', 'CREATEDTS') for tb in tbs: if isNotNull(tb) and isNotNull(tb[0]): tbsDict[tb[0]] = tb return tbsDict
def osh_createDb2Schema(db2SubsystemOsh, db): str_name = 'name' if UCMDB_VERSION < 9: str_name = 'data_name' if isNotNull(db) and isNotNull(db[0]): db2DbOsh = ObjectStateHolder('mainframe_db2_database') db2DbOsh.setAttribute(str_name, db[0]) db2DbOsh.setAttribute('creator', db[1]) db2DbOsh.setAttribute('stgroup', db[2]) db2DbOsh.setAttribute('encoding_scheme', db[3]) db2DbOsh.setAttribute('createdate', db[4]) db2DbOsh.setContainer(db2SubsystemOsh) return db2DbOsh
def getCICSRegions(ls, subsystemOSH): regiondict = {} str_name = 'name' if UCMDB_VERSION < 9: str_name = 'data_name' vector = ObjectStateHolderVector() # Get the active jobs running on the lpar # Look for the program name , if it is DFHSIP then we have found an active CICS job # The job name is the CICS region output = ls.evSysInfoCmd(_CMD_F_ALL_JOBS,'40') if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: if isNotNull(line): splitline = line.split('|') if len(splitline) == 10: if splitline[9] == 'DFHSIP': region = splitline[0].strip() #logger.debug ('Found region ===> ',region) cicsRegionOSH = ObjectStateHolder('cics_region') cicsRegionOSH.setAttribute(str_name, region) cicsRegionOSH.setContainer(subsystemOSH) addInfoOnRegions(ls, cicsRegionOSH) if not(regiondict.has_key(region)): regiondict[region] = cicsRegionOSH vector.add(cicsRegionOSH) return vector, regiondict
def ev4_getHomelistOutput(ls, tcpStack): # process HOMELIST --------------------------------------------------------- homeLists = [] # [ADDRESS, LINK, FLG] linkList = [] addrList = [] flgList = [] try: output = ls.evMvsCmd(_CMD_D_NETSTAT_HOME % tcpStack) if isNotNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0: linkList = output.getValuesFromLineList('s', output.cmdResponseList, 'LINKNAME:') addrList = output.getValuesFromLineList('s', output.cmdResponseList, 'ADDRESS:') flgList = output.getValuesFromLineList('s', output.cmdResponseList, 'FLAGS:') if len(linkList) > 0: for i in range(0, len(linkList)): linkname = linkList[i][1] address = addrList[i][1] if address == '127.0.0.1': continue flag = flgList[i][1] tempList = [linkname,address,flag] homeLists.append(tempList) except: errMsg = 'Failure in method ev4_getHomelistOutput()' logger.error(errMsg) logger.reportError(errMsg) return homeLists
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() logger.info ("Starting IMS Discovery") DiscoverIMSDB = Boolean.parseBoolean(Framework.getParameter('DiscoverIMSDB')) # create LPAR node from the ID passed in hostId = Framework.getDestinationAttribute(PARAM_HOST_ID) lparOsh = None if eview_lib.isNotNull(hostId): lparOsh = modeling.createOshByCmdbIdString('host_node', hostId) ls = eview_lib.EvShell(Framework) IMSSubSysDict = getIMSSubSys(ls, lparOsh) OSHVResult.addAll(getIMSActRegions(ls,lparOsh, IMSSubSysDict )) if DiscoverIMSDB and len(IMSSubSysDict) > 0: databaseAreaDictionary = {} databaseDictionary = {} OSHVResult.addAll(getIMSDB(ls, IMSSubSysDict, databaseAreaDictionary , databaseDictionary)) OSHVResult.addAll(getAREAs(ls, IMSSubSysDict, databaseAreaDictionary , databaseDictionary)) OSHVResult.addAll(processPrograms(ls,IMSSubSysDict, Framework)) ls.closeClient() logger.info ("Finished IMS Discovery") return OSHVResult
def ev6_tableSpacesByDsnRexxOutput(ls, db2SubsystemName): tbs = [ ] # [name, status, type, encoding, pgSize, dsSize, nTables, nPartitions, created] tbsDict = { } # {name:[name, status, type, encoding, pgSize, dsSize, nTables, nPartitions, created]} output = ls.evExecDb2Query(db2SubsystemName, _QRY_TABLESPACES) if output.isSuccess() and len(output.cmdResponseList) > 0: tbs = output.getDb2ValuesForColumns('NAME', 'STATUS', 'TYPE', 'ENCODING_SCHEME', 'PGSIZE', 'DSSIZE', 'NTABLES', 'PARTITIONS', 'CREATEDTS') for tb in tbs: if isNotNull(tb) and isNotNull(tb[0]): tbsDict[tb[0]] = tb return tbsDict
def osh_createZOsOsh(defaultIp, zOsRelease, ieasymList, ieasysList, machineBootDate, symbolsMap, memory, cpcSi): # Create LPAR OSH ---------------------------------- # version 9.0+ attributes -------------------------------------------------- str_discovered_os_name = 'discovered_os_name' str_discovered_os_version = 'discovered_os_version' str_vendor = 'vendor' str_os_vendor = 'os_vendor' str_name = 'name' str_serial_number = 'serial_number' # version 8.0- attributes -------------------------------------------------- if _CMDB_CLASS_MODEL.version() < 9: str_discovered_os_name = 'host_os' str_discovered_os_version = 'host_osversion' str_vendor = 'host_vendor' str_os_vendor = 'host_vendor' # duplicated str_name = 'data_name' str_serial_number = 'host_serialnumber' isComplete = 1 zOsOsh = modeling.createHostOSH(defaultIp, 'zos', _STR_EMPTY, _STR_EMPTY, machineBootDate) zOsOsh.setAttribute(str_discovered_os_name, 'z/OS') zOsOsh.setBoolAttribute('host_iscomplete', isComplete) zOsOsh.setAttribute(str_discovered_os_version, zOsRelease) zOsOsh.setAttribute(str_os_vendor, 'IBM') zOsOsh.setAttribute(str_vendor, 'IBM') zOsOsh.setAttribute('ieasym_list', ieasymList) # Spencer: Set memory attribute zOsOsh.setAttribute('memory_size', memory) if isNotNull(cpcSi): cpcSiList = string.split(cpcSi, '.') if len(cpcSiList) == 5: cpcSerial = cpcSiList[4] zOsOsh.setAttribute(str_serial_number,cpcSerial ) if isNotNull(symbolsMap) and len(symbolsMap) > 0: if symbolsMap.has_key('SYSNAME'): zOsOsh.setAttribute(str_name, symbolsMap['SYSNAME']) if symbolsMap.has_key('SYSALVL'): zOsOsh.setAttribute('mvs_architecture_level', symbolsMap['SYSALVL']) if symbolsMap.has_key('SYSCLONE'): zOsOsh.setAttribute('mvs_system_clone', symbolsMap['SYSCLONE']) if symbolsMap.has_key('SYSALVL'): zOsOsh.setAttribute('mvs_system_r1', symbolsMap['SYSR1']) return zOsOsh
def processPrograms(ls, lparOsh, regiondict, subsystemOSH, Framework): vector = ObjectStateHolderVector() discoverPrograms = Framework.getParameter('discover_CICS_programs') if isNotNull(discoverPrograms ) and string.lower(discoverPrograms ) == 'true': discoverPrograms = 1 else: discoverPrograms = 0 if discoverPrograms: excluderestricted = Framework.getParameter('exclude_restricted_programs') if isNotNull(excluderestricted) and string.lower(excluderestricted ) == 'true': excluderestricted = 'Y' else: excluderestricted = 'N' getCICSPrograms(ls, regiondict, subsystemOSH, excluderestricted, Framework) return
def osh_createDsgAndMemberOsh(db2SubsystemName, db2SubsystemOsh, dsg): str_name = 'name' str_membership = 'membership' if UCMDB_VERSION < 9: str_name = 'data_name' str_membership = 'member' _vector = ObjectStateHolderVector() if isNotNull(dsg) and isNotNull(dsg.name): dsgOsh = ObjectStateHolder('db2_datasharing_group') dsgOsh.setAttribute(str_name, dsg.name) dsgOsh.setAttribute('group_attach_name', dsg.attachName) dsgOsh.setAttribute('group_mode', dsg.mode) if isNotNull(dsg.level) and isnumeric(dsg.level): dsgOsh.setIntegerAttribute('group_level', int(dsg.level)) if isNotNull(dsg.protocolLevel) and isnumeric(dsg.protocolLevel): dsgOsh.setIntegerAttribute('group_protocol_level', int(dsg.protocolLevel)) _vector.add(dsgOsh) for member in dsg.members: if isNotNull(member) and isNotNull(member.db2Member) and isNotNull(member.subsys) and upper(member.subsys) == db2SubsystemName: dsgMemberOsh = ObjectStateHolder('db2_datasharing_group_member') dsgMemberOsh.setAttribute(str_name, member.db2Member) dsgMemberOsh.setAttribute('member_id', member.id) dsgMemberOsh.setAttribute('member_level', member.db2Level) dsgMemberOsh.setAttribute('member_status', member.status) dsgMemberOsh.setContainer(db2SubsystemOsh) _vector.add(dsgMemberOsh) # if DSG Member available, make subsystem member of DSB --------s memberLinkOsh = modeling.createLinkOSH(str_membership, dsgOsh, db2SubsystemOsh) _vector.add(memberLinkOsh) return _vector
def ev1_subsystemOutput(ls): db2Subsystems = [] # [name, initrtn, initparm, cmd_prefix] output = ls.evGetSubSysCmd() if output.isSuccess() and len(output.cmdResponseList) > 0: db2InitRoutineRegex = r"DSN\dINI" for line in output.cmdResponseList: if len(line) == 3 and isNotNull(line[1]): m = re.match(db2InitRoutineRegex, line[1], re.IGNORECASE) if isNotNull(m) and isNotNull(line[2]): initParm = string.replace(line[2], "'", "") initParmSplit = string.split(initParm, ",") cmd_prefix = '' if isNotNull(initParmSplit) and len( initParmSplit) > 1 and isNotNull(initParmSplit[1]): cmd_prefix = initParmSplit[1] db2Subsystems.append( [line[0], line[1], initParm, cmd_prefix]) else: if isNotNull(output) and isNotNull( output.errorDump) and output.errorDump.find( 'is not recognized as'): errMsg = 'Perl is required on the probe system path for this command to work. \nPlease install Perl as described in the EView agent documentation and retry this discovery' logger.error(errMsg) logger.reportError(errMsg) return db2Subsystems
def ev5_getSymlistOutput(ls): # process SYMLIST ---------------------------------------------------------- symbolsMap = {} # {name:value} try: output = ls.evMvsCmd(_CMD_D_SYMBOLS) if output.isSuccess() and len(output.cmdResponseList) > 0: symbolsList = output.getValuesFromLineList('s', output.cmdResponseList, '&', '\.\s+=\s+"', '"') for symbols in symbolsList: if len(symbols) == 4: symbolName = symbols[1] symbolValue = symbols[2] if isNotNull(symbolName) and isNotNull(symbolValue): symbolsMap[symbolName] = symbolValue except: errMsg = 'Failure in method ev5_getSymlistOutput()' logger.error(errMsg) logger.reportError(errMsg) return symbolsMap
def ev_getDefaultIpOfLpar(ls): defaultIp = None # Get TCP stacks ----------------------------------------------- tcpStackList = ev3_getTcpStackNameOutput(ls) try: if len(tcpStackList) > 0: for tcpStack in tcpStackList: # Get LPAR default IP address from the first TCP stack - homeLists = ev4_getHomelistOutput(ls, tcpStack) if len(homeLists) > 1 and eview_lib.isNotNull(homeLists[0][1]): defaultIp = homeLists[0][1] for homeListIndex in range(1, len(homeLists)): if homeLists[homeListIndex][2] == 'PRIMARY' and eview_lib.isNotNull(homeLists[homeListIndex][1]): defaultIp = homeLists[homeListIndex][1] except: errMsg = 'Failure in method ev_getDefaultIpOfLpar()' logger.error(errMsg) logger.reportError(errMsg) return defaultIp
def ev3_locationOutput(ls, db2SubsystemName): ##SELECT * FROM SYSIBM..LOCATIONS locations = [] # [name, linkName, port, dbAlias] output = ls.evExecDb2Query(db2SubsystemName, _QRY_LOCATIONS) if output.isSuccess() and len(output.cmdResponseList) > 0: for i in range(1, len(output.cmdResponseList)): if len(output.cmdResponseList[i]) == 4: if isNotNull(output.cmdResponseList[i][0]): locations.append(output.cmdResponseList[i]) return locations
def ev5_databasesByDsnRexxOutput(ls, db2SubsystemName): ## SELECT NAME, CREATOR, ENCODING_SCHEME FROM SYSIBM.SYSDATABASE dbs = [] # [name, creator, encoding] output = ls.evExecDb2Query(db2SubsystemName, _QRY_DATABASE) if output.isSuccess() and len(output.cmdResponseList) > 0: for i in range(1, len(output.cmdResponseList)): if len(output.cmdResponseList[i]) == 5: if isNotNull(output.cmdResponseList[i][0]): dbs.append(output.cmdResponseList[i]) return dbs
def processPrograms(ls,IMSSubSysDict,Framework): _vector = ObjectStateHolderVector() discoverPrograms = Framework.getParameter('discover_ims_programs') if isNotNull(discoverPrograms ) and string.lower(discoverPrograms ) == 'true': discoverPrograms = 1 else: discoverPrograms = 0 if discoverPrograms: _vector = getIMSPrograms(ls, IMSSubSysDict) return _vector
def ev7_getCpulistOutput(ls): cpuLists = [] # [CPU ID, CPU STATUS, CPU SERIAL, CPU RAW STATUS] cpcSi = '' cpcName = '' cpcId = '' lpName = '' lpId = '' output = ls.evMvsCmd(_CMD_D_M_CPU) if output.isSuccess() and len(output.cmdResponseList) > 0: # first search for CPUs ------------------------------------------------ headerColumns = ['ID', 'CPU', 'SERIAL'] tableBeginPattern = 'PROCESSOR STATUS' tableEndPattern = 'CPC ND =' firstColumnPaddingChar = '' includeRegexPattern = '' ignorePatterns = [] cpuTable = output.getTableValues(output.cmdResponseList, headerColumns, tableBeginPattern, tableEndPattern, firstColumnPaddingChar, includeRegexPattern, ignorePatterns) # then search for CPC SI ----------------------------------------------- cpcSiList = output.getValuesFromLineList('s', output.cmdResponseList, 'CPC SI =') if isNotNull(cpcSiList) and len(cpcSiList) > 0 and isNotNull(cpcSiList[0][1]): cpcSi = cpcSiList[0][1] # then search for CPC ID ----------------------------------------------- cpcIdList = output.getValuesFromLineList('s', output.cmdResponseList, 'CPC ID =') if isNotNull(cpcIdList) and len(cpcIdList) > 0 and isNotNull(cpcIdList[0][1]): cpcId = cpcIdList[0][1] # then search for CPC Name --------------------------------------------- cpcNameList = output.getValuesFromLineList('s', output.cmdResponseList, 'CPC NAME =') if isNotNull(cpcNameList) and len(cpcNameList) > 0 and isNotNull(cpcNameList[0][1]): cpcName = cpcNameList[0][1] return (cpuLists, cpcSi, cpcId, cpcName)
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() lparname = None # 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) lparname = Framework.getTriggerCIData('LparName') OSHVResult = processDb2Subsystem(ls, Framework, lparOsh, lparname) ls.closeClient() return OSHVResult
def ev3_getTcpStackNameOutput(ls): # get the running TCP stacks ----------------------------------------- tcpStackList = [] output = ls.evMvsCmd(_CMD_D_TCPIP) try: if isNotNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0: headerColumns = ['COUNT', 'TCPIP NAME', 'VERSION', 'STATUS'] tableBeginPattern = 'EZAOP50I TCPIP STATUS REPORT' tableEndPattern = 'END TCPIP STATUS REPORT' firstColumnPaddingChar = ' ' includeRegexPattern = '' ignorePatterns = ['------'] stacks = output.getTableValues(output.cmdResponseList, headerColumns, tableBeginPattern, tableEndPattern, firstColumnPaddingChar, includeRegexPattern, ignorePatterns) for i in range(1, len(stacks)): if len(stacks[i]) == 4 and eview_lib.isNotNull(stacks[i][1]): tcpStackList.append(stacks[i][1]) else: logger.reportWarning('Unable to get output for command - %s' % _CMD_D_TCPIP) except: errMsg = 'Failure in method ev3_getTcpStackNameOutput()' logger.error(errMsg) logger.reportError(errMsg) return tcpStackList
def ev1_subsystemOutput(ls): db2Subsystems = [] # [name, initrtn, initparm, cmd_prefix] output = ls.evGetSubSysCmd() if output.isSuccess() and len(output.cmdResponseList) > 0: db2InitRoutineRegex = r"DSN\dINI" for line in output.cmdResponseList: if len(line) == 3 and isNotNull(line[1]): m = re.match(db2InitRoutineRegex, line[1], re.IGNORECASE) if isNotNull(m) and isNotNull(line[2]): initParm = string.replace(line[2], "'", "") initParmSplit = string.split(initParm, ",") cmd_prefix = '' if isNotNull(initParmSplit) and len(initParmSplit) > 1 and isNotNull(initParmSplit[1]): cmd_prefix = initParmSplit[1] db2Subsystems.append([line[0], line[1], initParm, cmd_prefix]) else: if isNotNull(output) and isNotNull(output.errorDump) and output.errorDump.find('is not recognized as'): errMsg = 'Perl is required on the probe system path for this command to work. \nPlease install Perl as described in the EView agent documentation and retry this discovery' logger.error(errMsg) logger.reportError(errMsg) return db2Subsystems
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
def getSubSystem(ls, lparOsh): # CICS Subsystems are built if we find a running program called DFHSIP. If so we will build a CICS Subsystem. str_name = 'name' str_discovered_product_name = 'discovered_product_name' if UCMDB_VERSION < 9: str_name = 'data_name' str_discovered_product_name = 'data_name' # duplicated on purpose subsystemOSH = None output = ls.evSysInfoCmd(_CMD_F_ALL_JOBS,'40') if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: if isNotNull(line): splitline = line.split('|') if len(splitline) == 10: if splitline[9] == 'DFHSIP': subsystemOSH = ObjectStateHolder('mainframe_subsystem') subsystemOSH.setAttribute(str_name, 'CICS') subsystemOSH.setAttribute(str_discovered_product_name, 'CICS') subsystemOSH.setAttribute('type', 'CICS') subsystemOSH.setContainer(lparOsh) break return subsystemOSH
def osh_createDsgAndMemberOsh(db2SubsystemName, db2SubsystemOsh, dsg): str_name = 'name' str_membership = 'membership' if UCMDB_VERSION < 9: str_name = 'data_name' str_membership = 'member' _vector = ObjectStateHolderVector() if isNotNull(dsg) and isNotNull(dsg.name): dsgOsh = ObjectStateHolder('db2_datasharing_group') dsgOsh.setAttribute(str_name, dsg.name) dsgOsh.setAttribute('group_attach_name', dsg.attachName) dsgOsh.setAttribute('group_mode', dsg.mode) if isNotNull(dsg.level) and isnumeric(dsg.level): dsgOsh.setIntegerAttribute('group_level', int(dsg.level)) if isNotNull(dsg.protocolLevel) and isnumeric(dsg.protocolLevel): dsgOsh.setIntegerAttribute('group_protocol_level', int(dsg.protocolLevel)) _vector.add(dsgOsh) for member in dsg.members: if isNotNull(member) and isNotNull(member.db2Member) and isNotNull( member.subsys) and upper( member.subsys) == db2SubsystemName: dsgMemberOsh = ObjectStateHolder( 'db2_datasharing_group_member') dsgMemberOsh.setAttribute(str_name, member.db2Member) dsgMemberOsh.setAttribute('member_id', member.id) dsgMemberOsh.setAttribute('member_level', member.db2Level) dsgMemberOsh.setAttribute('member_status', member.status) dsgMemberOsh.setContainer(db2SubsystemOsh) _vector.add(dsgMemberOsh) # if DSG Member available, make subsystem member of DSB --------s memberLinkOsh = modeling.createLinkOSH(str_membership, dsgOsh, db2SubsystemOsh) _vector.add(memberLinkOsh) return _vector
def processDb2Subsystem(ls, Framework, lparOsh, lparname, useDsnRexx = 1): _vector = ObjectStateHolderVector() # get DB2 subsystems ------------------------------------------------------- db2Subsystems = ev1_subsystemOutput(ls) #db2Subsystems = [['DB9G', 'DSN3INI', 'DSN3EPX,-DB9G,S', '-DB9G']] for db2 in db2Subsystems: # Verify that the DB2 is active prior to doing any Discovery db2up = ev7_checksubsysstatus (ls, db2[0] ) if not db2up: logger.warn("DB2 subsystem " + db2[0] + " not active") continue # Verify this DB2 is running on this LPAR. If in a Sysplaex it could be on a differnt LPAR str_name = 'name' str_discovered_product_name = 'discovered_product_name' if UCMDB_VERSION < 9: str_name = 'data_name' str_discovered_product_name = 'data_name' # duplicated on purpose # create DB2 subsystem OSH --------------------------------------------- db2SubsystemOsh = osh_createDb2SubsystemOsh(lparOsh, db2) _vector.add(db2SubsystemOsh) if isNotNull(db2[0]) and isNotNull(db2[3]): name = db2[0] cmd_prefix = db2[3] createDDF = Framework.getParameter('discover_DDF') if isNotNull(createDDF) and string.lower(createDDF) == 'true': ''' get DDF and DDF alias info ''' ddfObjs = ev2_ddfOutput(ls, cmd_prefix) ''' create DDF and alias OSH ''' for ddfObj in ddfObjs: _vector.addAll(osh_createDdfOsh(db2SubsystemOsh, ddfObj)) createLocations = Framework.getParameter('discover_Locations') if isNotNull(createLocations) and string.lower(createLocations) == 'true': ''' get location info ''' locations = ev3_locationOutput(ls, name) ''' create location OSH ''' for location in locations: _vector.add(osh_createLocationOsh(db2SubsystemOsh, location)) createDsgs = Framework.getParameter('discover_DataSharingGroups') if isNotNull(createDsgs) and string.lower(createDsgs) == 'true': ''' get the db2 datasharing groups ''' dsgs = ev4_dataSharingGroupsOutput(ls, cmd_prefix) ''' create DSG and member OSH ''' for dsg in dsgs: _vector.addAll(osh_createDsgAndMemberOsh(name, db2SubsystemOsh, dsg)) createDbs = Framework.getParameter('discover_Databases') if isNotNull(createDbs) and string.lower(createDbs) == 'true': ''' get the mainframe DB2 databases ''' dbs = [] # [name, creator, storageGroup, encoding, created] if useDsnRexx: dbs = ev5_databasesByDsnRexxOutput(ls, name) for db in dbs: db2Osh = osh_createDb2Schema(db2SubsystemOsh, db) if isNotNull(db2Osh): _vector.add(db2Osh) createTbs = Framework.getParameter('discover_Tablespaces') if isNotNull(createTbs) and string.lower(createTbs) == 'true': ''' get the mainframe DB2 table spaces ''' tbs = [] # [name, status, type, encoding, pgSize, dsSize, nTables, nPartitions, created] if useDsnRexx: tbs = ev6_tableSpacesByDsnRexxOutput(ls, name) ''' create tablespace OSH ''' for (tbName, tb) in tbs.items(): tbOsh = osh_createDb2Tablespace(db2SubsystemOsh, tb) if isNotNull(tbOsh): _vector.add(tbOsh) return _vector
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
def processDb2Subsystem(ls, Framework, lparOsh, lparname, useDsnRexx=1): _vector = ObjectStateHolderVector() # get DB2 subsystems ------------------------------------------------------- db2Subsystems = ev1_subsystemOutput(ls) #db2Subsystems = [['DB9G', 'DSN3INI', 'DSN3EPX,-DB9G,S', '-DB9G']] for db2 in db2Subsystems: # Verify that the DB2 is active prior to doing any Discovery db2up = ev7_checksubsysstatus(ls, db2[0]) if not db2up: logger.warn("DB2 subsystem " + db2[0] + " not active") continue # Verify this DB2 is running on this LPAR. If in a Sysplaex it could be on a differnt LPAR str_name = 'name' str_discovered_product_name = 'discovered_product_name' if UCMDB_VERSION < 9: str_name = 'data_name' str_discovered_product_name = 'data_name' # duplicated on purpose # create DB2 subsystem OSH --------------------------------------------- db2SubsystemOsh = osh_createDb2SubsystemOsh(lparOsh, db2) _vector.add(db2SubsystemOsh) if isNotNull(db2[0]) and isNotNull(db2[3]): name = db2[0] cmd_prefix = db2[3] createDDF = Framework.getParameter('discover_DDF') if isNotNull(createDDF) and string.lower(createDDF) == 'true': ''' get DDF and DDF alias info ''' ddfObjs = ev2_ddfOutput(ls, cmd_prefix) ''' create DDF and alias OSH ''' for ddfObj in ddfObjs: _vector.addAll(osh_createDdfOsh(db2SubsystemOsh, ddfObj)) createLocations = Framework.getParameter('discover_Locations') if isNotNull(createLocations) and string.lower( createLocations) == 'true': ''' get location info ''' locations = ev3_locationOutput(ls, name) ''' create location OSH ''' for location in locations: _vector.add( osh_createLocationOsh(db2SubsystemOsh, location)) createDsgs = Framework.getParameter('discover_DataSharingGroups') if isNotNull(createDsgs) and string.lower(createDsgs) == 'true': ''' get the db2 datasharing groups ''' dsgs = ev4_dataSharingGroupsOutput(ls, cmd_prefix) ''' create DSG and member OSH ''' for dsg in dsgs: _vector.addAll( osh_createDsgAndMemberOsh(name, db2SubsystemOsh, dsg)) createDbs = Framework.getParameter('discover_Databases') if isNotNull(createDbs) and string.lower(createDbs) == 'true': ''' get the mainframe DB2 databases ''' dbs = [] # [name, creator, storageGroup, encoding, created] if useDsnRexx: dbs = ev5_databasesByDsnRexxOutput(ls, name) for db in dbs: db2Osh = osh_createDb2Schema(db2SubsystemOsh, db) if isNotNull(db2Osh): _vector.add(db2Osh) createTbs = Framework.getParameter('discover_Tablespaces') if isNotNull(createTbs) and string.lower(createTbs) == 'true': ''' get the mainframe DB2 table spaces ''' tbs = [ ] # [name, status, type, encoding, pgSize, dsSize, nTables, nPartitions, created] if useDsnRexx: tbs = ev6_tableSpacesByDsnRexxOutput(ls, name) ''' create tablespace OSH ''' for (tbName, tb) in tbs.items(): tbOsh = osh_createDb2Tablespace(db2SubsystemOsh, tb) if isNotNull(tbOsh): _vector.add(tbOsh) return _vector
def processConnections(ls, lparOsh, regiondict, subsystemOSH, Framework): vector = ObjectStateHolderVector() # Check each region for CICS to DB2 Connections for region in regiondict.keys(): command = concatenate(_CMD_F_CEMT_I_DB2CONN % region) output = ls.evMvsCmd(command) if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: #logger.debug ('In DB2CONN ===> ',line) # Skip the CICS regions that are not up m = re.search('IEE341I', line) if (m): break # If the connection is not connected then we skip it m = re.search('Connectst\((.+)\)', line) if (m): connected = m.group(1).strip() if connected == 'Notconnected': break # If we find a DB2GroupID then we have a connection using a sysplex to DB2 Sharing Group m = re.search('Db2groupid\((.+)\)',line) if (m): groupid = m.group(1).strip() if isNotNull(groupid): #logger.debug ('Found DB2 Group ID:',groupid) regionOSH = regiondict[region] str_name = 'name' db2sharegroupOSH = ObjectStateHolder('db2_datasharing_group') db2sharegroupOSH.setAttribute(str_name, groupid ) vector.add (db2sharegroupOSH) vector.add (regionOSH) vector.add (modeling.createLinkOSH('usage', regionOSH, db2sharegroupOSH)) # If we find a DB2id then we have a direct connection to a DB2 Subsystem m = re.search('Db2id\((.+)\)',line) if (m): db2id = m.group(1).strip() if isNotNull(db2id): #logger.debug ('Found DB2 ID:',db2id) regionOSH = regiondict[region] str_name = 'name' str_disc_name = 'discovered_product_name' db2subsystemOSH = ObjectStateHolder('mainframe_subsystem') db2subsystemOSH.setAttribute(str_name, db2id ) db2subsystemOSH.setAttribute(str_disc_name, db2id ) db2subsystemOSH.setContainer(lparOsh) vector.add (db2subsystemOSH) vector.add (regionOSH) vector.add (modeling.createLinkOSH('usage', regionOSH, db2subsystemOSH)) # Now Test each region for CICS to MQ Connections for region in regiondict.keys(): # Check the version of CICS to see if it is greater than V4. Inquire MQCONN is only supported on V4 or higher cicsversion = 0 command = concatenate(_CMD_F_CEMT_I_SYSTEM % region) output = ls.evMvsCmd(command) if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: #logger.debug (line) m = re.search('Cicstslevel\((\d\d).+',line) if (m): cicsversion = m.group(1).strip() # Skip the region if we are running CICS version < 4. # MQCONN Command only works on CICS >= 4 if int(cicsversion) < 4: break command = concatenate(_CMD_F_CEMT_I_MQCONN % region) output = ls.evMvsCmd(command) if output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: #logger.debug ('In MQCONN ===> ',line) # Skip the CICS regions that are not up m = re.search('IEE341I', line) if (m): break # If the connection is not connected then we skip it m = re.search('Connectst\((.+)\)', line) if (m): connected = m.group(1).strip() if connected != 'Connected': break # If we find a MQ connected to this region build the link m = re.search('Mqqmgr\((.+)\)',line) if (m): mqmgr = m.group(1).strip() if isNotNull(mqmgr): #logger.debug ('Found MQMGR: ',mqmgr) regionOSH = regiondict[region] str_name = 'name' # Build Websphere MQ OSH for this MQ Mqname = 'IBM WebSphere MQ ' MqOSH = ObjectStateHolder('webspheremq') MqOSH.setAttribute(str_name, Mqname) MqOSH.setAttribute('vendor', 'ibm_corp') MqOSH.setAttribute('application_category', 'Messaging') modeling.setApplicationProductName(MqOSH,'IBM WebSphere MQ') MqOSH.setContainer(lparOsh) vector.add(MqOSH) mqQMGROsh = ObjectStateHolder('mqqueuemanager') mqQMGROsh.setAttribute(str_name, mqmgr) mqQMGROsh.setContainer(MqOSH) vector.add (mqQMGROsh) vector.add (regionOSH) vector.add (modeling.createLinkOSH('usage', regionOSH, mqQMGROsh )) return vector
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
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
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