New cron type for audit interval
This patch set adds cron supporting for audit. Implements: blueprint cron-based-continuous-audits Change-Id: I8570bebb13332dfba80185e912aeda45b6b4cd70
This commit is contained in:
@@ -16,8 +16,11 @@
|
||||
|
||||
"""Utilities and helper functions."""
|
||||
|
||||
import datetime
|
||||
import re
|
||||
|
||||
from croniter import croniter
|
||||
|
||||
from jsonschema import validators
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import strutils
|
||||
@@ -63,6 +66,15 @@ is_int_like = strutils.is_int_like
|
||||
strtime = timeutils.strtime
|
||||
|
||||
|
||||
def is_cron_like(value):
|
||||
"""Return True is submitted value is like cron syntax"""
|
||||
try:
|
||||
croniter(value, datetime.datetime.now())
|
||||
except Exception as e:
|
||||
raise exception.CronFormatIsInvalid(message=str(e))
|
||||
return True
|
||||
|
||||
|
||||
def safe_rstrip(value, chars=None):
|
||||
"""Removes trailing characters from a string if that does not make it empty
|
||||
|
||||
|
||||
Reference in New Issue
Block a user