Add host_aggregates in exclude rule of audit scope
Currently if user wants to skip some host_aggregates from audit, it is not possible. This patch adds host_aggregates into the exclude rule of audit scope. This patch also implements audit-tag-vm-metadata using scopes. TODOs: 1. Add tests 2. Remove old implementation of audit-tag-vm-metadata Change-Id: Ie86378cb02145a660bbf446eedb29dc311fa29d7 Implements: BP audit-tag-vm-metadata
This commit is contained in:
@@ -109,6 +109,21 @@ class AuditTemplatePostType(wtypes.Base):
|
||||
common_utils.Draft4Validator(
|
||||
default.DefaultScope.DEFAULT_SCHEMA).validate(audit_template.scope)
|
||||
|
||||
include_host_aggregates = False
|
||||
exclude_host_aggregates = False
|
||||
for rule in audit_template.scope:
|
||||
if 'host_aggregates' in rule:
|
||||
include_host_aggregates = True
|
||||
elif 'exclude' in rule:
|
||||
for resource in rule['exclude']:
|
||||
if 'host_aggregates' in resource:
|
||||
exclude_host_aggregates = True
|
||||
if include_host_aggregates and exclude_host_aggregates:
|
||||
raise exception.Invalid(
|
||||
message=_(
|
||||
"host_aggregates can't be "
|
||||
"included and excluded together"))
|
||||
|
||||
if audit_template.strategy:
|
||||
available_strategies = objects.Strategy.list(
|
||||
AuditTemplatePostType._ctx)
|
||||
|
||||
Reference in New Issue
Block a user