本文整理汇总了Python中steelscript.appfwk.apps.datasource.models.TableField.create方法的典型用法代码示例。如果您正苦于以下问题:Python TableField.create方法的具体用法?Python TableField.create怎么用?Python TableField.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类steelscript.appfwk.apps.datasource.models.TableField
的用法示例。
在下文中一共展示了TableField.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_process_table
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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: add_netprofiler_application_field
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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}'
)
示例3: extend_filterexpr
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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()
示例4: post_process_table
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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)
示例5: post_process_table
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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)
示例6: post_process_table
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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)
示例7: post_process_table
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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')
示例8: post_process_table
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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()
示例9:
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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')
示例10:
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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')
示例11:
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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')
示例12: add_netprofiler_hostgroup_field
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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
)
示例13:
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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')
示例14: post_process_table
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
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)
示例15: software
# 需要导入模块: from steelscript.appfwk.apps.datasource.models import TableField [as 别名]
# 或者: from steelscript.appfwk.apps.datasource.models.TableField import create [as 别名]
# 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)