Exemple #1
0
    def create(cls, name, groupby, realm, duration,
               resolution='auto', filterexpr=None, interface=False,
               **kwargs):
        logger.debug('Creating ProfilerTable table %s (%s) - %s/%s' %
                     (name, duration, groupby, realm))

        options = TableOptions(groupby=groupby,
                               realm=realm,
                               centricity='int' if interface else 'hos')

        t = Table(name=name, module=__name__, 
                  filterexpr=filterexpr, options=options, **kwargs)
        t.save()

        if resolution != 'auto':
            if isinstance(resolution, int):
                res = resolution
            else:
                res = int(timedelta_total_seconds(parse_timedelta(resolution)))
            resolution = rvbd.profiler.report.Report.RESOLUTION_MAP[res]

        if isinstance(duration, int):
            duration = "%d min" % duration

        fields_add_device_selection(t, keyword='profiler_device',
                                    label='Profiler', module='profiler',
                                    enabled=True)
        fields_add_time_selection(t, initial_duration=duration)
        
        fields_add_filterexpr(t)
        fields_add_resolution(t, initial=resolution,
                              resolutions=[('auto', 'Automatic'),
                                           '1min', '15min', 'hour', '6hour'],
                              special_values=['auto'])
        return t
Exemple #2
0
    def create(cls,
               name,
               duration='1m',
               durations=None,
               resolution='1m',
               resolutions=None,
               aggregated=False,
               filterexpr=None,
               sortcol=None):
        """ Create a Shark table.

        `duration` is in minutes

        """
        logger.debug('Creating Shark table %s (%s)' % (name, duration))
        options = TableOptions(aggregated=aggregated)

        t = Table(name=name,
                  module=__name__,
                  filterexpr=filterexpr,
                  options=options,
                  sortcol=sortcol)
        t.save()

        if durations is None:
            durations = ['1m', '15m']

        if isinstance(duration, int):
            duration = "%dm" % duration

        if resolutions is None:
            resolutions = ['1s', '1m']

        fields_add_device_selection(t,
                                    keyword='shark_device',
                                    label='Shark',
                                    module='shark',
                                    enabled=True)

        TableField.create(keyword='shark_source_name',
                          label='Source',
                          obj=t,
                          field_cls=forms.ChoiceField,
                          parent_keywords=['shark_device'],
                          dynamic=True,
                          pre_process_func=Function(shark_source_name_choices))

        fields_add_time_selection(t,
                                  initial_duration=duration,
                                  durations=durations)
        fields_add_resolution(t, initial=resolution, resolutions=resolutions)
        fields_add_filterexpr(t)

        return t
Exemple #3
0
    def create(cls, name, resolution='1s', resolutions=None, **kwargs):

        if resolutions is None:
            resolutions = ['1s', '1m']

        if resolution and isinstance(resolution, int):
            resolution = "%dsec" % resolution

        table = Table.create(name, module=__name__, **kwargs)
        fields_add_resolution(table, initial= resolution, resolutions=resolutions)
        fields_add_pcapfile(table)
        fields_add_filterexpr(table)
        return table
    def create(cls, name, options, duration='1h', resolution='1min', **kwargs):

        # Create the table object and save it
        t = BaseTable(name=name, module=__name__, options=options, **kwargs)
        t.save()

        #
        # Add criteria fields that are required by this table
        #

        # Add a device selection criteria to the table,
        # listing only devices from sample_device module that are
        # enabled
        fields_add_device_selection(t,
                                    keyword='sample_device',
                                    label='Sample',
                                    module='sample_device',
                                    enabled=True)

        # Add a time selection field
        fields_add_time_selection(t, initial_duration=duration)

        # Add a time resolution field
        fields_add_resolution(t,
                              initial=resolution,
                              resolutions=[('auto', 'Automatic'), '1sec',
                                           '1min', '15min', 'hour', '6hour'],
                              special_values=['auto'])

        # Add a custom field
        TableField.create(
            obj=t,
            keyword='min',
            initial=-100,
            label='Min value',
            help_text=('Clip all wave forms at this minimum value'),
            required=False)

        # Add a custom field
        TableField.create(
            obj=t,
            keyword='max',
            initial=100,
            label='Max value',
            help_text=('Clip all wave forms at this maximum value'),
            required=False)

        return t
    def create(cls, name, options, duration="1h", resolution="1min", **kwargs):

        # Create the table object and save it
        t = BaseTable(name=name, module=__name__, options=options, **kwargs)
        t.save()

        #
        # Add criteria fields that are required by this table
        #

        # Add a device selection criteria to the table,
        # listing only devices from sample_device module that are
        # enabled
        fields_add_device_selection(t, keyword="sample_device", label="Sample", module="sample_device", enabled=True)

        # Add a time selection field
        fields_add_time_selection(t, initial_duration=duration)

        # Add a time resolution field
        fields_add_resolution(
            t,
            initial=resolution,
            resolutions=[("auto", "Automatic"), "1sec", "1min", "15min", "hour", "6hour"],
            special_values=["auto"],
        )

        # Add a custom field
        TableField.create(
            obj=t,
            keyword="min",
            initial=-100,
            label="Min value",
            help_text=("Clip all wave forms at this minimum value"),
            required=False,
        )

        # Add a custom field
        TableField.create(
            obj=t,
            keyword="max",
            initial=100,
            label="Max value",
            help_text=("Clip all wave forms at this maximum value"),
            required=False,
        )

        return t
Exemple #6
0
    def create(cls, name,
               duration='1m', durations=None,
               resolution='1m', resolutions=None,
               aggregated=False, filterexpr=None,
               sortcol=None):
        """ Create a Shark table.

        `duration` is in minutes

        """
        logger.debug('Creating Shark table %s (%s)' % (name, duration))
        options = TableOptions(aggregated=aggregated)
        
        t = Table(name=name, module=__name__, 
                  filterexpr=filterexpr, options=options, sortcol=sortcol)
        t.save()

        if durations is None:
            durations = ['1m', '15m']
            
        if isinstance(duration, int):
            duration = "%dm" % duration

        if resolutions is None:
            resolutions = ['1s', '1m']
        
        fields_add_device_selection(t,
                                    keyword='shark_device',
                                    label='Shark',
                                    module='shark',
                                    enabled=True)

        TableField.create(keyword='shark_source_name', label='Source', obj=t,
                          field_cls=forms.ChoiceField,
                          parent_keywords=['shark_device'],
                          dynamic=True,
                          pre_process_func=Function(shark_source_name_choices))
        
        fields_add_time_selection(t, initial_duration=duration,
                                  durations=durations)
        fields_add_resolution(t, initial=resolution, resolutions=resolutions)
        fields_add_filterexpr(t)

        return t
Exemple #7
0
    def create(cls, name, template_id, duration,
               resolution='auto', filterexpr=None, **kwargs):
        """ Create a ProfilerTemplateTable.

        This queries a Profiler saved report template rather than creating
        a new report from scratch.

        `template_id` is a saved-report template ID
        `duration` is in minutes or a string like '15min'
        """
        logger.debug('Creating ProfilerTemplateTable table %s (%s) - %s/%s' %
                     (name, template_id, duration, resolution))

        options = TableOptions(template_id=template_id)

        t = Table(name=name, module=__name__, 
                  filterexpr=filterexpr, options=options, **kwargs)
        t.save()

        if resolution != 'auto':
            if isinstance(resolution, int):
                res = resolution
            else:
                res = int(timedelta_total_seconds(parse_timedelta(resolution)))
            resolution = rvbd.profiler.report.Report.RESOLUTION_MAP[res]

        if isinstance(duration, int):
            duration = "%d min" % duration

        fields_add_device_selection(t, keyword='profiler_device',
                                    label='Profiler', module='profiler',
                                    enabled=True)
        fields_add_time_selection(t, initial_duration=duration)
        
        fields_add_filterexpr(t)
        fields_add_resolution(t, initial=resolution,
                              resolutions=[('auto', 'Automatic'),
                                           '1min', '15min', 'hour', '6hour'],
                              special_values=['auto'])
        return t
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import Column

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw
from rvbd_portal.apps.datasource.forms import fields_add_time_selection, fields_add_resolution

from . import synthentic_functions as funcs

# Report
report = Report(title='Synthetic No Resampling' )
report.save()

# Section 
section = Section(report=report, title='Section 0')
section.save()

# Table
table = AnalysisTable.create('test-synthetic-noresampling', tables={}, 
                             func = funcs.analysis_echo_criteria)
fields_add_time_selection(table)
fields_add_resolution(table)

Column.create(table, 'time', 'Time', iskey=True, isnumeric=True, datatype='time')
Column.create(table, 'value', 'Value', isnumeric=True)

raw.TableWidget.create(section, table, 'Table')
Exemple #9
0
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable
from rvbd_portal.apps.datasource.models import Column

from rvbd_portal.apps.report.models import Report, Section
from rvbd_portal.apps.report.modules import raw
from rvbd_portal.apps.datasource.forms import fields_add_time_selection, fields_add_resolution

# Report
from rvbd_portal.apps.report.tests.reports import synthetic_functions as funcs

report = Report(title='Synthetic No Resampling' )
report.save()

# Section 
section = Section(report=report, title='Section 0')
section.save()

# Table
table = AnalysisTable.create('test-synthetic-resampling', tables={}, 
                             func = funcs.analysis_generate_data,
                             resample = True,
                             params = {'source_resolution': 60 })
fields_add_time_selection(table)
fields_add_resolution(table)

Column.create(table, 'time', 'Time', iskey=True, isnumeric=True, datatype='time')
Column.create(table, 'value', 'Value', isnumeric=True)

raw.TableWidget.create(section, table, 'Table')