Example #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_)
Example #2
0
    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))
Example #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'])
Example #4
0
    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)
Example #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)
Example #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)
Example #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)
Example #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)
Example #9
0
 def _validate(self):
     config = checkType('config', (dict, ), self.data)
     LoggerConfigurator.checkConfiguration(checkAttr('logger', config))
     Manager.checkConfiguration(checkAttr('manager', config))
Example #10
0
 def checkConfiguration(config):
     checkIPv4('deviceIP', checkAttr('deviceIP', config))
     checkPort('devicePort', checkAttr('devicePort', config))
Example #11
0
 def checkConfiguration(config):
     #Comprobamos configuracion 
     checkType('config', (dict,), config)
     checkIPv4('serverIP', checkAttr('serverIP', config))
     checkPort('serverPort', checkAttr('serverPort', config))