def DiscoveryMain(Framework): fileName = Framework.getParameter('file_name').replace( '%PROBE_MGR_RESOURCES_DIR%', CollectorsParameters.PROBE_MGR_RESOURCES_DIR) string_list_delimiter = Framework.getParameter('string_list_delimiter') integer_list_delimiter = Framework.getParameter('integer_list_delimiter') relationship_attr_delimiter = Framework.getParameter( 'relationship_attr_delimiter') set_empty_value_flag = Boolean.parseBoolean( Framework.getParameter('set_empty_value')) if not (fileName and string_list_delimiter and integer_list_delimiter and relationship_attr_delimiter): logger.reportError('Not all job parameters are set.') return try: workbook = xlsutils.openXlFile(fileName) if workbook: classModel = ConfigFilesManagerImpl.getInstance( ).getCmdbClassModel() classModelUtil = xlsutils.ClassModelUtils(classModel, integer_list_delimiter, string_list_delimiter) importer = WorkSheetImporter(workbook, classModelUtil, set_empty_value=set_empty_value_flag) return importer.processWorkbook() except JavaException, ex: logger.reportError(ex.getMessage()) ex.printStackTrace() logger.errorException('')
def addServiceAddressOsh(hostOsh, OSHVResult, ip, portNumber, protocol, portName=None): portType = PORT_TYPE_NAMES_DICT.get(protocol) if portType: if not portName: portConfig = ConfigFilesManagerImpl.getInstance().getConfigFile(CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME) portName = portConfig.getPortNameByNumberAndType(int(portNumber), str(portType)) serviceAddressOsh = modeling.createServiceAddressOsh(hostOsh, ip, portNumber, portType, portName) OSHVResult.add(serviceAddressOsh)
def getPortDescription(portNumber, portType): """ Return port name for the given port number and type. @param portNumber: The port number @param portType: The port type (TCP / UDP) @return: String the description """ portConfig = ConfigFilesManagerImpl.getInstance().getConfigFile(CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME) return portConfig.getPortNameByNumberAndType(int(portNumber), portType)
def getPortDescription(portNumber, portType): """ Return port name for the given port number and type. @param portNumber: The port number @param portType: The port type (TCP / UDP) @return: String the description """ portConfig = ConfigFilesManagerImpl.getInstance().getConfigFile( CollectorsParameters.KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME) return portConfig.getPortNameByNumberAndType(int(portNumber), portType)
def isInstanceOf(refType, sourceType): if sourceType: if isinstance(sourceType, ObjectStateHolder): sourceType = sourceType.getObjectClass() if refType == sourceType: return True try: classModel = ConfigFilesManagerImpl.getInstance().getCmdbClassModel() return classModel.isTypeOf(refType, sourceType) except: return False return False
def isInstanceOf(refType, sourceType): if sourceType: if isinstance(sourceType, ObjectStateHolder): sourceType = sourceType.getObjectClass() if refType == sourceType: return True try: classModel = ConfigFilesManagerImpl.getInstance( ).getCmdbClassModel() return classModel.isTypeOf(refType, sourceType) except: return False return False
def addServiceAddressOsh(hostOsh, OSHVResult, ip, portNumber, protocol, portName=None): portType = PORT_TYPE_NAMES_DICT.get(protocol) if portType: if not portName: portConfig = ConfigFilesManagerImpl.getInstance().getConfigFile( CollectorsParameters. KEY_COLLECTORS_SERVERDATA_PORTNUMBERTOPORTNAME) portName = portConfig.getPortNameByNumberAndType( int(portNumber), str(portType)) serviceAddressOsh = modeling.createServiceAddressOsh( hostOsh, ip, portNumber, portType, portName) OSHVResult.add(serviceAddressOsh)
def DiscoveryMain(Framework): fileName = Framework.getParameter('file_name').replace('%PROBE_MGR_RESOURCES_DIR%', CollectorsParameters.PROBE_MGR_RESOURCES_DIR) string_list_delimiter = Framework.getParameter('string_list_delimiter') integer_list_delimiter = Framework.getParameter('integer_list_delimiter') relationship_attr_delimiter = Framework.getParameter('relationship_attr_delimiter') set_empty_value_flag = Boolean.parseBoolean(Framework.getParameter('set_empty_value')) if not (fileName and string_list_delimiter and integer_list_delimiter and relationship_attr_delimiter): logger.reportError('Not all job parameters are set.') return try: workbook = xlsutils.openXlFile(fileName) if workbook: classModel = ConfigFilesManagerImpl.getInstance().getCmdbClassModel() classModelUtil = xlsutils.ClassModelUtils(classModel, integer_list_delimiter, string_list_delimiter) importer = WorkSheetImporter(workbook, classModelUtil, set_empty_value = set_empty_value_flag) return importer.processWorkbook () except JavaException, ex: logger.reportError(ex.getMessage()) ex.printStackTrace() logger.errorException('')