예제 #1
0
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('')
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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
예제 #6
0
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
예제 #7
0
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)
예제 #8
0
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('')
예제 #9
0
def initConfigFiles():
    ConfigFilesManagerImpl.init("config", None, None)
예제 #10
0
def initConfigFiles():
    ConfigFilesManagerImpl.init("config", None, None)