Add name for audit

This patch adds name for audit in dashboard.
Implements: blueprint add-name-for-audit-in-watcher-dashboard

Change-Id: I86992ac8f62cd44cafbaee84aaf5d22a187b6ee3
This commit is contained in:
Yumeng Bao 2018-07-26 17:28:28 +08:00
parent f0f6cef879
commit d62d8a8ba4
3 changed files with 14 additions and 2 deletions

View File

@ -55,7 +55,7 @@ def insert_watcher_policy_file():
class Audit(base.APIDictWrapper):
_attrs = ('uuid', 'created_at', 'modified_at', 'deleted_at',
_attrs = ('uuid', 'name', 'created_at', 'modified_at', 'deleted_at',
'state', 'audit_type', 'audit_template_uuid',
'audit_template_name', 'interval')
@ -81,6 +81,9 @@ class Audit(base.APIDictWrapper):
:param interval: Audit interval (default: None)
:type interval: int
:param name: Name for this audit
:type name: string
:return: the created Audit object
:rtype: :py:class:`~.Audit`
"""

View File

@ -35,6 +35,10 @@ class CreateForm(forms.SelfHandlingForm):
audit_template = forms.DynamicChoiceField(
label=_("Audit Template"),
add_item_link=ADD_AUDIT_TEMPLATES_URL)
audit_name = forms.CharField(max_length=255, label=_("Name"),
help_text=_("An audit name should not "
"duplicate with existed audits' names."),
required=False)
audit_type = forms.ChoiceField(label=_("Audit Type"),
choices=[(None, _("Select Audit Type")),
('oneshot', _('ONESHOT')),
@ -86,6 +90,7 @@ class CreateForm(forms.SelfHandlingForm):
params = {'audit_template_uuid': data.get('audit_template')}
params['audit_type'] = data['audit_type'].upper()
params['auto_trigger'] = data['auto_trigger']
params['name'] = data['audit_name']
if data['audit_type'] == 'continuous':
params['interval'] = data['interval']
else:

View File

@ -104,10 +104,14 @@ class ArchiveAudits(horizon.tables.DeleteAction):
class AuditsTable(horizon.tables.DataTable):
name = horizon.tables.Column(
uuid = horizon.tables.Column(
'uuid',
verbose_name=_("UUID"),
link="horizon:admin:audits:detail")
name = horizon.tables.Column(
'name',
verbose_name=_("Name"),
link="horizon:admin:audits:detail")
goal = horizon.tables.Column(
'goal_name',
verbose_name=_('Goal'))