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
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
from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from . import criteria_functions as funcs report = Report(title='Criteria Changing with Sections', field_order =['first', 'second']) report.save() section = Section.create(report=report, title='Section 0', section_keywords=['first','second']) section.save() table = AnalysisTable.create('test-criteria-changingchoiceswithsections-0', tables={}, func = funcs.analysis_echo_criteria) TableField.create ('first', 'First Choice', table, field_cls = forms.ChoiceField, field_kwargs = {'choices': (('a', 'Option A'), ('b', 'Option B') ) }) TableField.create ('second', 'Second Choice', table, field_cls = forms.ChoiceField, pre_process_func = Function(funcs.preprocess_changesecond), dynamic=True) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table 0') section = Section.create(report=report, title='Section 1', section_keywords=['first','second']) section.save()
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Shared Fields' ) report.save() section = Section(report=report, title='Section') section.save() x = TableField.create('x', 'X Value') for i in range(2): table = AnalysisTable.create('test-criteria-sharedfields-%d' % i, tables={}, func = funcs.analysis_echo_criteria) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) table.fields.add(x) y = TableField.create('y', 'Y Value', table, hidden=True, parent_keywords = ['x'], post_process_func = Function(funcs.sharedfields_compute, params={'factor': 10*(i+1)}))
from django import forms from rvbd_portal.apps.datasource.forms import fields_add_time_selection from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Table, Column from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from . import criteria_functions as funcs report = Report(title='Criteria Two Reports - 2') report.save() TableField.create(keyword='k2', label='Key 2', obj=report, initial='r2') # Section section = Section.create(report=report, title='Section') section.save() # Table table = AnalysisTable.create('test-criteria-tworeports-2', tables={}, func = funcs.analysis_echo_criteria) TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1') Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table 2')
from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title="Criteria Post Process") report.save() section = Section(report=report, title="Section 0") section.save() table = AnalysisTable.create("test-criteria-postprocess", tables={}, func=funcs.analysis_echo_criteria) TableField.create("w", "W Value", table) TableField.create("x", "X Value", table) TableField.create("y", "Y Value", table) for (f1, f2) in [("w", "x"), ("w", "y"), ("x", "y")]: ( TableField.create( "%s%s" % (f1, f2), "%s+%s Value" % (f1, f2), table, hidden=True, parent_keywords=[f1, f2], post_process_func=Function(funcs.postprocess_field_compute, params={"fields": [f1, f2]}), ) )
# https://github.com/riverbed/flyscript-portal/blob/master/LICENSE ("License"). # This software is distributed "AS IS" as set forth in the License. from rvbd_portal.apps.datasource.models import Column, TableField from rvbd_portal.apps.report.models import Report, Section import rvbd_portal.apps.report.modules.yui3 as yui3 from rvbd_portal_profiler.datasources import profiler from rvbd_portal_profiler.datasources.profiler import (GroupByTable, TimeSeriesTable) report = Report(title="QoS Report", position=15) report.save() interface_field = TableField.create(keyword='interface', label='Interface', required=True) datafilter_field = TableField.create( keyword='datafilter', hidden=True, post_process_template='interfaces_a,{interface}') section = Section.create(report, title="Overall") # Define a Overall TimeSeries showing In/Out Utilization table = TimeSeriesTable.create('qos-overall-util', duration=15, resolution=60, interface=True) table.fields.add(interface_field) table.fields.add(datafilter_field)
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Defaults') report.save() # Report-level criteria TableField.create(keyword='report-1', label='Report 1', obj=report, initial='r1') TableField.create(keyword='report-2', label='Report 2', obj=report, required=True) # Section section = Section(report=report, title='Section 0') section.save() # Section-level criteria TableField.create(keyword='section-1', label='Section 1', obj=section, initial='s1') TableField.create(keyword='section-2', label='Section 2', obj=section, required=True, initial='s2') # Table table = AnalysisTable.create('test-criteria-postprocess', tables={}, func = funcs.analysis_echo_criteria) # Table-level criteria TableField.create(keyword='table-1', label='Table 1', obj=table, initial='t1') TableField.create(keyword='table-2', label='Table 2', obj=table, initial='t2')
from rvbd_portal.apps.report.modules import raw from . import criteria_functions as funcs report = Report(title='Criteria Section Keywords') report.save() # Section section = Section.create(report=report, title='Section 0', section_keywords=['k1']) section.save() # Table table = AnalysisTable.create('test-criteria-sectionkeywords-1', tables={}, func = funcs.analysis_echo_criteria) TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1') Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table 1') # Section section = Section.create(report=report, title='Section 1', section_keywords=['k1']) section.save() # Table table = AnalysisTable.create('test-criteria-sectionkeywords-2', tables={}, func = funcs.analysis_echo_criteria) TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1')
from . import criteria_functions as funcs report = Report(title='Criteria Circular Dependency') report.save() # Section section = Section(report=report, title='Section 0') section.save() table = AnalysisTable.create('test-criteria-circulardependency', tables={}, func=funcs.analysis_echo_criteria) TableField.create(keyword='t1', obj=table, post_process_template='table_computed:{t2}', hidden=False) TableField.create(keyword='t2', obj=table, post_process_template='table_computed:{t3}', hidden=False) TableField.create(keyword='t3', obj=table, post_process_template='table_computed:{t1}', hidden=False) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False)
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Parents', hidden_fields = ['report_computed', 'section_computed', 'table_computed'] ) report.save() # Report-level independent TableField.create(keyword='report_independent', label='Report Independent', obj=report) # Report-level computed TableField.create(keyword='report_computed', obj=report, post_process_template='report_computed:{report_independent}', hidden=False) # Section section = Section(report=report, title='Section 0') section.save() # Section-level computed TableField.create(keyword='section_computed', obj=section, post_process_template='section_computed:{report_computed}', hidden=False) # Table
# MIT License set forth at: # https://github.com/riverbed/flyscript-portal/blob/master/LICENSE ("License"). # This software is distributed "AS IS" as set forth in the License. from rvbd_portal.apps.datasource.models import Column, TableField from rvbd_portal.apps.report.models import Report, Section import rvbd_portal.apps.report.modules.yui3 as yui3 from rvbd_portal_profiler.datasources import profiler from rvbd_portal_profiler.datasources.profiler import (GroupByTable, TimeSeriesTable) report = Report(title="QoS Report", position=15) report.save() interface_field = TableField.create(keyword='interface', label='Interface', required=True) datafilter_field = TableField.create(keyword='datafilter', hidden=True, post_process_template='interfaces_a,{interface}') section = Section.create(report, title="Overall") # Define a Overall TimeSeries showing In/Out Utilization table = TimeSeriesTable.create('qos-overall-util', duration=15, resolution=60, interface=True) table.fields.add(interface_field) table.fields.add(datafilter_field) Column.create(table, 'time', 'Time', datatype='time', iskey=True) Column.create(table, 'in_avg_util', 'Avg Inbound Util %', datatype='bytes', units='B/s') Column.create(table, 'out_avg_util', 'Avg Outbound Util %', datatype='bytes', units='B/s')
from . import criteria_functions as funcs report = Report(title='Criteria Section Keywords') report.save() # Section section = Section.create(report=report, title='Section 0', section_keywords=['k1']) section.save() # Table table = AnalysisTable.create('test-criteria-sectionkeywords-1', tables={}, func=funcs.analysis_echo_criteria) TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1') Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table 1') # Section section = Section.create(report=report, title='Section 1', section_keywords=['k1']) section.save() # Table table = AnalysisTable.create('test-criteria-sectionkeywords-2', tables={},
from rvbd_portal.apps.report.modules import raw from . import criteria_functions as funcs report = Report(title='Criteria Circular Dependency') report.save() # Section section = Section(report=report, title='Section 0') section.save() table = AnalysisTable.create('test-criteria-circulardependency', tables={}, func = funcs.analysis_echo_criteria) TableField.create(keyword='t1', obj=table, post_process_template='table_computed:{t2}', hidden=False) TableField.create(keyword='t2', obj=table, post_process_template='table_computed:{t3}', hidden=False) TableField.create(keyword='t3', obj=table, post_process_template='table_computed:{t1}', hidden=False) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table')
from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Post Process') report.save() section = Section(report=report, title='Section 0') section.save() table = AnalysisTable.create('test-criteria-postprocess', tables={}, func=funcs.analysis_echo_criteria) TableField.create('w', 'W Value', table) TableField.create('x', 'X Value', table) TableField.create('y', 'Y Value', table) for (f1, f2) in [('w', 'x'), ('w', 'y'), ('x', 'y')]: (TableField.create('%s%s' % (f1, f2), '%s+%s Value' % (f1, f2), table, hidden=True, parent_keywords=[f1, f2], post_process_func=Function( funcs.postprocess_field_compute, params={'fields': [f1, f2]}))) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False)
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Defaults') report.save() # Report-level criteria TableField.create(keyword='report-1', label='Report 1', obj=report, initial='r1') TableField.create(keyword='report-2', label='Report 2', obj=report, required=True) # Section section = Section(report=report, title='Section 0') section.save() # Section-level criteria TableField.create(keyword='section-1', label='Section 1', obj=section, initial='s1') TableField.create(keyword='section-2',
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Post Process Errors' ) report.save() section = Section(report=report, title='Section 0') section.save() table = AnalysisTable.create('test-criteria-postprocess', tables={}, func = funcs.analysis_echo_criteria) TableField.create('error', 'Error type', table) TableField.create('x', 'X Value', table, hidden=True, post_process_func = Function(funcs.postprocesserrors_compute)) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table')
from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Pre Process' ) report.save() section = Section(report=report, title='Section 0') section.save() TableField.create ('choices', 'Choices', section, field_cls = forms.ChoiceField, pre_process_func = Function(funcs.preprocess_field_choices)) TableField.create ('choices_with_params', 'Choices with params', section, field_cls = forms.ChoiceField, pre_process_func = Function(funcs.preprocess_field_choices_with_params, params={'start' : 1, 'end': 3, 'prefix': 'pre'})) table = AnalysisTable.create('test-criteria-preprocess', tables={}, func = funcs.analysis_echo_criteria) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False)
from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from . import criteria_functions as funcs report = Report(title='Criteria Changing', field_order =['first', 'second']) report.save() section = Section(report=report, title='Section 0') section.save() TableField.create ('first', 'First Choice', section, field_cls = forms.ChoiceField, field_kwargs = {'choices': (('a', 'Option A'), ('b', 'Option B') ) }) TableField.create ('second', 'Second Choice', section, field_cls = forms.ChoiceField, pre_process_func = Function(funcs.preprocess_changesecond), dynamic=True) table = AnalysisTable.create('test-criteria-changingchoices', tables={}, func = funcs.analysis_echo_criteria) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table')
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report( title='Criteria Parents', hidden_fields=['report_computed', 'section_computed', 'table_computed']) report.save() # Report-level independent TableField.create(keyword='report_independent', label='Report Independent', obj=report) # Report-level computed TableField.create(keyword='report_computed', obj=report, post_process_template='report_computed:{report_independent}', hidden=False) # Section section = Section(report=report, title='Section 0') section.save() # Section-level computed TableField.create(keyword='section_computed', obj=section,
from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Pre Process') report.save() section = Section(report=report, title='Section 0') section.save() TableField.create('choices', 'Choices', section, field_cls=forms.ChoiceField, pre_process_func=Function(funcs.preprocess_field_choices)) TableField.create('choices_with_params', 'Choices with params', section, field_cls=forms.ChoiceField, pre_process_func=Function( funcs.preprocess_field_choices_with_params, params={ 'start': 1, 'end': 3, 'prefix': 'pre' }))
from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Column from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from rvbd_portal.apps.report.tests.reports import criteria_functions as funcs report = Report(title='Criteria Shared Fields') report.save() section = Section(report=report, title='Section') section.save() x = TableField.create('x', 'X Value') for i in range(2): table = AnalysisTable.create('test-criteria-sharedfields-%d' % i, tables={}, func=funcs.analysis_echo_criteria) Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) table.fields.add(x) y = TableField.create('y', 'Y Value', table, hidden=True, parent_keywords=['x'], post_process_func=Function(
from django import forms from rvbd_portal.apps.datasource.forms import fields_add_time_selection from rvbd_portal.apps.datasource.modules.analysis import AnalysisTable from rvbd_portal.apps.datasource.models import TableField, Table, Column from rvbd_portal.libs.fields import Function from rvbd_portal.apps.report.models import Report, Section from rvbd_portal.apps.report.modules import raw from . import criteria_functions as funcs report = Report(title='Criteria Two Reports - 2') report.save() TableField.create(keyword='k2', label='Key 2', obj=report, initial='r2') # Section section = Section.create(report=report, title='Section') section.save() # Table table = AnalysisTable.create('test-criteria-tworeports-2', tables={}, func=funcs.analysis_echo_criteria) TableField.create(keyword='k1', label='Key 1', obj=table, initial='r1') Column.create(table, 'key', 'Key', iskey=True, isnumeric=False) Column.create(table, 'value', 'Value', isnumeric=False) raw.TableWidget.create(section, table, 'Table 2')