From c8df16da8fcfd5918b93abe1feeafd4c2f5b1c3f Mon Sep 17 00:00:00 2001 From: Alexander Chadin Date: Tue, 13 Jun 2017 17:32:00 +0300 Subject: [PATCH] Add support for cron syntax Implements: blueprint cron-based-continuous-audits Change-Id: Ib281964fbf9c160791d30eafe94fd83937cac23e --- watcherclient/tests/functional/v1/test_audit.py | 3 ++- watcherclient/tests/unit/v1/test_audit_shell.py | 3 +++ watcherclient/v1/audit_shell.py | 5 +++-- watcherclient/v1/resource_fields.py | 5 +++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/watcherclient/tests/functional/v1/test_audit.py b/watcherclient/tests/functional/v1/test_audit.py index cb935b6..b12fa06 100644 --- a/watcherclient/tests/functional/v1/test_audit.py +++ b/watcherclient/tests/functional/v1/test_audit.py @@ -25,7 +25,8 @@ class AuditTests(base.TestCase): list_fields = ['UUID', 'Audit Type', 'State', 'Goal', 'Strategy'] detailed_list_fields = list_fields + ['Created At', 'Updated At', 'Deleted At', 'Parameters', - 'Interval', 'Audit Scope'] + 'Interval', 'Audit Scope', + 'Next Run Time'] audit_template_name = 'a' + uuidutils.generate_uuid() audit_uuid = None diff --git a/watcherclient/tests/unit/v1/test_audit_shell.py b/watcherclient/tests/unit/v1/test_audit_shell.py index c2d17ae..5afed99 100644 --- a/watcherclient/tests/unit/v1/test_audit_shell.py +++ b/watcherclient/tests/unit/v1/test_audit_shell.py @@ -68,6 +68,7 @@ AUDIT_1 = { 'interval': None, 'scope': '', 'auto_trigger': False, + 'next_run_time': None, } AUDIT_2 = { @@ -85,6 +86,7 @@ AUDIT_2 = { 'interval': None, 'scope': '', 'auto_trigger': False, + 'next_run_time': None, } AUDIT_3 = { @@ -102,6 +104,7 @@ AUDIT_3 = { 'interval': 3600, 'scope': '', 'auto_trigger': True, + 'next_run_time': None, } diff --git a/watcherclient/v1/audit_shell.py b/watcherclient/v1/audit_shell.py index d05e91e..c678d6c 100644 --- a/watcherclient/v1/audit_shell.py +++ b/watcherclient/v1/audit_shell.py @@ -150,8 +150,9 @@ class CreateAudit(command.ShowOne): '-i', '--interval', dest='interval', metavar='', - help=_('Audit interval (in seconds). ' - "Only used if the audit is CONTINUOUS.")) + help=_('Audit interval (in seconds or cron format). ' + 'Cron inteval can be used like: "*/5 * * * *". ' + 'Only used if the audit is CONTINUOUS.')) parser.add_argument( '-g', '--goal', dest='goal', diff --git a/watcherclient/v1/resource_fields.py b/watcherclient/v1/resource_fields.py index 307ecee..e34d114 100644 --- a/watcherclient/v1/resource_fields.py +++ b/watcherclient/v1/resource_fields.py @@ -32,11 +32,12 @@ AUDIT_TEMPLATE_SHORT_LIST_FIELD_LABELS = ['UUID', 'Name', 'Goal', 'Strategy'] # Audit AUDIT_FIELDS = ['uuid', 'created_at', 'updated_at', 'deleted_at', 'state', 'audit_type', 'parameters', 'interval', 'goal_name', - 'strategy_name', 'scope', 'auto_trigger'] + 'strategy_name', 'scope', 'auto_trigger', 'next_run_time'] AUDIT_FIELD_LABELS = ['UUID', 'Created At', 'Updated At', 'Deleted At', 'State', 'Audit Type', 'Parameters', 'Interval', 'Goal', - 'Strategy', 'Audit Scope', 'Auto Trigger'] + 'Strategy', 'Audit Scope', 'Auto Trigger', + 'Next Run Time'] AUDIT_SHORT_LIST_FIELDS = ['uuid', 'audit_type', 'state', 'goal_name', 'strategy_name',