def create(cls, name, tables, func, columns=None, params=None, copy_fields=True, **kwargs): """ Class method to create an AnalysisTable. """ options = TableOptions(tables=tables, func=func, params=params) table = Table(name=name, module=__name__, options=options, **kwargs) table.save() if columns: for c in columns: Column.create(table, c) keywords = [] if tables and copy_fields: for table_id in tables.values(): for f in Table.objects.get(id=table_id).fields.all(): if f.keyword not in keywords: table.fields.add(f) keywords.append(f.keyword) return table
def create(cls, name, tables, func, columns=None, params=None, copy_fields=True, related_tables=None, **kwargs): """ Class method to create an AnalysisTable. """ options = TableOptions(tables=tables, related_tables=related_tables, func=func, params=params) table = Table(name=name, module=__name__, options=options, **kwargs) table.save() if columns: for c in columns: Column.create(table, c) keywords = [] if (tables or related_tables) and copy_fields: table_ids = [] for t in [tables, related_tables]: if t: table_ids.extend(t.values()) for table_id in table_ids: for f in Table.objects.get(id=table_id).fields.all(): if f.keyword not in keywords: table.fields.add(f) keywords.append(f.keyword) return table
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
def create(cls, name, **kwargs): logger.debug("Creating Solarwinds table %s" % name) t = Table(name=name, module=__name__, **kwargs) t.save() fields_add_device_selection( t, keyword="solarwinds_device", label="Solarwinds", module="solarwinds", enabled=True ) return t
def create(cls, name, html): logger.debug('Creating StaticHTMLTable %s' % name) options = TableOptions(html=html) t = Table(name=name, module=__name__, options=options) t.save() Column.create(t, 'html', label='html') return t
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, **kwargs): logger.debug('Creating Solarwinds table %s' % name) t = Table(name=name, module=__name__, **kwargs) t.save() fields_add_device_selection(t, keyword='solarwinds_device', label='Solarwinds', module='solarwinds', enabled=True) return t
def create(cls, name, **kwargs): logger.debug('Creating Profiler DeviceTable table %s' % name) t = Table(name=name, module=__name__, **kwargs) t.save() fields_add_device_selection(t, keyword='profiler_device', label='Profiler', module='profiler', enabled=True) return t
def create(cls, name, site_url, list_name, **kwargs): logger.debug('Creating Sharepoint table %s' % name) options = TableOptions(site_url=site_url, list_name=list_name) t = Table(name=name, module=__name__, options=options, **kwargs) t.save() fields_add_device_selection(t, keyword='sharepoint_device', label='Sharepoint', module='sharepoint_device', enabled=True) 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
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