def post_process_table(self, field_options):
        super(NetProfilerTrafficTimeSeriesTable, self).post_process_table(
            field_options)

        if self.options.top_n is None:
            # If not top-n, the criteria field 'query_columns' must
            # either be a string or an array of column definitions
            # (a string is simply parsed as json to the latter).
            #
            # This criteria field must resolve to an array of
            # field definitions, one per column to be queried
            #
            # An array of column defintions looks like the following:
            #   [ {'name': <name>, 'label': <name>, 'json': <json>},
            #     {'name': <name>, 'label': <name>, 'json': <json>},
            #     ... ]
            #
            # Each element corresponds to a column requested.  <name> is
            # used as the Column.name, <label> is for the Column.label
            # and json is what is passed on to NetProfiler in the POST
            # to create the report
            #
            TableField.create(keyword='query_columns',
                              label='Query columns',
                              obj=self)
예제 #2
0
    def post_process_table(self, field_options):
        super(NetProfilerTrafficTimeSeriesTable, self).post_process_table(
            field_options)

        if self.options.top_n is None:
            # If not top-n, the criteria field 'query_columns' must
            # either be a string or an array of column definitions
            # (a string is simply parsed as json to the latter).
            #
            # This criteria field must resolve to an array of
            # field definitions, one per column to be queried
            #
            # An array of column defintions looks like the following:
            #   [ {'name': <name>, 'label': <name>, 'json': <json>},
            #     {'name': <name>, 'label': <name>, 'json': <json>},
            #     ... ]
            #
            # Each element corresponds to a column requested.  <name> is
            # used as the Column.name, <label> is for the Column.label
            # and json is what is passed on to NetProfiler in the POST
            # to create the report
            #
            TableField.create(keyword='query_columns',
                              label='Query columns',
                              obj=self)
예제 #3
0
    def post_process_table(self, field_options):
        fields_add_device_selection(self,
                                    keyword='netprofiler_device',
                                    label='NetProfiler',
                                    module='netprofiler',
                                    enabled=True)
        fields_add_time_selection(self, show_end=True, show_duration=False)

        func = Function(netprofiler_live_templates, self.options)

        TableField.create('template_id',
                          label='Template',
                          obj=self,
                          field_cls=IDChoiceField,
                          parent_keywords=['netprofiler_device'],
                          dynamic=True,
                          pre_process_func=func)

        self.add_column('template_id',
                        'Template ID',
                        datatype='string',
                        iskey=True)
        self.add_column('widget_id',
                        'Widget ID',
                        datatype='integer',
                        iskey=True)
        self.add_column('title', 'Title', datatype='string')
        self.add_column('widget_type', 'Type', datatype='string')
        self.add_column('visualization', 'Visualization', datatype='string')
        self.add_column('datasource', 'Data Source', datatype='string')
예제 #4
0
def add_netprofiler_application_field(report, section, app=None):
    """ Attach fields for dynamic Application dropdowns to add as filter
    expressions to the report.

    This can be added for each section in a report where the added filter
    expression is desired.

    The optional ``app`` argument can be either a single string or a list
    of strings for each HostGroupType.  If a single string, the
    'Application' field will be hidden and automatically filter Applications
    to the given App.  If a list, the elements of the App
    list will be fixed to those in the list.
    """
    # add default filter expr to extend against
    filterexpr = TableField.create(keyword='netprofiler_filterexpr')
    section.fields.add(filterexpr)

    if app is None:
        # use all available apps
        field = TableField.create(
            keyword='application',
            label='Application',
            obj=report,
            field_cls=forms.ChoiceField,
            field_kwargs={'widget_attrs': {'class': 'form-control'}},
            parent_keywords=['netprofiler_device'],
            dynamic=True,
            pre_process_func=Function(netprofiler_application_choices)
        )
        section.fields.add(field)

    elif type(app) in (list, tuple):
        # add apps field that uses given list
        field = TableField.create(
            keyword='application',
            label='Application',
            obj=report,
            field_cls=forms.ChoiceField,
            field_kwargs={'choices': zip(app, app),
                          'widget_attrs': {'class': 'form-control'}},
            parent_keywords=['netprofiler_device'],
        )
        section.fields.add(field)

    else:
        # no app, so no field just hardcode the filter
        NetProfilerTable.extend_filterexpr(
            section, keyword='application',
            template='app {}'.format(app)
        )

        # we're done here
        return

    NetProfilerTable.extend_filterexpr(
        section, keyword='hg_filterexpr',
        template='app {application}'
    )
예제 #5
0
def fields_add_entire_pcap(table):
    TableField.create(keyword='entire_pcap',
                      obj=table,
                      field_cls=forms.BooleanField,
                      label='Entire File',
                      help_text='Ignore start/end times '
                      'and run the report over the '
                      'whole timeframe of the selected '
                      'file.',
                      initial=True,
                      required=False)
예제 #6
0
def fields_add_source_choices(table, func, keyword='appresponse_source',
                              label='Source', initial=None):
    TableField.create(
        keyword=keyword, label=label,
        obj=table,
        field_cls=IDChoiceField,
        field_kwargs={'widget_attrs': {'class': 'form-control'}},
        parent_keywords=['appresponse_device'],
        initial=initial,
        dynamic=True,
        pre_process_func=func
    )
예제 #7
0
    def post_process_table(self, field_options):

        super(AppResponseTimeSeriesTable, self).\
            post_process_table(field_options)

        TableField.create(keyword='pivot_column_names',
                          required=not self.options.hide_pivot_field,
                          hidden=self.options.hide_pivot_field,
                          label=self.options.pivot_column_label, obj=self,
                          help_text='Name of Interested Columns '
                                    '(separated by ",")')

        self.add_column('time', 'time', datatype='time', iskey=True)
예제 #8
0
    def post_process_table(self, field_options):
        fields_add_device_selection(self,
                                    keyword='netshark_device_src',
                                    label='NetShark Source',
                                    module='netshark',
                                    enabled=True)
        fields_add_device_selection(self,
                                    keyword='netshark_device_dst',
                                    label='NetShark Dest',
                                    module='netshark',
                                    enabled=True)

        fields_add_device_selection(self,
                                    keyword='netshark_device_upload',
                                    label='NetShark MSA',
                                    module='netshark',
                                    enabled=True)
        TableField.create(
            keyword='netshark_source_name_src',
            label='Source Capture Job',
            obj=self,
            field_cls=forms.ChoiceField,
            field_kwargs={'widget_attrs': {
                'class': 'form-control'
            }},
            parent_keywords=['netshark_device_src'],
            dynamic=True,
            pre_process_func=Function(netshark_source_choices,
                                      {'field': 'netshark_device_src'}))
        TableField.create(
            keyword='netshark_source_name_dst',
            label='Dest Capture Job',
            obj=self,
            field_cls=forms.ChoiceField,
            field_kwargs={'widget_attrs': {
                'class': 'form-control'
            }},
            parent_keywords=['netshark_device_dst'],
            dynamic=True,
            pre_process_func=Function(netshark_source_choices,
                                      {'field': 'netshark_device_dst'}))

        fields_add_time_selection(self,
                                  show_start=True,
                                  initial_start_time='now-1m',
                                  show_end=True,
                                  show_duration=False)

        fields_add_filterexpr(obj=self)
예제 #9
0
    def extend_filterexpr(cls, obj, keyword, template):

        field = obj.fields.get(keyword='netprofiler_filterexpr')
        field.post_process_func = Function(
            function=_post_process_combine_filterexprs
        )

        TableField.create(
            keyword=keyword, obj=obj, hidden=True,
            post_process_template=template)

        parent_keywords = set(field.parent_keywords or [])
        parent_keywords.add(keyword)
        field.parent_keywords = list(parent_keywords)
        field.save()
    def extend_filterexpr(cls, obj, keyword, template):

        field = obj.fields.get(keyword='netprofiler_filterexpr')
        field.post_process_func = Function(
            function=_post_process_combine_filterexprs
        )

        TableField.create(
            keyword=keyword, obj=obj, hidden=True,
            post_process_template=template)

        parent_keywords = set(field.parent_keywords or [])
        parent_keywords.add(keyword)
        field.parent_keywords = list(parent_keywords)
        field.save()
    def post_process_table(self, field_options):
        #
        # Add criteria fields that are required by this table
        #
        TableField.create(keyword='entire_pcap', obj=self,
                          field_cls=forms.BooleanField,
                          label='Entire PCAP',
                          initial=True,
                          required=False)

        fields_add_time_selection(self, show_start=True, show_end=True,
                                  show_duration=False)
        fields_add_resolution(obj=self,
                              initial=field_options['resolution'],
                              resolutions=field_options['resolutions'])
        fields_add_pcapfile(
            obj=self, astextfield=field_options['pcapfile_astextfield'])
        fields_add_filterexpr(obj=self)
예제 #12
0
    def post_process_table(self, field_options):
        duration = field_options['duration']
        if isinstance(duration, int):
            duration = "{}m".format(duration)

        fields_add_device_selection(self,
                                    keyword='netshark_device',
                                    label='NetShark',
                                    module='netshark',
                                    enabled=True)

        func = Function(netshark_msa_file_choices, self.options)
        TableField.create(
            keyword='netshark_source_name',
            label='Source',
            obj=self,
            field_cls=IDChoiceField,
            field_kwargs={'widget_attrs': {
                'class': 'form-control'
            }},
            parent_keywords=['netshark_device'],
            dynamic=True,
            pre_process_func=func)

        fields_add_time_selection(self,
                                  initial_duration=duration,
                                  durations=field_options['durations'])
        fields_add_resolution(self,
                              initial=field_options['resolution'],
                              resolutions=field_options['resolutions'])

        if self.options.include_filter:
            fields_add_filterexpr(self)

        if self.options.include_bpf_filter:
            fields_add_bpf_filterexpr(self)

        if self.options.show_entire_msa:
            TableField.create(keyword='entire_msa',
                              obj=self,
                              field_cls=forms.BooleanField,
                              label='Entire MSA (ignore start/end times)',
                              initial=True,
                              required=False)
예제 #13
0
    def post_process_table(self, field_options):
        duration = field_options['duration']
        if isinstance(duration, int):
            duration = "%dm" % duration

        fields_add_device_selection(self,
                                    keyword='netshark_device',
                                    label='NetShark',
                                    module='netshark',
                                    enabled=True)

        func = Function(netshark_source_name_choices, self.options)
        TableField.create(
            keyword='netshark_source_name',
            label='Source',
            obj=self,
            field_cls=IDChoiceField,
            field_kwargs={'widget_attrs': {
                'class': 'form-control'
            }},
            parent_keywords=['netshark_device'],
            dynamic=True,
            pre_process_func=func)

        if self.options.include_persistent:
            TableField.create(keyword='netshark_persistent',
                              label='Persistent View',
                              obj=self,
                              field_cls=forms.BooleanField,
                              initial=False)

        fields_add_time_selection(self,
                                  initial_duration=duration,
                                  durations=field_options['durations'])
        fields_add_resolution(self,
                              initial=field_options['resolution'],
                              resolutions=field_options['resolutions'])

        if self.options.include_filter:
            fields_add_filterexpr(self)

        if self.options.include_bpf_filter:
            fields_add_bpf_filterexpr(self)
예제 #14
0
 def post_process_table(self, field_options):
     fields_add_device_selection(self, keyword='netshark_device',
                                 label='NetShark', module='netshark',
                                 enabled=True)
     fields_add_time_selection(self, show_start=True,
                               initial_start_time='now-1m',
                               show_end=True,
                               show_duration=False)
     fields_add_resolution(self,
                           initial=field_options['resolution'],
                           resolutions=field_options['resolutions'])
     func = Function(netshark_source_name_choices, self.options)
     TableField.create(keyword='netshark_source_name', label='Source',
                       obj=self,
                       field_cls=forms.ChoiceField,
                       parent_keywords=['netshark_device'],
                       dynamic=True,
                       pre_process_func=func)
     fields_add_filterexpr(obj=self)
     self.add_column('filename', datatype='string')
예제 #15
0
    def post_process_table(self, field_options):
        fields_add_device_selection(self, keyword='netshark_device_src',
                                    label='NetShark Source', module='netshark',
                                    enabled=True)
        fields_add_device_selection(self, keyword='netshark_device_dst',
                                    label='NetShark Dest', module='netshark',
                                    enabled=True)

        fields_add_device_selection(self, keyword='netshark_device_upload',
                                    label='NetShark MSA', module='netshark',
                                    enabled=True)
        TableField.create(
            keyword='netshark_source_name_src',
            label='Source Capture Job',
            obj=self,
            field_cls=forms.ChoiceField,
            field_kwargs={'widget_attrs': {'class': 'form-control'}},
            parent_keywords=['netshark_device_src'],
            dynamic=True,
            pre_process_func=Function(netshark_source_choices,
                                      {'field': 'netshark_device_src'})
        )
        TableField.create(
            keyword='netshark_source_name_dst',
            label='Dest Capture Job',
            obj=self,
            field_cls=forms.ChoiceField,
            field_kwargs={'widget_attrs': {'class': 'form-control'}},
            parent_keywords=['netshark_device_dst'],
            dynamic=True,
            pre_process_func=Function(netshark_source_choices,
                                      {'field': 'netshark_device_dst'})
        )

        fields_add_time_selection(self, show_start=True,
                                  initial_start_time='now-1m',
                                  show_end=True,
                                  show_duration=False)

        fields_add_filterexpr(obj=self)
예제 #16
0
    def post_process_table(self, field_options):
        duration = field_options['duration']
        if isinstance(duration, int):
            duration = "{}m".format(duration)

        fields_add_device_selection(self, keyword='netshark_device',
                                    label='NetShark', module='netshark',
                                    enabled=True)

        func = Function(netshark_msa_file_choices,
                        self.options)
        TableField.create(keyword='netshark_source_name', label='Source',
                          obj=self,
                          field_cls=IDChoiceField,
                          field_kwargs={
                              'widget_attrs': {'class': 'form-control'}
                          },
                          parent_keywords=['netshark_device'],
                          dynamic=True,
                          pre_process_func=func)

        fields_add_time_selection(self,
                                  initial_duration=duration,
                                  durations=field_options['durations'])
        fields_add_resolution(self,
                              initial=field_options['resolution'],
                              resolutions=field_options['resolutions'])

        if self.options.include_filter:
            fields_add_filterexpr(self)

        if self.options.include_bpf_filter:
            fields_add_bpf_filterexpr(self)

        if self.options.show_entire_msa:
            TableField.create(keyword='entire_msa', obj=self,
                              field_cls=forms.BooleanField,
                              label='Entire MSA (ignore start/end times)',
                              initial=True,
                              required=False)
예제 #17
0
    def post_process_table(self, field_options):
        # Add a time selection field

        fields_add_device_selection(self,
                                    keyword='appresponse_device',
                                    label='AppResponse',
                                    module='appresponse',
                                    enabled=True)

        if self.options.source == 'packets':
            func = Function(appresponse_source_choices, self.options)

            TableField.create(
                keyword='appresponse_source',
                label='Source',
                obj=self,
                field_cls=IDChoiceField,
                field_kwargs={'widget_attrs': {
                    'class': 'form-control'
                }},
                parent_keywords=['appresponse_device'],
                dynamic=True,
                pre_process_func=func)

            if self.options.show_entire_pcap:
                TableField.create(keyword='entire_pcap',
                                  obj=self,
                                  field_cls=forms.BooleanField,
                                  label='Entire PCAP',
                                  initial=True,
                                  required=False)

        fields_add_granularity(self,
                               initial=field_options['granularity'],
                               source=self.options.source)

        fields_add_time_selection(self,
                                  show_end=True,
                                  initial_duration=field_options['duration'])
예제 #18
0
    def post_process_table(self, field_options):
        duration = field_options['duration']
        if isinstance(duration, int):
            duration = "%dm" % duration

        fields_add_device_selection(self, keyword='netshark_device',
                                    label='NetShark', module='netshark',
                                    enabled=True)

        func = Function(netshark_source_name_choices,
                        self.options)
        TableField.create(
            keyword='netshark_source_name', label='Source',
            obj=self,
            field_cls=IDChoiceField,
            field_kwargs={'widget_attrs': {'class': 'form-control'}},
            parent_keywords=['netshark_device'],
            dynamic=True,
            pre_process_func=func
        )

        if self.options.include_persistent:
            TableField.create(keyword='netshark_persistent',
                              label='Persistent View', obj=self,
                              field_cls=forms.BooleanField,
                              initial=False)

        fields_add_time_selection(self,
                                  initial_duration=duration,
                                  durations=field_options['durations'])
        fields_add_resolution(self,
                              initial=field_options['resolution'],
                              resolutions=field_options['resolutions'])

        if self.options.include_filter:
            fields_add_filterexpr(self)

        if self.options.include_bpf_filter:
            fields_add_bpf_filterexpr(self)
예제 #19
0
    def post_process_table(self, field_options):
        duration = field_options['duration']
        if isinstance(duration, int):
            duration = "%dm" % duration

        fields_add_device_selection(self, keyword='netshark_device',
                                    label='NetShark', module='netshark',
                                    enabled=True)

        TableField.create(keyword='netshark_source_name', label='Source',
                          obj=self,
                          field_cls=forms.ChoiceField,
                          parent_keywords=['netshark_device'],
                          dynamic=True,
                          pre_process_func=Function(netshark_source_name_choices))

        fields_add_time_selection(self,
                                  initial_duration=duration,
                                  durations=field_options['durations'])
        fields_add_resolution(self,
                              initial=field_options['resolution'],
                              resolutions=field_options['resolutions'])
        self.fields_add_filterexpr()
    def post_process_table(self, field_options):
        fields_add_device_selection(self, keyword='netprofiler_device',
                                    label='NetProfiler', module='netprofiler',
                                    enabled=True)
        fields_add_time_selection(self, show_end=True, show_duration=False)

        func = Function(netprofiler_live_templates, self.options)

        TableField.create('template_id', label='Template',
                          obj=self,
                          field_cls=IDChoiceField,
                          parent_keywords=['netprofiler_device'],
                          dynamic=True,
                          pre_process_func=func)

        self.add_column('template_id', 'Template ID', datatype='string',
                        iskey=True)
        self.add_column('widget_id', 'Widget ID', datatype='integer',
                        iskey=True)
        self.add_column('title', 'Title', datatype='string')
        self.add_column('widget_type', 'Type', datatype='string')
        self.add_column('visualization', 'Visualization', datatype='string')
        self.add_column('datasource', 'Data Source', datatype='string')
    def post_process_table(self, field_options):
        #
        # Add criteria fields that are required by this table
        #
        if self.options.show_entire_pcap:
            TableField.create(keyword='entire_pcap',
                              obj=self,
                              field_cls=forms.BooleanField,
                              label='Entire PCAP',
                              initial=True,
                              required=False)

        fields_add_time_selection(self,
                                  show_start=True,
                                  show_end=True,
                                  show_duration=False)
        fields_add_resolution(obj=self,
                              initial=field_options['resolution'],
                              resolutions=field_options['resolutions'])

        if self.options.show_pcap_mgr:
            fields_add_pcapmgr_selection(obj=self)
        fields_add_filterexpr(obj=self)
예제 #22
0
 def post_process_table(self, field_options):
     fields_add_device_selection(self,
                                 keyword='netshark_device',
                                 label='NetShark',
                                 module='netshark',
                                 enabled=True)
     fields_add_time_selection(self,
                               show_start=True,
                               initial_start_time='now-1m',
                               show_end=True,
                               show_duration=False)
     fields_add_resolution(self,
                           initial=field_options['resolution'],
                           resolutions=field_options['resolutions'])
     func = Function(netshark_source_name_choices, self.options)
     TableField.create(keyword='netshark_source_name',
                       label='Source',
                       obj=self,
                       field_cls=forms.ChoiceField,
                       parent_keywords=['netshark_device'],
                       dynamic=True,
                       pre_process_func=func)
     fields_add_filterexpr(obj=self)
     self.add_column('filename', datatype='string')
예제 #23
0
from django import forms

from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

report = Report.create(title='Criteria Bool')

# Section
section = report.add_section(title='Section 0')

# Table
a = CriteriaTable.create('test-criteria-bool')

# Table-level criteria
TableField.create('b1',
                  'Bool True',
                  obj=a,
                  field_cls=forms.BooleanField,
                  initial=True)
TableField.create('b2',
                  'Bool False',
                  obj=a,
                  field_cls=forms.BooleanField,
                  initial=False)

report.add_widget(raw.TableWidget, a, 'Table')
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

from steelscript.appfwk.apps.report.tests.reports import criteria_functions as funcs

report = Report.create(title='Criteria Parents',
                       hidden_fields=['report_computed',
                                      'section_computed',
                                      'table_computed'])

# Report-level independent
TableField.create('report_independent', 'Report Independent', obj=report)

# Report-level computed
TableField.create('report_computed', 'Reprot computed', obj=report,
                  post_process_template='report_computed:{report_independent}',
                  hidden=False)

# Section
section = report.add_section(title='Section 0')

# Section-level computed
TableField.create(keyword='section_computed', obj=section,
                  post_process_template='section_computed:{report_computed}',
                  hidden=False)

# Table
a = CriteriaTable.create('test-criteria-parents')
def add_netprofiler_hostgroup_field(report, section, hg_type=None):
    """ Attach fields for dynamic HostGroup dropdowns to add as filter
    expressions to the report.

    This can be added for each section in a report where the added filter
    expression is desired.

    The optional ``hg_type`` argument can be either a single string or a list
    of strings for each HostGroupType.  If a single string, the
    'HostGroupType' field will be hidden and automatically filter HostGroups
    to the given HostGroupType.  If a list, the elements of the HostGroupType
    list will be fixed to those in the list; this can be helpful if certain
    HostGroupTypes may be sensitive or not applicable to the report.
    """
    # add default filter expr to extend against
    filterexpr = TableField.create(keyword='netprofiler_filterexpr')
    section.fields.add(filterexpr)

    # defaults if we are using hostgroup type field
    hg_template = '{hostgroup_type}'
    hg_parent = ['hostgroup_type']
    hg_params = None

    if hg_type is None:
        # add hostgroup types field that queries netprofiler
        field = TableField.create(
            keyword='hostgroup_type',
            label='HostGroup Type',
            obj=report,
            field_cls=forms.ChoiceField,
            parent_keywords=['netprofiler_device'],
            dynamic=True,
            pre_process_func=Function(netprofiler_hostgroup_types)
        )
        section.fields.add(field)

    elif type(hg_type) in (list, tuple):
        # add hostgroup types field that uses given list
        field = TableField.create(
            keyword='hostgroup_type',
            label='HostGroup Type',
            obj=report,
            field_cls=forms.ChoiceField,
            field_kwargs={'choices': zip(hg_type, hg_type)},
            parent_keywords=['netprofiler_device'],
        )
        section.fields.add(field)

    else:
        # no field, hardcode the given value
        hg_template = hg_type
        hg_parent = None
        hg_params = {'hostgroup_type': hg_type}

    # add hostgroup field
    field = TableField.create(
        keyword='hostgroup',
        label='HostGroup',
        obj=report,
        field_cls=forms.ChoiceField,
        parent_keywords=hg_parent,
        dynamic=True,
        pre_process_func=Function(netprofiler_hostgroups, params=hg_params)
    )
    section.fields.add(field)

    NetProfilerTable.extend_filterexpr(
        section, keyword='hg_filterexpr',
        template='hostgroup %s:{hostgroup}' % hg_template
    )
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.libs.fields import Function

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

from steelscript.appfwk.apps.report.tests.reports \
    import criteria_functions as funcs

report = Report.create(title='Criteria Post Process Errors')

section = report.add_section(title='Section 0')

a = CriteriaTable.create('test-criteria-postprocess-errors')

TableField.create('error', 'Error type', a)
TableField.create('x',
                  'X Value',
                  a,
                  hidden=True,
                  post_process_func=Function(funcs.postprocesserrors_compute))

report.add_widget(raw.TableWidget, a, 'Table')
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.libs.fields import Function

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

from steelscript.appfwk.apps.report.tests.reports \
    import criteria_functions as funcs

report = Report.create(title='Criteria Post Process Errors')

section = report.add_section(title='Section 0')

a = CriteriaTable.create('test-criteria-postprocess-errors')

TableField.create('error', 'Error type', a)
TableField.create('x', 'X Value', a, hidden=True,
                  post_process_func=Function(funcs.postprocesserrors_compute))


report.add_widget(raw.TableWidget, a, 'Table')
예제 #28
0
 def post_process_table(self, field_options):
     super(CriteriaFieldMapTable, self).post_process_table(field_options)
     TableField.create('k1', 'Key 1', obj=self, initial='K1')
     TableField.create('k2', 'Key 2', obj=self, required=True)
예제 #29
0
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

report = Report.create(title='Criteria Defaults')

# Report-level criteria
TableField.create('report-1', 'Report 1', obj=report, initial='r1')
TableField.create('report-2', 'Report 2', obj=report, required=True)

# Section
section = report.add_section(title='Section 0')

# Section-level criteria
TableField.create('section-1', 'Section 1', obj=section, initial='s1')
TableField.create('section-2',
                  'Section 2',
                  obj=section,
                  required=True,
                  initial='s2')

# Table
a = CriteriaTable.create('test-criteria-defaults')

# Table-level criteria
TableField.create('table-1', 'Table 1', obj=a, initial='t1')
TableField.create('table-2', 'Table 2', obj=a, initial='t2')

report.add_widget(raw.TableWidget, a, 'Table')
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.libs.fields import Function

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw
from . import criteria_functions as funcs

report = Report.create(title='Criteria Post Process')

section = report.add_section(title='Section 0')

a = CriteriaTable.create('test-criteria-postprocess')

TableField.create('w', 'W Value', a)
TableField.create('x', 'X Value', a)
TableField.create('y', 'Y Value', a)

for (f1, f2) in [('w', 'x'), ('w', 'y'), ('x', 'y')]:
    (TableField.create('%s%s' % (f1, f2),
                       '%s+%s Value' % (f1, f2),
                       a,
                       hidden=True,
                       parent_keywords=[f1, f2],
                       post_process_func=Function(
                           funcs.postprocess_field_compute,
                           params={'fields': [f1, f2]})))

report.add_widget(raw.TableWidget, a, 'Table')
예제 #31
0
def add_netprofiler_hostgroup_field(report, section, hg_type=None):
    """ Attach fields for dynamic HostGroup dropdowns to add as filter
    expressions to the report.

    This can be added for each section in a report where the added filter
    expression is desired.

    The optional ``hg_type`` argument can be either a single string or a list
    of strings for each HostGroupType.  If a single string, the
    'HostGroupType' field will be hidden and automatically filter HostGroups
    to the given HostGroupType.  If a list, the elements of the HostGroupType
    list will be fixed to those in the list; this can be helpful if certain
    HostGroupTypes may be sensitive or not applicable to the report.
    """
    # add default filter expr to extend against
    filterexpr = TableField.create(keyword='netprofiler_filterexpr')
    section.fields.add(filterexpr)

    # defaults if we are using hostgroup type field
    hg_template = '{hostgroup_type}'
    hg_parent = ['hostgroup_type']
    hg_params = None

    if hg_type is None:
        # add hostgroup types field that queries netprofiler
        field = TableField.create(
            keyword='hostgroup_type',
            label='HostGroup Type',
            obj=report,
            field_cls=forms.ChoiceField,
            field_kwargs={'widget_attrs': {'class': 'form-control'}},
            parent_keywords=['netprofiler_device'],
            dynamic=True,
            pre_process_func=Function(netprofiler_hostgroup_types)
        )
        section.fields.add(field)

    elif type(hg_type) in (list, tuple):
        # add hostgroup types field that uses given list
        field = TableField.create(
            keyword='hostgroup_type',
            label='HostGroup Type',
            obj=report,
            field_cls=forms.ChoiceField,
            field_kwargs={'choices': zip(hg_type, hg_type),
                          'widget_attrs': {'class': 'form-control'}},
            parent_keywords=['netprofiler_device'],
        )
        section.fields.add(field)

    else:
        # no field, hardcode the given value
        hg_template = hg_type
        hg_parent = None
        hg_params = {'hostgroup_type': hg_type}

    # add hostgroup field
    field = TableField.create(
        keyword='hostgroup',
        label='HostGroup',
        obj=report,
        field_cls=forms.ChoiceField,
        field_kwargs={'widget_attrs': {'class': 'form-control'}},
        parent_keywords=hg_parent,
        dynamic=True,
        pre_process_func=Function(netprofiler_hostgroups, params=hg_params)
    )
    section.fields.add(field)

    NetProfilerTable.extend_filterexpr(
        section, keyword='hg_filterexpr',
        template='hostgroup %s:{hostgroup}' % hg_template
    )
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.libs.fields import Function

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw
from . import criteria_functions as funcs

report = Report.create(title='Criteria Post Process')

section = report.add_section(title='Section 0')

a = CriteriaTable.create('test-criteria-postprocess')

TableField.create('w', 'W Value', a)
TableField.create('x', 'X Value', a)
TableField.create('y', 'Y Value', a)

for (f1, f2) in [('w', 'x'), ('w', 'y'), ('x', 'y')]:
    (TableField.create
     ('%s%s' % (f1, f2), '%s+%s Value' % (f1, f2), a,
      hidden=True, parent_keywords=[f1, f2],
      post_process_func=Function(funcs.postprocess_field_compute,
                                 params={'fields': [f1, f2]})))


report.add_widget(raw.TableWidget, a, 'Table')
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.libs.fields import Function

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

from steelscript.appfwk.apps.report.tests.reports \
    import criteria_functions as funcs

report = Report.create(title='Criteria Shared Fields')

x = TableField.create('x', 'X Value')
for i in range(2):

    section = report.add_section(title='Section %d' % i)

    a = CriteriaTable.create('test-criteria-sharedfields-%d' % i)

    a.fields.add(x)
    y = TableField.create('y',
                          'Y Value',
                          a,
                          hidden=True,
                          parent_keywords=['x'],
                          post_process_func=Function(
                              funcs.sharedfields_compute,
                              params={'factor': 10 * (i + 1)}))

    report.add_widget(raw.TableWidget, a, 'Table %d' % i)
예제 #34
0
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.libs.fields import Function
from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw
from steelscript.appfwk.apps.report.tests.reports \
    import criteria_functions as funcs

report = Report.create(title='Criteria Pre Process')

section = report.add_section(title='Section 0')

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'
                      }))
예제 #35
0
# accompanying the software ("License").  This software is distributed "AS IS"
# as set forth in the License.


from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.apps.report.models import Report
import steelscript.appfwk.apps.report.modules.c3 as c3
import steelscript.appfwk.apps.report.modules.tables as tables

from steelscript.netprofiler.appfwk.datasources.netprofiler import \
    NetProfilerTimeSeriesTable, NetProfilerGroupbyTable, NetProfilerTable

report = Report.create("DSCP Report", position=10,
                       hidden_fields=['netprofiler_filterexpr'])

netprofiler_filterexpr = TableField.create(
    keyword='netprofiler_filterexpr')

interface_field = TableField.create(
    keyword='interface', label='Interface', required=True)

#
# Overall section
#  - netprofiler_filterexpr = "interface {interface}"
#
section = report.add_section("Overall",
                             section_keywords=['netprofiler_filterexpr',
                                               'interface_expr'])

section.fields.add(netprofiler_filterexpr)
section.fields.add(interface_field)
 def post_process_table(self, field_options):
     super(CriteriaFieldMapTable, self).post_process_table(field_options)
     TableField.create('k1', 'Key 1', obj=self, initial='K1')
     TableField.create('k2', 'Key 2', obj=self, required=True)
from django import forms

from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

report = Report.create(title='Criteria Bool')

# Section
section = report.add_section(title='Section 0')

# Table
a = CriteriaTable.create('test-criteria-bool')

# Table-level criteria
TableField.create('b1', 'Bool True', obj=a,
                  field_cls=forms.BooleanField, initial=True)
TableField.create('b2', 'Bool False', obj=a,
                  field_cls=forms.BooleanField, initial=False)

report.add_widget(raw.TableWidget, a, 'Table')
예제 #38
0
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

from steelscript.appfwk.apps.report.tests.reports import criteria_functions as funcs

report = Report.create(
    title='Criteria Parents',
    hidden_fields=['report_computed', 'section_computed', 'table_computed'])

# Report-level independent
TableField.create('report_independent', 'Report Independent', obj=report)

# Report-level computed
TableField.create('report_computed',
                  'Reprot computed',
                  obj=report,
                  post_process_template='report_computed:{report_independent}',
                  hidden=False)

# Section
section = report.add_section(title='Section 0')

# Section-level computed
TableField.create(keyword='section_computed',
                  obj=section,
                  post_process_template='section_computed:{report_computed}',
                  hidden=False)
from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField

from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw

report = Report.create(title='Criteria Defaults')

# Report-level criteria
TableField.create('report-1', 'Report 1', obj=report, initial='r1')
TableField.create('report-2', 'Report 2', obj=report, required=True)

# Section
section = report.add_section(title='Section 0')

# Section-level criteria
TableField.create('section-1', 'Section 1', obj=section, initial='s1')
TableField.create('section-2', 'Section 2', obj=section, required=True, initial='s2')

# Table
a = CriteriaTable.create('test-criteria-defaults')

# Table-level criteria
TableField.create('table-1', 'Table 1', obj=a, initial='t1')
TableField.create('table-2', 'Table 2', obj=a, initial='t2')

report.add_widget(raw.TableWidget, a, 'Table')
from django import forms

from steelscript.appfwk.apps.datasource.modules.analysis import CriteriaTable
from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.libs.fields import Function
from steelscript.appfwk.apps.report.models import Report
from steelscript.appfwk.apps.report.modules import raw
from steelscript.appfwk.apps.report.tests.reports \
    import criteria_functions as funcs

report = Report.create(title='Criteria Pre Process')

section = report.add_section(title='Section 0')

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'}))

a = CriteriaTable.create('test-criteria-preprocess')

report.add_widget(raw.TableWidget, a, 'Table')
예제 #41
0
# This software is licensed under the terms and conditions of the MIT License
# accompanying the software ("License").  This software is distributed "AS IS"
# as set forth in the License.


from steelscript.appfwk.apps.datasource.models import TableField
from steelscript.appfwk.apps.report.models import Report
import steelscript.appfwk.apps.report.modules.yui3 as yui3

from steelscript.netprofiler.appfwk.datasources.netprofiler import \
    NetProfilerTimeSeriesTable, NetProfilerGroupbyTable, NetProfilerTable

report = Report.create("DSCP Report", position=10,
                       hidden_fields=['netprofiler_filterexpr'])

netprofiler_filterexpr = TableField.create(
    keyword='netprofiler_filterexpr')

interface_field = TableField.create(
    keyword='interface', label='Interface', required=True)

#
# Overall section
#  - netprofiler_filterexpr = "interface {interface}"
#
section = report.add_section("Overall",
                             section_keywords=['netprofiler_filterexpr',
                                               'interface_expr'])

section.fields.add(netprofiler_filterexpr)
section.fields.add(interface_field)