def osh_createOutQueueOsh(lparOsh, outQueueLists): _vector = ObjectStateHolderVector() str_name = 'name' for queue in outQueueLists: if isNotNull(queue[0]): key = concatenate(queue[0].strip(), queue[1].strip()) outqueueOsh = ObjectStateHolder('iseries_outqueue') outqueueOsh.setAttribute(str_name, key) outqueueOsh.setAttribute('queue_name', queue[0].strip()) outqueueOsh.setAttribute('library_name', queue[1].strip()) outqueueOsh.setAttribute('number_of__files', int(queue[2])) outqueueOsh.setAttribute('writer', queue[3].strip()) outqueueOsh.setAttribute('queue_status', queue[4].strip()) outqueueOsh.setContainer(lparOsh) _vector.add(outqueueOsh) subsystem = queue[3].strip() if isNotNull(subsystem): subsystemOSH = ObjectStateHolder('iseriessubsystem') subsystemOSH.setAttribute(str_name, subsystem) subsystemOSH.setAttribute('discovered_product_name', subsystem) subsystemOSH.setContainer(lparOsh) _vector.add(subsystemOSH) memberOsh = modeling.createLinkOSH('membership', outqueueOsh, subsystemOSH) _vector.add(memberOsh) return _vector
def ev2_getiSeriesOutput(ls): model = '' serialnbr = '' osversion = '' sysname = '' r1 = re.compile('Current system name',re.IGNORECASE) output = ls.evClCmd(_CMD_SYSVAL_QMODEL) if isNotNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0: oslist = output.cmdResponseList[1].split() osversion = oslist[1] modelList = output.getValuesFromLineList('s', output.cmdResponseList, 'QMODEL') model = modelList[0][1].split()[0] else: logger.reportWarning('Unable to get output for command - %s' % _CMD_SYSVAL_QMODEL) output = ls.evClCmd(_CMD_SYSVAL_QSRLNBR) if isNotNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0: serialList = output.getValuesFromLineList('s', output.cmdResponseList, 'QSRLNBR') serialnbr = serialList[0][1].split()[0] else: logger.reportWarning('Unable to get output for command - %s' % _CMD_SYSVAL_QSRLNBR) output = ls.evClCmd(_CMD_DSPNETA) if isNotNull(output) and output.isSuccess() and len(output.cmdResponseList) > 0: for line in output.cmdResponseList: if r1.search(line): m = re.search('.*:\s+(\S+)', line) if (m): sysname = m.group(1) else: logger.reportWarning('Unable to get output for command - %s' % _CMD_DSPNETA) return ( model, serialnbr, osversion, sysname)
def osh_createJobOsh(lparOsh, jobsLists): _vector = ObjectStateHolderVector() str_name = 'name' for job in jobsLists: if isNotNull(job[0]): jobOsh = ObjectStateHolder('iseries_job') jobOsh.setAttribute(str_name, job[0].strip()) jobOsh.setAttribute('owner', job[1]) jobOsh.setAttribute('job_id', int(job[2])) jobOsh.setAttribute('job_int_id', job[3]) jobOsh.setAttribute('job_status', job[4]) jobOsh.setAttribute('job_type', job[5]) jobOsh.setContainer(lparOsh) _vector.add(jobOsh) subsystem = job[6].strip() if isNotNull(subsystem): subsystemOSH = ObjectStateHolder('iseriessubsystem') subsystemOSH.setAttribute(str_name, subsystem) subsystemOSH.setAttribute('discovered_product_name', subsystem) subsystemOSH.setContainer(lparOsh) _vector.add(subsystemOSH) memberOsh = modeling.createLinkOSH('membership', jobOsh, subsystemOSH) _vector.add(memberOsh) return _vector
def osh_createOutQueueOsh(lparOsh, outQueueLists): _vector = ObjectStateHolderVector() str_name = 'name' for queue in outQueueLists: if isNotNull(queue[0]): key = concatenate(queue[0].strip(),queue[1].strip()) outqueueOsh = ObjectStateHolder('iseries_outqueue') outqueueOsh.setAttribute(str_name, key) outqueueOsh.setAttribute('queue_name', queue[0].strip()) outqueueOsh.setAttribute('library_name', queue[1].strip()) outqueueOsh.setAttribute('number_of__files' , int(queue[2])) outqueueOsh.setAttribute('writer', queue[3].strip()) outqueueOsh.setAttribute('queue_status', queue[4].strip()) outqueueOsh.setContainer(lparOsh) _vector.add(outqueueOsh) subsystem = queue[3].strip() if isNotNull(subsystem): subsystemOSH = ObjectStateHolder('iseriessubsystem') subsystemOSH.setAttribute(str_name,subsystem) subsystemOSH.setAttribute('discovered_product_name',subsystem) subsystemOSH.setContainer(lparOsh) _vector.add(subsystemOSH) memberOsh = modeling.createLinkOSH('membership', outqueueOsh, subsystemOSH) _vector.add(memberOsh) return _vector
def osh_createIpOsh(lparOsh, tcpStacks): ipstoexclude = ['127.0.0.1'] # tcpStacks [ip, network, mask, interface name, status, type, mac address]str_name = 'name' str_name = 'name' str_mac_address = 'mac_address' _vector = ObjectStateHolderVector() for mac, tcpentry in tcpStacks.items(): ipAddress = tcpentry[0].strip() if ipAddress not in ipstoexclude: ipOsh = modeling.createIpOSH(ipAddress) probeName = CollectorsParameters.getValue(CollectorsParameters.KEY_COLLECTORS_PROBE_NAME) if isNotNull(probeName): ipOsh.setAttribute('ip_probename', probeName) containedOsh = modeling.createLinkOSH('contained', lparOsh, ipOsh) _vector.add(lparOsh) _vector.add(ipOsh) _vector.add(containedOsh) # create interface ---------------------------------------------------- ifOsh = ObjectStateHolder('interface') interfacename = tcpentry[3].strip() ifOsh.setAttribute(str_name, interfacename) # default the mac address attribute to linkName and update later if MAC found ifOsh.setAttribute(str_mac_address, mac) # if MAC not found for set #linkName as key ifOsh.setContainer(lparOsh) _vector.add(ifOsh) if tcpStacks.has_key(mac): parentLinkOsh = modeling.createLinkOSH('containment', ifOsh, ipOsh) _vector.add(parentLinkOsh) return _vector
def appendToList(originalList, newList): tempList = [] if isNull(originalList): originalList = tempList for val in newList: if isNotNull(val): originalList.append(val) return originalList
def appendToDictionary(originalDict, newDict): dict = {} if isNull(originalDict): originalDict = dict for (x, y) in newDict.items(): if isNotNull(y) and not originalDict.has_key(x): originalDict[x] = y return originalDict
def processiSeriesObjects(ls, lparOsh, Framework): # Process LPAR iSeries Objects _vector = ObjectStateHolderVector() #=========================================================================== # Run commands and create OSHs #=========================================================================== ''' Discover the Active Jobs if the parameter is true''' createJobs = Framework.getParameter('discover_Jobs') if isNotNull(createJobs) and string.lower(createJobs) == 'true': jobslist = ev1_getJobs(ls) #logger.debug (jobslist) _vector.addAll(osh_createJobOsh(lparOsh, jobslist)) ''' Discover the Jobs Queue and Output Queue if the parameter is true''' createQueue = Framework.getParameter('discover_Queue') if isNotNull(createQueue) and string.lower(createQueue) == 'true': jobsqueuelist = ev2_getJobsQueue(ls) #logger.debug (jobsqueuelist) _vector.addAll(osh_createJobQueueOsh(lparOsh, jobsqueuelist)) outqueuelist = ev3_getOutQueue(ls) #logger.debug (outqueuelist) _vector.addAll(osh_createOutQueueOsh(lparOsh, outqueuelist)) ''' Discover the Object Libraries if the parameter is true''' createLib = Framework.getParameter('discover_Library') if isNotNull(createLib) and string.lower(createLib) == 'true': liblist = ev4_getObjLib(ls) #logger.debug (liblist) _vector.addAll(osh_createLibOsh(lparOsh, liblist)) ''' Discover the Object Programs if the parameter is true''' createPgm = Framework.getParameter('discover_Program') if isNotNull(createPgm) and string.lower(createPgm) == 'true': pgmlist = ev5_getObjPgm(ls) #logger.debug (pgmlist) _vector.addAll(osh_createPgmOsh(lparOsh, pgmlist)) return _vector
def osh_createASPOsh(lparOsh, ASPList, DiskList): spDict = {} str_name = 'name' str_storagepool_poolid = 'storagepool_poolid' str_storagepool_mbavailable = 'storagepool_mbavailable' str_storagepool_mbtotal = 'storagepool_mbtotal' str_storagepool_capacitynum = 'storagepool_capacitynum' str_serial_number = 'serial_number' str_logicalvolume_fstype = 'logicalvolume_fstype' str_logicalvolume_id = 'logicalvolume_id' str_logicalvolume_free = 'logicalvolume_free' str_logicalvolume_size = 'logicalvolume_size' _vector = ObjectStateHolderVector() if isNotNull(ASPList): for asp in ASPList: if isNotNull(asp[0]): aspname = ('ASP' + asp[0]) spOsh = ObjectStateHolder('storagepool') spOsh.setAttribute(str_name, aspname) spOsh.setIntegerAttribute(str_storagepool_poolid, int(asp[0])) spOsh.setDoubleAttribute(str_storagepool_mbavailable, asp[3]) spOsh.setDoubleAttribute(str_storagepool_mbtotal, asp[2]) spOsh.setIntegerAttribute(str_storagepool_capacitynum, asp[1]) spOsh.setContainer(lparOsh) spDict[asp[0]] = spOsh _vector.add(spOsh) if isNotNull(DiskList): for disk in DiskList: if isNotNull(disk[0]): aspid = disk[0] diskOsh = ObjectStateHolder('logical_volume') diskOsh.setAttribute(str_name, disk[4]) diskOsh.setAttribute(str_serial_number, disk[3]) diskOsh.setAttribute(str_logicalvolume_fstype, disk[1]) diskOsh.setIntegerAttribute(str_logicalvolume_id, int(disk[5])) diskOsh.setDoubleAttribute(str_logicalvolume_free, disk[7]) diskOsh.setDoubleAttribute(str_logicalvolume_size, disk[6]) diskOsh.setContainer(lparOsh) _vector.add(diskOsh) if spDict.has_key(aspid): memberOsh = modeling.createLinkOSH('membership', spDict[aspid], diskOsh) _vector.add(memberOsh) return _vector
def osh_createASPOsh(lparOsh, ASPList, DiskList): spDict = {} str_name = 'name' str_storagepool_poolid = 'storagepool_poolid' str_storagepool_mbavailable = 'storagepool_mbavailable' str_storagepool_mbtotal = 'storagepool_mbtotal' str_storagepool_capacitynum = 'storagepool_capacitynum' str_serial_number = 'serial_number' str_logicalvolume_fstype = 'logicalvolume_fstype' str_logicalvolume_id = 'logicalvolume_id' str_logicalvolume_free = 'logicalvolume_free' str_logicalvolume_size = 'logicalvolume_size' _vector = ObjectStateHolderVector() if isNotNull(ASPList): for asp in ASPList: if isNotNull(asp[0]): aspname = ('ASP' + asp[0]) spOsh = ObjectStateHolder('storagepool') spOsh.setAttribute(str_name, aspname ) spOsh.setIntegerAttribute(str_storagepool_poolid, int(asp[0])) spOsh.setDoubleAttribute(str_storagepool_mbavailable, asp[3]) spOsh.setDoubleAttribute(str_storagepool_mbtotal, asp[2]) spOsh.setIntegerAttribute(str_storagepool_capacitynum, asp[1]) spOsh.setContainer(lparOsh) spDict[asp[0]] = spOsh _vector.add(spOsh) if isNotNull(DiskList): for disk in DiskList: if isNotNull(disk[0]): aspid = disk[0] diskOsh = ObjectStateHolder('logical_volume') diskOsh.setAttribute(str_name, disk[4]) diskOsh.setAttribute(str_serial_number, disk[3]) diskOsh.setAttribute(str_logicalvolume_fstype, disk[1]) diskOsh.setIntegerAttribute(str_logicalvolume_id, int(disk[5])) diskOsh.setDoubleAttribute(str_logicalvolume_free, disk[7]) diskOsh.setDoubleAttribute(str_logicalvolume_size, disk[6]) diskOsh.setContainer(lparOsh) _vector.add(diskOsh) if spDict.has_key(aspid): memberOsh = modeling.createLinkOSH('membership', spDict[aspid], diskOsh) _vector.add(memberOsh) return _vector
def osh_createSubsystemsOsh(lparOsh, ssiList): # ssi [Name, Library, Max Jobs, Active Jobs, Description] str_name = 'name' str_discovered_product_name = 'discovered_product_name' str_description = 'description' str_actjobs = 'active_jobs' _vector = ObjectStateHolderVector() if isNotNull(ssiList): for ssi in ssiList: if isNotNull(ssi[0]): ssOsh = ObjectStateHolder('iseriessubsystem') ssOsh.setAttribute(str_name, ssi[0].strip()) ssOsh.setAttribute(str_discovered_product_name, ssi[0].strip()) ssOsh.setAttribute(str_description, ssi[4].strip()) ssOsh.setAttribute(str_actjobs, int(ssi[3])) ssOsh.setContainer(lparOsh) _vector.add(ssOsh) return _vector
def osh_createSubsystemsOsh(lparOsh, ssiList): # ssi [Name, Library, Max Jobs, Active Jobs, Description] str_name = 'name' str_discovered_product_name = 'discovered_product_name' str_description = 'description' str_actjobs = 'active_jobs' _vector = ObjectStateHolderVector() if isNotNull(ssiList): for ssi in ssiList: if isNotNull(ssi[0]): ssOsh = ObjectStateHolder('iseriessubsystem') ssOsh.setAttribute(str_name,ssi[0].strip()) ssOsh.setAttribute(str_discovered_product_name ,ssi[0].strip()) ssOsh.setAttribute(str_description,ssi[4].strip()) ssOsh.setAttribute(str_actjobs,int(ssi[3])) ssOsh.setContainer(lparOsh) _vector.add(ssOsh) return _vector
def osh_createEviewOsh(localshell, iSeriesOsh, appPath, confFolder, file, nodeName, eviewVersion, defaultIp): # Create EView agent OSH --------------------------------------------------- logger.debug('Creating EView object') eviewOSH = ObjectStateHolder('eview') eviewOSH.setAttribute('name', nodeName) eviewOSH.setAttribute('discovered_product_name', nodeName) eviewOSH.setAttribute('version', eviewVersion) eviewOSH.setAttribute('application_path', appPath) eviewOSH.setAttribute('application_ip', defaultIp) eviewOSH.setAttribute('vendor', 'EView Technology Inc.') eviewOSH.setAttribute('eview_agent_type','iSeries') fileContents = localshell.safecat('%s%s' % (confFolder, file)) address, port = eview400_lib.getEviewAgentAddress(localshell, fileContents) if eview400_lib.isNotNull(address): eviewOSH.setAttribute('application_ip', address) if eview400_lib.isNotNull(port) and eview400_lib.isnumeric(port): eviewOSH.setIntegerAttribute('application_port', int(port)) eviewOSH.setContainer(iSeriesOsh) return eviewOSH
def osh_createCpuOsh(lparOsh, cpuLists): _vector = ObjectStateHolderVector() for cpu in cpuLists: if isNotNull(cpu[0]): cpuOsh = ObjectStateHolder('cpu') cpuOsh.setAttribute('cpu_id', cpu[0]) cpuOsh.setAttribute('cpu_vendor', 'IBM') cpuOsh.setAttribute('serial_number', cpu[2]) cpuOsh.setAttribute('cpu_type', cpu[1]) cpuOsh.setContainer(lparOsh) _vector.add(cpuOsh) return _vector
def osh_createEviewOsh(localshell, iSeriesOsh, appPath, confFolder, file, nodeName, eviewVersion, defaultIp): # Create EView agent OSH --------------------------------------------------- logger.debug('Creating EView object') eviewOSH = ObjectStateHolder('eview') eviewOSH.setAttribute('name', nodeName) eviewOSH.setAttribute('discovered_product_name', nodeName) eviewOSH.setAttribute('version', eviewVersion) eviewOSH.setAttribute('application_path', appPath) eviewOSH.setAttribute('application_ip', defaultIp) eviewOSH.setAttribute('vendor', 'EView Technology Inc.') eviewOSH.setAttribute('eview_agent_type', 'iSeries') fileContents = localshell.safecat('%s%s' % (confFolder, file)) address, port = eview400_lib.getEviewAgentAddress(localshell, fileContents) if eview400_lib.isNotNull(address): eviewOSH.setAttribute('application_ip', address) if eview400_lib.isNotNull(port) and eview400_lib.isnumeric(port): eviewOSH.setIntegerAttribute('application_port', int(port)) eviewOSH.setContainer(iSeriesOsh) return eviewOSH
def ev2_getiSeriesOutput(ls): model = '' serialnbr = '' osversion = '' sysname = '' r1 = re.compile('Current system name', re.IGNORECASE) output = ls.evClCmd(_CMD_SYSVAL_QMODEL) if isNotNull(output) and output.isSuccess() and len( output.cmdResponseList) > 0: oslist = output.cmdResponseList[1].split() osversion = oslist[1] modelList = output.getValuesFromLineList('s', output.cmdResponseList, 'QMODEL') model = modelList[0][1].split()[0] else: logger.reportWarning('Unable to get output for command - %s' % _CMD_SYSVAL_QMODEL) output = ls.evClCmd(_CMD_SYSVAL_QSRLNBR) if isNotNull(output) and output.isSuccess() and len( output.cmdResponseList) > 0: serialList = output.getValuesFromLineList('s', output.cmdResponseList, 'QSRLNBR') serialnbr = serialList[0][1].split()[0] else: logger.reportWarning('Unable to get output for command - %s' % _CMD_SYSVAL_QSRLNBR) output = ls.evClCmd(_CMD_DSPNETA) if isNotNull(output) and output.isSuccess() and len( output.cmdResponseList) > 0: for line in output.cmdResponseList: if r1.search(line): m = re.search('.*:\s+(\S+)', line) if (m): sysname = m.group(1) else: logger.reportWarning('Unable to get output for command - %s' % _CMD_DSPNETA) return (model, serialnbr, osversion, sysname)
def osh_createJobOsh(lparOsh, jobsLists): _vector = ObjectStateHolderVector() str_name = 'name' for job in jobsLists: if isNotNull(job[0]): jobOsh = ObjectStateHolder('iseries_job') jobOsh.setAttribute(str_name, job[0].strip()) jobOsh.setAttribute('owner', job[1]) jobOsh.setAttribute('job_id', int(job[2])) jobOsh.setAttribute('job_int_id', job[3]) jobOsh.setAttribute('job_status', job[4]) jobOsh.setAttribute('job_type', job[5]) jobOsh.setContainer(lparOsh) _vector.add(jobOsh) subsystem = job[6].strip() if isNotNull(subsystem): subsystemOSH = ObjectStateHolder('iseriessubsystem') subsystemOSH.setAttribute(str_name,subsystem) subsystemOSH.setAttribute('discovered_product_name',subsystem) subsystemOSH.setContainer(lparOsh) _vector.add(subsystemOSH) memberOsh = modeling.createLinkOSH('membership', jobOsh, subsystemOSH) _vector.add(memberOsh) return _vector
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() # create LPAR node hostId = Framework.getDestinationAttribute(PARAM_HOST_ID) lparOsh = None if eview400_lib.isNotNull(hostId): lparOsh = modeling.createOshByCmdbIdString('host_node', hostId) ls = eview400_lib.EvShell(Framework) (iseriesObjectOSHV) = processiSeriesObjects(ls, lparOsh, Framework) OSHVResult.addAll(iseriesObjectOSHV) ls.closeClient() return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() knownPortsConfigFile = Framework.getConfigFile(CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME) # create LPAR node lparName = Framework.getDestinationAttribute(PARAM_LPAR_NAME) hostId = Framework.getDestinationAttribute(PARAM_HOST_ID) lparOsh = None if eview400_lib.isNotNull(hostId): lparOsh = modeling.createOshByCmdbIdString('host_node', hostId) ls = eview400_lib.EvShell(Framework) (hostResourcesOshv) = processiSeriesResources(ls, lparOsh, knownPortsConfigFile, Framework) OSHVResult.addAll(hostResourcesOshv) ls.closeClient() return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() knownPortsConfigFile = Framework.getConfigFile( CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME) # create LPAR node lparName = Framework.getDestinationAttribute(PARAM_LPAR_NAME) hostId = Framework.getDestinationAttribute(PARAM_HOST_ID) lparOsh = None if eview400_lib.isNotNull(hostId): lparOsh = modeling.createOshByCmdbIdString('host_node', hostId) ls = eview400_lib.EvShell(Framework) (hostResourcesOshv) = processiSeriesResources(ls, lparOsh, knownPortsConfigFile, Framework) OSHVResult.addAll(hostResourcesOshv) ls.closeClient() return OSHVResult
def osh_createLibOsh(lparOsh, liblists): _vector = ObjectStateHolderVector() str_name = 'name' for lib in liblists: if isNotNull(lib[0]): key = concatenate(lib[0].strip(), lib[1].strip()) libraryOsh = ObjectStateHolder('iseries_library') libraryOsh.setAttribute(str_name, key) libraryOsh.setAttribute('object_name', lib[0].strip()) libraryOsh.setAttribute('library_name', lib[1].strip()) libraryOsh.setAttribute('type', lib[2].strip()) libraryOsh.setAttribute('program_create_time', lib[3].strip()) libraryOsh.setAttribute('program_change_time', lib[4].strip()) libraryOsh.setAttribute('creator', lib[5].strip()) libraryOsh.setAttribute('owner', lib[6].strip()) libraryOsh.setAttribute('size', lib[7].strip()) libraryOsh.setAttribute('description', lib[9].strip()) libraryOsh.setContainer(lparOsh) _vector.add(libraryOsh) return _vector
def osh_createLibOsh(lparOsh, liblists): _vector = ObjectStateHolderVector() str_name = 'name' for lib in liblists: if isNotNull(lib[0]): key = concatenate(lib[0].strip(),lib[1].strip()) libraryOsh = ObjectStateHolder('iseries_library') libraryOsh.setAttribute(str_name, key) libraryOsh.setAttribute('object_name',lib[0].strip()) libraryOsh.setAttribute('library_name', lib[1].strip()) libraryOsh.setAttribute('type' , lib[2].strip()) libraryOsh.setAttribute('program_create_time', lib[3].strip()) libraryOsh.setAttribute('program_change_time', lib[4].strip()) libraryOsh.setAttribute('creator', lib[5].strip()) libraryOsh.setAttribute('owner', lib[6].strip()) libraryOsh.setAttribute('size', lib[7].strip()) libraryOsh.setAttribute('description', lib[9].strip()) libraryOsh.setContainer(lparOsh) _vector.add(libraryOsh) return _vector
def osh_createPgmOsh(lparOsh, pgmlists): _vector = ObjectStateHolderVector() str_name = 'name' for pgm in pgmlists: if isNotNull(pgm[0]): key = concatenate(pgm[0].strip(), pgm[1].strip()) programOsh = ObjectStateHolder('iseries_program') programOsh.setAttribute(str_name, key) programOsh.setAttribute('object_name', pgm[0].strip()) programOsh.setAttribute('library_name', pgm[1].strip()) programOsh.setAttribute('type', pgm[2].strip()) programOsh.setAttribute('program_create_time', pgm[3].strip()) programOsh.setAttribute('program_change_time', pgm[4].strip()) programOsh.setAttribute('creator', pgm[5].strip()) programOsh.setAttribute('owner', pgm[6].strip()) programOsh.setAttribute('size', pgm[7].strip()) programOsh.setAttribute('description', pgm[9].strip()) programOsh.setContainer(lparOsh) _vector.add(programOsh) return _vector
def osh_createPgmOsh(lparOsh, pgmlists): _vector = ObjectStateHolderVector() str_name = 'name' for pgm in pgmlists: if isNotNull(pgm[0]): key = concatenate(pgm[0].strip(),pgm[1].strip()) programOsh = ObjectStateHolder('iseries_program') programOsh.setAttribute(str_name, key) programOsh.setAttribute('object_name',pgm[0].strip()) programOsh.setAttribute('library_name', pgm[1].strip()) programOsh.setAttribute('type' , pgm[2].strip()) programOsh.setAttribute('program_create_time', pgm[3].strip()) programOsh.setAttribute('program_change_time', pgm[4].strip()) programOsh.setAttribute('creator', pgm[5].strip()) programOsh.setAttribute('owner', pgm[6].strip()) programOsh.setAttribute('size', pgm[7].strip()) programOsh.setAttribute('description', pgm[9].strip()) programOsh.setContainer(lparOsh) _vector.add(programOsh) return _vector
def osh_createIpOsh(lparOsh, tcpStacks): ipstoexclude = ['127.0.0.1'] # tcpStacks [ip, network, mask, interface name, status, type, mac address]str_name = 'name' str_name = 'name' str_mac_address = 'mac_address' _vector = ObjectStateHolderVector() for mac, tcpentry in tcpStacks.items(): ipAddress = tcpentry[0].strip() if ipAddress not in ipstoexclude: ipOsh = modeling.createIpOSH(ipAddress) probeName = CollectorsParameters.getValue( CollectorsParameters.KEY_COLLECTORS_PROBE_NAME) if isNotNull(probeName): ipOsh.setAttribute('ip_probename', probeName) containedOsh = modeling.createLinkOSH('contained', lparOsh, ipOsh) _vector.add(lparOsh) _vector.add(ipOsh) _vector.add(containedOsh) # create interface ---------------------------------------------------- ifOsh = ObjectStateHolder('interface') interfacename = tcpentry[3].strip() ifOsh.setAttribute(str_name, interfacename) # default the mac address attribute to linkName and update later if MAC found ifOsh.setAttribute( str_mac_address, mac) # if MAC not found for set #linkName as key ifOsh.setContainer(lparOsh) _vector.add(ifOsh) if tcpStacks.has_key(mac): parentLinkOsh = modeling.createLinkOSH('containment', ifOsh, ipOsh) _vector.add(parentLinkOsh) return _vector
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\\ev400hostcmd.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 iSeries & 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 ev400_config_<NODE_NAME> logger.debug('Node = ', nodeName) if eview400_lib.isNotNull(nodeName): #=================================================================== # connect to each node with configuration and only # create EView CI for the ones that connect #=================================================================== ls = eview400_lib.EvShell(Framework, nodeName, appPath) # Get EView agent version ------------------------------------------ eviewVersion = ev1_getEviewVersion(ls) if eview400_lib.isNotNull(eviewVersion): logger.debug( 'Successfully executed command against EView agent on node: ', nodeName) # Get the iSeries info ------------------------------------------------- (model, serialnbr, osversion, sysname) = ev2_getiSeriesOutput(ls) # Get the default IP of the LPAR ------------------------------- defaultIp, macAddress = ev_getIPofLpar(ls) if isNull(defaultIp): logger.reportWarning( 'Unable to get IP Address of LPAR: %s. Continuing with next LPAR.' % nodeName) continue else: # Create iSeries OSH --------------------------------- iSeriesOsh = osh_createiSeriesOsh( defaultIp, model, osversion, serialnbr, sysname, macAddress) _vector.add(iSeriesOsh) if isNotNull(iSeriesOsh): # Create IP OSH and link it to zOS OSH ------------------------- _vector.addAll( osh_createIpOsh(iSeriesOsh, defaultIp)) # Create EView Agent OSH and link it to the zOS OSH ------------ eviewOSH = osh_createEviewOsh( localshell, iSeriesOsh, 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 processiSeriesResources(ls, lparOsh, knownPortsConfigFile, Framework): # Process LPAR iSeries Resources _vector = ObjectStateHolderVector() #=========================================================================== # Run commands and create OSHs #=========================================================================== (cpuLists, cecTable, memTable) = ev1_getCpulistOutput(ls) # If we don't get output then the Iseries command failed and we need to get out if isNull(cpuLists): return _vector ''' Create IBM Frame OSH ''' _vector.addAll(osh_createIBMframeOsh(lparOsh, cecTable)) # CPU List Command --------------------------------------------------------- ''' Create CPU OSH ''' createCpu = Framework.getParameter('discover_CPUs') if isNotNull(createCpu) and string.lower(createCpu) == 'true': _vector.addAll(osh_createCpuOsh(lparOsh, cpuLists)) ''' Update the memory in the lpar OSH''' _vector.addAll(osh_updateMemOsh(lparOsh, memTable)) ''' TCPIP Stacks Command ''' tcpStacks, primaryIP = ev2_getTCPStack(ls) # Create IP OSHs ------------------------------------------------------------ _vector.addAll(osh_createIpOsh(lparOsh, tcpStacks)) # Create Network OSHs ------------------------------------------------------------ _vector.addAll(osh_createNetworkOsh(lparOsh, tcpStacks)) # Discover Subsystems ------------------------------------------------------- createSubsystem = Framework.getParameter('discover_Subsystems') if isNotNull(createSubsystem) and string.lower(createSubsystem) == 'true': ssiList = ev3_getSubsystemOutput(ls) _vector.addAll(osh_createSubsystemsOsh(lparOsh, ssiList)) # Discover Auxillary Storage Pools and Disks------------------------------------------------------ createASP = Framework.getParameter('discover_ASP') if isNotNull(createASP) and string.lower(createASP) == 'true': aspList, diskList = ev4_getAspandDisk(ls) _vector.addAll(osh_createASPOsh(lparOsh, aspList, diskList)) createSoftware = Framework.getParameter('discover_Software') if isNotNull(createSoftware) and string.lower(createSoftware) == 'true': prodLists = ev5_getInstalledSoftware(ls) ''' Create Iseries Software CIs ''' _vector.addAll(osh_createSoftwareOsh(lparOsh, prodLists)) createTCP = Framework.getParameter('discover_TCP_UDP') if isNotNull(createTCP) and string.lower(createTCP) == 'true': connections = ev6_getTcpConnOutput(ls) ''' Create Iseries Connection CIs ''' _vector.addAll( osh_createTcpConnectionsOsh(lparOsh, primaryIP, knownPortsConfigFile, connections)) return _vector
def osh_createTcpConnectionsOsh(lparOsh, primaryIP, knownPortsConfigFile, connections): str_containment = 'containment' _vector = ObjectStateHolderVector() ignoreLocalConnections = 0 ## ER: parameterize probeName = CollectorsParameters.getValue( CollectorsParameters.KEY_COLLECTORS_PROBE_NAME) for conn in connections: dstPort = '' dstAddr = '' srcAddr = '' srcPort = '' id = conn[5] #(dstAddr, dstPort) = _getIpPortFromSocket(localSocket, primaryIP) dstAddr = conn[2].strip() if dstAddr == '0.0.0.0' or dstAddr == '127.0.0.1': dstAddr = primaryIP.strip() dstPort = conn[3].strip() state = conn[9].strip() #(srcAddr, srcPort) = _getIpPortFromSocket(foreignSocket, primaryIP) if upper(state) == 'ESTABLISH': srcAddr = conn[0].strip() srcPort = conn[1].strip() if srcAddr == '127.0.0.1': srcAddr = primaryIP.strip() if ignoreLocalConnections and (srcAddr == dstAddr): continue if isNotNull(dstAddr): destination = '%s:%s' % (dstAddr, dstPort) logger.debug('[', state, '] Current connection: ', srcAddr, ' -> ', destination) # create destination (server) IP and Host -------------------------- dstIpOsh = modeling.createIpOSH(dstAddr) if isNotNull(probeName): dstIpOsh.setAttribute('ip_probename', probeName) dstHostOsh = None if isNotNull(lparOsh): dstHostOsh = lparOsh else: dstHostOsh = modeling.createHostOSH(dstAddr) dstContainedLinkOsh = modeling.createLinkOSH( str_containment, dstHostOsh, dstIpOsh) _vector.add(dstIpOsh) _vector.add(dstHostOsh) _vector.add(dstContainedLinkOsh) # create destination service address object ------------------------ portTypeEnum = TCP_PORT_TYPE_ENUM portName = knownPortsConfigFile.getTcpPortName(int(dstPort)) if upper(state) == 'UDP': portTypeEnum = UDP_PORT_TYPE_ENUM portName = knownPortsConfigFile.getUdpPortName(int(dstPort)) if isNull(portName): portName = dstPort serverPortOsh = modeling.createServiceAddressOsh( dstHostOsh, dstAddr, int(dstPort), portTypeEnum, portName) _vector.add(serverPortOsh) if isNotNull(srcAddr): # create source (client) IP and Host --------------------------- srcIpOsh = modeling.createIpOSH(srcAddr) if isNotNull(probeName): srcIpOsh.setAttribute('ip_probename', probeName) srcHostOsh = modeling.createHostOSH(srcAddr) srcContainedLinkOsh = modeling.createLinkOSH( str_containment, srcHostOsh, srcIpOsh) _vector.add(srcIpOsh) _vector.add(srcHostOsh) _vector.add(srcContainedLinkOsh) # create client-server links ----------------------------------- _vector.add( _createClientServerLinkOsh(dstPort, serverPortOsh, portName, lower(state), srcIpOsh)) # create client server dependency links ------------------------ _vector.add( _createClientServerDependencyLinkOsh( dstHostOsh, dstPort, srcHostOsh, portName)) return _vector
def osh_createTcpConnectionsOsh(lparOsh, primaryIP, knownPortsConfigFile, connections): str_containment = 'containment' _vector = ObjectStateHolderVector() ignoreLocalConnections = 0 ## ER: parameterize probeName = CollectorsParameters.getValue(CollectorsParameters.KEY_COLLECTORS_PROBE_NAME) for conn in connections: dstPort = '' dstAddr = '' srcAddr = '' srcPort = '' id = conn[5] #(dstAddr, dstPort) = _getIpPortFromSocket(localSocket, primaryIP) dstAddr = conn[2].strip() if dstAddr == '0.0.0.0' or dstAddr == '127.0.0.1': dstAddr = primaryIP.strip() dstPort = conn[3].strip() state = conn[9].strip() #(srcAddr, srcPort) = _getIpPortFromSocket(foreignSocket, primaryIP) if upper(state) == 'ESTABLISH': srcAddr = conn[0].strip() srcPort = conn[1].strip() if srcAddr == '127.0.0.1': srcAddr = primaryIP.strip() if ignoreLocalConnections and (srcAddr == dstAddr): continue if isNotNull(dstAddr): destination = '%s:%s' % (dstAddr, dstPort) logger.debug('[', state, '] Current connection: ', srcAddr, ' -> ', destination) # create destination (server) IP and Host -------------------------- dstIpOsh = modeling.createIpOSH(dstAddr) if isNotNull(probeName): dstIpOsh.setAttribute('ip_probename', probeName) dstHostOsh = None if isNotNull(lparOsh): dstHostOsh = lparOsh else: dstHostOsh = modeling.createHostOSH(dstAddr) dstContainedLinkOsh = modeling.createLinkOSH(str_containment, dstHostOsh, dstIpOsh) _vector.add(dstIpOsh) _vector.add(dstHostOsh) _vector.add(dstContainedLinkOsh) # create destination service address object ------------------------ portTypeEnum = TCP_PORT_TYPE_ENUM portName = knownPortsConfigFile.getTcpPortName(int(dstPort)) if upper(state) == 'UDP': portTypeEnum = UDP_PORT_TYPE_ENUM portName = knownPortsConfigFile.getUdpPortName(int(dstPort)) if isNull(portName): portName = dstPort serverPortOsh = modeling.createServiceAddressOsh(dstHostOsh, dstAddr, int(dstPort), portTypeEnum, portName) _vector.add(serverPortOsh) if isNotNull(srcAddr): # create source (client) IP and Host --------------------------- srcIpOsh = modeling.createIpOSH(srcAddr) if isNotNull(probeName): srcIpOsh.setAttribute('ip_probename', probeName) srcHostOsh = modeling.createHostOSH(srcAddr) srcContainedLinkOsh = modeling.createLinkOSH(str_containment, srcHostOsh, srcIpOsh) _vector.add(srcIpOsh) _vector.add(srcHostOsh) _vector.add(srcContainedLinkOsh) # create client-server links ----------------------------------- _vector.add(_createClientServerLinkOsh(dstPort, serverPortOsh, portName, lower(state), srcIpOsh)) # create client server dependency links ------------------------ _vector.add(_createClientServerDependencyLinkOsh(dstHostOsh, dstPort, srcHostOsh, portName)) return _vector
def processiSeriesResources(ls, lparOsh, knownPortsConfigFile, Framework): # Process LPAR iSeries Resources _vector = ObjectStateHolderVector() #=========================================================================== # Run commands and create OSHs #=========================================================================== (cpuLists ,cecTable, memTable) = ev1_getCpulistOutput(ls) # If we don't get output then the Iseries command failed and we need to get out if isNull (cpuLists): return _vector ''' Create IBM Frame OSH ''' _vector.addAll(osh_createIBMframeOsh(lparOsh ,cecTable)) # CPU List Command --------------------------------------------------------- ''' Create CPU OSH ''' createCpu = Framework.getParameter('discover_CPUs') if isNotNull(createCpu) and string.lower(createCpu) == 'true': _vector.addAll(osh_createCpuOsh(lparOsh, cpuLists)) ''' Update the memory in the lpar OSH''' _vector.addAll(osh_updateMemOsh(lparOsh, memTable)) ''' TCPIP Stacks Command ''' tcpStacks, primaryIP = ev2_getTCPStack(ls) # Create IP OSHs ------------------------------------------------------------ _vector.addAll(osh_createIpOsh(lparOsh, tcpStacks)) # Create Network OSHs ------------------------------------------------------------ _vector.addAll(osh_createNetworkOsh(lparOsh, tcpStacks)) # Discover Subsystems ------------------------------------------------------- createSubsystem = Framework.getParameter('discover_Subsystems') if isNotNull(createSubsystem) and string.lower(createSubsystem) == 'true': ssiList = ev3_getSubsystemOutput(ls) _vector.addAll(osh_createSubsystemsOsh(lparOsh, ssiList)) # Discover Auxillary Storage Pools and Disks------------------------------------------------------ createASP = Framework.getParameter('discover_ASP') if isNotNull(createASP) and string.lower(createASP) == 'true': aspList, diskList = ev4_getAspandDisk(ls) _vector.addAll(osh_createASPOsh(lparOsh, aspList, diskList)) createSoftware = Framework.getParameter('discover_Software') if isNotNull(createSoftware) and string.lower(createSoftware) == 'true': prodLists = ev5_getInstalledSoftware(ls) ''' Create Iseries Software CIs ''' _vector.addAll(osh_createSoftwareOsh(lparOsh, prodLists)) createTCP = Framework.getParameter('discover_TCP_UDP') if isNotNull(createTCP) and string.lower(createTCP) == 'true': connections = ev6_getTcpConnOutput(ls) ''' Create Iseries Connection CIs ''' _vector.addAll(osh_createTcpConnectionsOsh(lparOsh, primaryIP, knownPortsConfigFile, connections)) return _vector
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\\ev400hostcmd.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 iSeries & 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 ev400_config_<NODE_NAME> logger.debug ('Node = ',nodeName) if eview400_lib.isNotNull(nodeName): #=================================================================== # connect to each node with configuration and only # create EView CI for the ones that connect #=================================================================== ls = eview400_lib.EvShell(Framework, nodeName, appPath) # Get EView agent version ------------------------------------------ eviewVersion = ev1_getEviewVersion(ls) if eview400_lib.isNotNull(eviewVersion): logger.debug('Successfully executed command against EView agent on node: ', nodeName) # Get the iSeries info ------------------------------------------------- (model, serialnbr, osversion, sysname) = ev2_getiSeriesOutput(ls) # Get the default IP of the LPAR ------------------------------- defaultIp, macAddress = ev_getIPofLpar(ls) if isNull(defaultIp): logger.reportWarning('Unable to get IP Address of LPAR: %s. Continuing with next LPAR.' % nodeName) continue else: # Create iSeries OSH --------------------------------- iSeriesOsh = osh_createiSeriesOsh(defaultIp, model, osversion, serialnbr, sysname, macAddress) _vector.add(iSeriesOsh) if isNotNull(iSeriesOsh): # Create IP OSH and link it to zOS OSH ------------------------- _vector.addAll(osh_createIpOsh(iSeriesOsh, defaultIp)) # Create EView Agent OSH and link it to the zOS OSH ------------ eviewOSH = osh_createEviewOsh(localshell, iSeriesOsh, 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