예제 #1
0
    def checkJSON(field):
        id_ = checkAttr('id', field)
        checkInteger('id', id_, 1, 2**15 - 1)

        pen = None
        if ('pen' in field):
            pen = checkAttr('pen', field)
            checkInteger('pen', pen, 1, 2**32 - 1)

        name = checkAttr('name', field)
        fieldInfo = getIANAFieldById(id_) if (
            pen is None) else getPENFieldById(id_, pen)
        fieldName = fieldInfo[1]['name']
        if (name != fieldName):
            raise Exception('Field name(%s) does not match id(%d)' %
                            (name, id_))

        length = None
        if ('length' in field):
            length = checkAttr('length', field)
            checkInteger('length', length, 1)

        type_ = checkAttr('type', field)
        getStructForType(ie_type=type_, fieldName=name, length=length)

        return (id_, pen, name, length, type_)
예제 #2
0
파일: Collector.py 프로젝트: lgifre/pyIPFIX
    def checkConfiguration(config):
        checkType('config', (dict, ), config)
        checkIPv4('listenIP', checkAttr('listenIP', config))
        checkPort('listenPort', checkAttr('listenPort', config))

        transport = checkAttr('transport', config)
        checkOptions('transport', transport, ['udp', 'tcp'])
        if (transport != 'udp'):
            raise Exception('Transport(%s) not implemented' % str(transport))
예제 #3
0
    def checkConfiguration(config):
        checkOptions('screenSeverity', checkAttr('screenSeverity', config),
                     LoggerConfigurator.SEVERITY)
        if ('screenFormatter' in config):
            checkString('screenFormatter', config['screenFormatter'])

        checkOptions('fileSeverity', checkAttr('fileSeverity', config),
                     LoggerConfigurator.SEVERITY)
        checkString('fileName', checkAttr('fileName', config))
        if ('fileFormatter' in config):
            checkString('fileFormatter', config['fileFormatter'])
예제 #4
0
파일: Exporter.py 프로젝트: lgifre/pyIPFIX
    def checkConfiguration(config):
        checkType('config', (dict,), config)
        checkIPv4('localIP', checkAttr('localIP', config))
        checkIPv4('serverIP', checkAttr('serverIP', config))
        checkPort('serverPort', checkAttr('serverPort', config))
        
        transport = checkAttr('transport', config)
        checkOptions('transport', transport, ['udp', 'tcp'])
        if(transport != 'udp'): raise Exception('Transport(%s) not implemented' % str(transport))

        checkFloat('templateRefreshTimeout', checkAttr('templateRefreshTimeout', config), 1, 86400)
예제 #5
0
 def configure(self, config):
     Agent_RMON.checkConfiguration(config)
     # configure Agent_RMON
     # config = dict({'deviceIP':<str>, 'devicePort':<int>, 'mpModel':<int>})
     #Load attributes
     self._deviceIP = checkAttr('deviceIP', config)
     self._devicePort = checkAttr('devicePort', config)
     self._mpModel = checkAttr('mpModel', config)
     self._configured = True
     self._log.debug("Configuration parameters RMON Agent")
     self._log.debug(self._deviceIP)
     self._log.debug(self._devicePort)
     self._log.debug(self._mpModel)
예제 #6
0
    def fromJSON(cls, data):
        obj = cls()

        semantic = checkAttr('semantic', data)
        checkSemantics(semantic)
        obj.semantic = semantic

        template = checkAttr('template', data)
        template = TemplateRecord.newFromJSON(template['templateId'],
                                              template['fields'])
        checkType('template', (TemplateRecord, ), template)
        obj.template = template
        obj.templateId = template.getId()
        obj.records = map(lambda x: DataRecord.create(template, x['values']),
                          data['records'])
        return (obj)
예제 #7
0
    def checkConfiguration(config):
        checkType('config', (dict, ), config)

        templatesDefinitionsFile = checkAttr('definitionsFile', config)
        if (not os.path.isfile(templatesDefinitionsFile)):
            raise Exception('templatesDefinitionsFile(%s) does not exist' %
                            templatesDefinitionsFile)
        templatesDefinitions = json.loads(readFile(templatesDefinitionsFile))

        for strTemplateId, templateAttr in templatesDefinitions.iteritems():
            checkRegex('templateId', '[0-9]+', strTemplateId)
            checkInteger('templateId', int(strTemplateId), 256, 65535)
            checkType('templateAttr', (dict, ), templateAttr)

            fields = checkAttr('fields', templateAttr)
            checkType('fields', (list, ), fields)
            for field in fields:
                checkType('field', (dict, ), field)
                name = checkAttr('name', field)
                checkRegex('name', '[a-zA-Z0-9]+', name)
                enterprise = checkAttr('enterprise', field)
                checkRegex('enterprise', '[a-zA-Z0-9]+', enterprise)
                pen = pen_alias.get(enterprise)
                length = field.get('length')
                checkInteger('length',
                             length,
                             minValue=1,
                             maxValue=VARIABLE_LENGTH,
                             allowNone=True)
                if (pen is None):
                    raise Exception('Unknown Enterprise Alias(%s)' %
                                    enterprise)
                if (pen == -1):
                    FieldSpecifier.newIANA(name, length)
                else:
                    FieldSpecifier.newEnterprise(name, pen, length)
예제 #8
0
 def checkConfiguration(config):
     checkType('config', (dict, ), config)
     checkIPv4('listenIP', checkAttr('listenIP', config))
     checkPort('listenPort', checkAttr('listenPort', config))
     checkInteger('numWorkers', checkAttr('numWorkers', config), 1)
예제 #9
0
 def _validate(self):
     config = checkType('config', (dict, ), self.data)
     LoggerConfigurator.checkConfiguration(checkAttr('logger', config))
     Manager.checkConfiguration(checkAttr('manager', config))
예제 #10
0
 def checkConfiguration(config):
     checkIPv4('deviceIP', checkAttr('deviceIP', config))
     checkPort('devicePort', checkAttr('devicePort', config))
예제 #11
0
 def checkConfiguration(config):
     #Comprobamos configuracion 
     checkType('config', (dict,), config)
     checkIPv4('serverIP', checkAttr('serverIP', config))
     checkPort('serverPort', checkAttr('serverPort', config))