From d62d8a8ba41b30196354d8b609a0db65bfb60488 Mon Sep 17 00:00:00 2001 From: Yumeng Bao Date: Thu, 26 Jul 2018 17:28:28 +0800 Subject: [PATCH] Add name for audit This patch adds name for audit in dashboard. Implements: blueprint add-name-for-audit-in-watcher-dashboard Change-Id: I86992ac8f62cd44cafbaee84aaf5d22a187b6ee3 --- watcher_dashboard/api/watcher.py | 5 ++++- watcher_dashboard/content/audits/forms.py | 5 +++++ watcher_dashboard/content/audits/tables.py | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/watcher_dashboard/api/watcher.py b/watcher_dashboard/api/watcher.py index 068dced..0a2a456 100644 --- a/watcher_dashboard/api/watcher.py +++ b/watcher_dashboard/api/watcher.py @@ -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` """ diff --git a/watcher_dashboard/content/audits/forms.py b/watcher_dashboard/content/audits/forms.py index 6c2e50e..7edafe4 100644 --- a/watcher_dashboard/content/audits/forms.py +++ b/watcher_dashboard/content/audits/forms.py @@ -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: diff --git a/watcher_dashboard/content/audits/tables.py b/watcher_dashboard/content/audits/tables.py index b1cbe71..c17cb1e 100644 --- a/watcher_dashboard/content/audits/tables.py +++ b/watcher_dashboard/content/audits/tables.py @@ -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'))