def testScript(): OSHVResult = ObjectStateHolderVector() DebugMode = 'false' DateParsePattern = 'EEE MMM dd HH:mm:ss z yyyy' userExtDir = 'E:\\data\\Desktop\\Pull_From_Remedy_backup\\' if (DebugMode != None): DebugMode = DebugMode.lower() if DebugMode == "true": logger.info ('[NOTE] UCMDB Integration is running in DEBUG mode. No data will be pushed to the destination server.') return filePathDir = userExtDir + 'TQLExport\\Atrium\\results\\' directory = File(filePathDir) files = directory.listFiles() try: for file in files: if file != None or file != '': builder = SAXBuilder () doc = builder.build(file) logger.info("Start processing CIs to update in the destination server...") allObjects = doc.getRootElement().getChild('data').getChild('objects').getChildren('Object') (objVector, ciDict) = processObjects(allObjects, DateParsePattern) OSHVResult.addAll(objVector) logger.info("Start processing Relationships to update in the destination server...") allLinks = doc.getRootElement().getChild('data').getChild('links').getChildren('link') linkVector = processLinks(allLinks, ciDict) OSHVResult.addAll(linkVector) print OSHVResult.toXmlString() except: stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) logger.info('Failure in processing data %s' % stacktrace) logger.info('Ending Push to UCMDB') #testScript()
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() DebugMode = Framework.getParameter('DebugMode') userExtDir = CollectorsParameters.BASE_PROBE_MGR_DIR + CollectorsParameters.getDiscoveryResourceFolder( ) + '\\' filePathDir = userExtDir + 'TQLExport\\ARIS\\results\\' directory = File(filePathDir) files = directory.listFiles() if files == None: logger.warn( 'Results XML not found. Perhaps no data was received from ARIS or an error occurred in the Pull_From_ARIS script.' ) return try: ## Start the work for file in files: if file != None or file != '': builder = SAXBuilder() doc = builder.build(file) # Process CIs # info( "Start processing CIs to update in the destination server..." ) allObjects = doc.getRootElement().getChild('data').getChild( 'objects').getChildren('Object') (objVector, ciDict) = processObjects(allObjects) OSHVResult.addAll(objVector) # Process Relations # info( "Start processing Relationships to update in the destination server..." ) allLinks = doc.getRootElement().getChild('data').getChild( 'links').getChildren('link') linkVector = processLinks(allLinks, ciDict) OSHVResult.addAll(linkVector) except: stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) info(concatenate('Failure: ():\n', stacktrace)) if (DebugMode != None): DebugMode = DebugMode.lower() if DebugMode == "true": mam_utils.info( '[NOTE] UCMDB Integration is running in DEBUG mode. No data will be pushed to the destination server.' ) print OSHVResult.toXmlString() return None else: #print OSHVResult.toXmlString() return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() fileSeparator = File.separator DebugMode = Framework.getParameter('DebugMode') userExtDir = CollectorsParameters.BASE_PROBE_MGR_DIR + CollectorsParameters.getDiscoveryResourceFolder() + fileSeparator filePathDir = userExtDir + 'TQLExport' + fileSeparator + 'hpsim' + fileSeparator + 'results' + fileSeparator directory = File(filePathDir) files = directory.listFiles() if files == None: logger.warn('Results XML not found. Perhaps no data was received from SIM or an error occurred in the SIM_Discovery script.') return ## Read ignored Ci types from integration configuration ignoredCiTypes = [] rawIgnoredCiTypes = Framework.getParameter('IgnoredCiTypes') tempIgnoredCiTypes = eval(rawIgnoredCiTypes) if tempIgnoredCiTypes is not None: for item in tempIgnoredCiTypes: item != 'None' and ignoredCiTypes.append(item) ## Identify UCMDB version ucmdbVersion = modeling.CmdbClassModel().version() try: ## Start the work for file in files: if file != None or file != '': builder = SAXBuilder() doc = builder.build(file) # Process CIs # info("Start processing CIs to update in the destination server...") allObjects = doc.getRootElement().getChild('data').getChild('objects').getChildren('Object') (objVector, ciDict) = processObjects(allObjects, ignoredCiTypes, ucmdbVersion) OSHVResult.addAll(objVector) # Process Relations # info("Start processing Relationships to update in the destination server...") allLinks = doc.getRootElement().getChild('data').getChild('links').getChildren('link') linkVector = processLinks(allLinks, ciDict) OSHVResult.addAll(linkVector) except: stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) info(concatenate('Failure: ():\n', stacktrace)) if (DebugMode != None): DebugMode = DebugMode.lower() if DebugMode == "true": mam_utils.info ('[NOTE] UCMDB Integration is running in DEBUG mode. No data will be pushed to the destination server.') print OSHVResult.toXmlString() return None else: #print OSHVResult.toXmlString() return OSHVResult
def DiscoveryMain(Framework): OSHVResult = ObjectStateHolderVector() DebugMode = Framework.getParameter('DebugMode') userExtDir = CollectorsParameters.BASE_PROBE_MGR_DIR + CollectorsParameters.getDiscoveryResourceFolder() + '\\' filePathDir = userExtDir + 'TQLExport\\ARIS\\results\\' directory = File(filePathDir) files = directory.listFiles() if files == None: logger.warn('Results XML not found. Perhaps no data was received from ARIS or an error occurred in the Pull_From_ARIS script.') return try: ## Start the work for file in files: if file != None or file != '': builder = SAXBuilder () doc = builder.build(file) # Process CIs # info("Start processing CIs to update in the destination server...") allObjects = doc.getRootElement().getChild('data').getChild('objects').getChildren('Object') (objVector, ciDict) = processObjects(allObjects) OSHVResult.addAll(objVector) # Process Relations # info("Start processing Relationships to update in the destination server...") allLinks = doc.getRootElement().getChild('data').getChild('links').getChildren('link') linkVector = processLinks(allLinks, ciDict) OSHVResult.addAll(linkVector) except: stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) info(concatenate('Failure: ():\n', stacktrace)) if (DebugMode != None): DebugMode = DebugMode.lower() if DebugMode == "true": mam_utils.info ('[NOTE] UCMDB Integration is running in DEBUG mode. No data will be pushed to the destination server.') print OSHVResult.toXmlString() return None else: #print OSHVResult.toXmlString() return OSHVResult
def testScript(): OSHVResult = ObjectStateHolderVector() DebugMode = 'false' DateParsePattern = 'EEE MMM dd HH:mm:ss z yyyy' userExtDir = 'E:\\data\\Desktop\\Pull_From_Remedy_backup\\' if (DebugMode != None): DebugMode = DebugMode.lower() if DebugMode == "true": logger.info( '[NOTE] UCMDB Integration is running in DEBUG mode. No data will be pushed to the destination server.' ) return filePathDir = userExtDir + 'TQLExport\\Atrium\\results\\' directory = File(filePathDir) files = directory.listFiles() try: for file in files: if file != None or file != '': builder = SAXBuilder() doc = builder.build(file) logger.info( "Start processing CIs to update in the destination server..." ) allObjects = doc.getRootElement().getChild('data').getChild( 'objects').getChildren('Object') (objVector, ciDict) = processObjects(allObjects, DateParsePattern) OSHVResult.addAll(objVector) logger.info( "Start processing Relationships to update in the destination server..." ) allLinks = doc.getRootElement().getChild('data').getChild( 'links').getChildren('link') linkVector = processLinks(allLinks, ciDict) OSHVResult.addAll(linkVector) print OSHVResult.toXmlString() except: stacktrace = traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]) logger.info('Failure in processing data %s' % stacktrace) logger.info('Ending Push to UCMDB')
def getDatabaseProperties(self,databases,dbList,discoverConfigs=1): oshv = ObjectStateHolderVector() if not discoverConfigs: return oshv query = Util.replace(Queries.DATABASE_CONFIG_FILE.toString(),dbList) rs = self.connection.getTable(query) logger.debug("get db properties") while rs.next(): dataBasePropsList=[] dbName = rs.getString("name") database = databases.get(dbName) for key in VALUES: value = rs.getString('_'+key) if value: dataBasePropsList.append("%s=%s\n" % (key, value)) data = ''.join(dataBasePropsList) configFileOsh = modeling.createConfigurationDocumentOSH('mssql database configuration.txt', 'virtual', data, database, modeling.MIME_TEXT_PLAIN) oshv.add(configFileOsh) logger.debug("get db properties: ", oshv.toXmlString()) rs.close() return oshv
def getDatabaseProperties(self, databases, dbList, discoverConfigs=1): oshv = ObjectStateHolderVector() if not discoverConfigs: return oshv query = Util.replace(Queries.DATABASE_CONFIG_FILE.toString(), dbList) rs = self.connection.getTable(query) logger.debug("get db properties") while rs.next(): dataBasePropsList = [] dbName = rs.getString("name") database = databases.get(dbName) for key in VALUES: value = rs.getString('_' + key) if value: dataBasePropsList.append("%s=%s\n" % (key, value)) data = ''.join(dataBasePropsList) configFileOsh = modeling.createConfigurationDocumentOSH( 'mssql database configuration.txt', 'virtual', data, database, modeling.MIME_TEXT_PLAIN) oshv.add(configFileOsh) logger.debug("get db properties: ", oshv.toXmlString()) rs.close() return oshv